Class: RailsAutoscaleAgent::LoggerProxy

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

Constant Summary collapse

TAG =
'[RailsAutoscale]'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject

Returns the value of attribute logger

Returns:

  • (Object)

    the current value of logger



13
14
15
# File 'lib/rails_autoscale_agent/logger.rb', line 13

def logger
  @logger
end

Instance Method Details

#debug(msg) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rails_autoscale_agent/logger.rb', line 28

def debug(msg)
  # Silence debug logs by default to avoiding being overly chatty (Rails logger defaults
  # to DEBUG level in production). Setting RAILS_AUTOSCALE_DEBUG=true enables debug logs,
  # even if the underlying logger severity level is INFO.
  if Config.instance.debug?
    if logger.respond_to?(:debug?) && logger.debug?
      logger.debug tag(msg)
    elsif logger.respond_to?(:info?) && logger.info?
      logger.info tag("[DEBUG] #{msg}")
    end
  end
end

#error(msg) ⇒ Object



16
17
18
# File 'lib/rails_autoscale_agent/logger.rb', line 16

def error(msg)
  logger.error tag(msg)
end

#info(msg) ⇒ Object



24
25
26
# File 'lib/rails_autoscale_agent/logger.rb', line 24

def info(msg)
  logger.info tag(msg) unless Config.instance.quiet?
end

#warn(msg) ⇒ Object



20
21
22
# File 'lib/rails_autoscale_agent/logger.rb', line 20

def warn(msg)
  logger.warn tag(msg)
end