Class: ResponseLogger
- Inherits:
-
Object
- Object
- ResponseLogger
- Defined in:
- lib/veracodecli/log.rb
Instance Method Summary collapse
-
#initialize(log_path) ⇒ ResponseLogger
constructor
Logger initialization, records the desired log file path.
-
#log(call, code, response) ⇒ Object
writes the following information for the passed response string: date & time the call was made, body (response), call name (call), HTTP response code (code).
-
#timestamp ⇒ Object
Returns current system date & time.
Constructor Details
#initialize(log_path) ⇒ ResponseLogger
Logger initialization, records the desired log file path.
6 7 8 |
# File 'lib/veracodecli/log.rb', line 6 def initialize(log_path) @path = log_path end |
Instance Method Details
#log(call, code, response) ⇒ Object
writes the following information for the passed response string: date & time the call was made, body (response), call name (call), HTTP response code (code).
11 12 13 14 15 16 17 18 |
# File 'lib/veracodecli/log.rb', line 11 def log(call, code, response) log = File.open "#{@path}/veracodecli.log", 'a+' log.write "#{call} called @ #{}" log.write "HTTP #{code}\n" log.write response log.write "\n" log.close end |
#timestamp ⇒ Object
Returns current system date & time.
21 22 23 |
# File 'lib/veracodecli/log.rb', line 21 def `date` end |