Module: Cyrel::Logging
- Included in:
- Query
- Defined in:
- lib/cyrel/logging.rb
Overview
Basic logging support for Cyrel. Debug logging is disabled by default.
Constant Summary collapse
- LOG_TAG =
'Cyrel'
Class Attribute Summary collapse
-
.backend ⇒ Logger
The configured logger.
Class Method Summary collapse
Instance Method Summary collapse
- #log_debug(msg) ⇒ Object
- #log_error(msg) ⇒ Object
- #log_info(msg) ⇒ Object
- #log_warn(msg) ⇒ Object
- #logger ⇒ Object
Class Attribute Details
.backend ⇒ Logger
Returns the configured logger.
14 15 16 |
# File 'lib/cyrel/logging.rb', line 14 def backend @backend end |
Class Method Details
.logger ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cyrel/logging.rb', line 20 def logger self.backend ||= begin log_level = ENV.fetch('CYREL_LOG_LEVEL', 'unknown') logger_base = Logger.new($stdout) logger_base.level = resolve_log_level(log_level) # Return a TaggedLogging instance without calling 'tagged!' ActiveSupport::TaggedLogging.new(logger_base) end end |
.resolve_log_level(log_level_str) ⇒ Object
16 17 18 |
# File 'lib/cyrel/logging.rb', line 16 def resolve_log_level(log_level_str) Logger.const_get(log_level_str.upcase) end |
Instance Method Details
#log_debug(msg) ⇒ Object
36 |
# File 'lib/cyrel/logging.rb', line 36 def log_debug(msg) = logger.debug { msg } |
#log_error(msg) ⇒ Object
39 |
# File 'lib/cyrel/logging.rb', line 39 def log_error(msg) = logger.error { msg } |
#log_info(msg) ⇒ Object
37 |
# File 'lib/cyrel/logging.rb', line 37 def log_info(msg) = logger.info { msg } |
#log_warn(msg) ⇒ Object
38 |
# File 'lib/cyrel/logging.rb', line 38 def log_warn(msg) = logger.warn { msg } |