Class: ResponseLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/veracodecli/log.rb

Instance Method Summary collapse

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 @ #{timestamp}"
  log.write "HTTP #{code}\n"
  log.write response
  log.write "\n"
  log.close
end

#timestampObject

Returns current system date & time.



21
22
23
# File 'lib/veracodecli/log.rb', line 21

def timestamp
  `date`
end