Class: Supergood::Logger

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

Instance Method Summary collapse

Constructor Details

#initialize(api, config, header_options) ⇒ Logger

Returns a new instance of Logger.



8
9
10
11
12
13
# File 'lib/supergood/logger.rb', line 8

def initialize(api, config, header_options)
  super(STDOUT)
  @api = api
  @config = config
  @header_options = header_options
end

Instance Method Details

#debug(payload) ⇒ Object



33
34
35
36
37
# File 'lib/supergood/logger.rb', line 33

def debug(payload)
  if(ENV['SUPERGOOD_LOG_LEVEL'] == 'debug')
    super
  end
end

#error(data, error, msg) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/supergood/logger.rb', line 15

def error(data, error, msg)
  if(ENV['SUPERGOOD_LOG_LEVEL'] == 'debug')
    super(error)
  end
  @api.post_errors(
    {
      error: error.backtrace.join('\n'),
      message: msg,
      payload: {
        config: @config,
        data: data,
        packageName: 'supergood-rb',
        packageVersion: Supergood::VERSION
      }
    }
  )
end