Class: ResponseLogger

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

Instance Method Summary collapse

Constructor Details

#initialize(log_path) ⇒ ResponseLogger

Returns a new instance of ResponseLogger.



5
6
7
# File 'lib/veracodecli/log.rb', line 5

def initialize(log_path)
  @path = log_path
end

Instance Method Details

#check_log_file(file_path) ⇒ Object



19
20
21
# File 'lib/veracodecli/log.rb', line 19

def check_log_file(file_path)
  File.open file_path, 'w' unless File.exist? file_path
end

#log(call, code, response) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/veracodecli/log.rb', line 9

def log(call, code, response)
  check_log_file "#{@path}/veracodecli.log"
  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



23
24
25
# File 'lib/veracodecli/log.rb', line 23

def timestamp
  `date`
end