Module: Observed::Logging

Includes:
Configurable
Included in:
Translator
Defined in:
lib/observed/logging.rb

Instance Method Summary collapse

Methods included from Configurable

#configure, #get_attribute_value, #has_attribute_value?, included, #initialize

Instance Method Details

#log_debug(message) ⇒ Object

Log the debug message through the logger configured via the :logger attribute

Parameters:

  • message (String)


18
19
20
# File 'lib/observed/logging.rb', line 18

def log_debug(message)
  logger.debug message if logging_enabled?
end

#log_error(message) ⇒ Object

Log the error message through the logger configured via the :logger attribute

Parameters:

  • message (String)


36
37
38
# File 'lib/observed/logging.rb', line 36

def log_error(message)
  logger.error message if logging_enabled?
end

#log_info(message) ⇒ Object

Log the info message through the logger configured via the :logger attribute

Parameters:

  • message (String)


24
25
26
# File 'lib/observed/logging.rb', line 24

def log_info(message)
  logger.info message if logging_enabled?
end

#log_warn(message) ⇒ Object

Log the warn message through the logger configured via the :logger attribute

Parameters:

  • message (String)


30
31
32
# File 'lib/observed/logging.rb', line 30

def log_warn(message)
  logger.warn message if logging_enabled?
end

#logging_enabled?Boolean

Returns ‘true` if a value is set for the attribute :logger.

Returns:

  • (Boolean)

    ‘true` if a value is set for the attribute :logger



12
13
14
# File 'lib/observed/logging.rb', line 12

def logging_enabled?
  has_attribute_value? :logger
end