Class: Astrobot::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/astrobot/logger.rb

Class Method Summary collapse

Class Method Details

.add(message) ⇒ Object



3
4
5
# File 'lib/astrobot/logger.rb', line 3

def self.add(message)
  Kernel.puts "[TransmissionApi #{Time.now.strftime( "%F %T" )}] #{message}" if Astrobot.config[:debug_mode]
end

.debug(response) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/astrobot/logger.rb', line 7

def self.debug(response)
  body = nil
  begin
    body = JSON.parse(response.body).to_yaml
  rescue
    body = response.body
  end

  headers = response.headers.to_yaml

  add "response.code: #{response.code}"
  add "response.message: #{response.message}"

  add "response.body:"
  add body
  add "-----------------"

  add "response.headers:"
  add headers
  add "------------------"
end