Class: Clogs::Log
- Inherits:
-
Object
- Object
- Clogs::Log
- Defined in:
- lib/clogs/log.rb
Overview
Lacci insists on a logging implementation being plugged in before any Shoes
object exists. Scarpe ships two (one backed by the logging gem, one
simple); Clogs has its own so that a packaged app needs no logging
dependency at all.
Configure with SCARPE_LOG_LEVEL (debug/info/warn/error/fatal) or SCARPE_DEBUG=1.
Defined Under Namespace
Classes: Logger
Constant Summary collapse
- LEVELS =
{ debug: 0, info: 1, warn: 2, error: 3, fatal: 4 }.freeze
Instance Method Summary collapse
- #configure_logger(config) ⇒ Object
- #emit(component, level, message) ⇒ Object
-
#initialize(out = $stderr) ⇒ Log
constructor
A new instance of Log.
- #logger_for_component(component) ⇒ Object
Constructor Details
#initialize(out = $stderr) ⇒ Log
Returns a new instance of Log.
14 15 16 17 |
# File 'lib/clogs/log.rb', line 14 def initialize(out = $stderr) @out = out @level = :warn end |
Instance Method Details
#configure_logger(config) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/clogs/log.rb', line 19 def configure_logger(config) level = if ENV["SCARPE_LOG_LEVEL"] ENV["SCARPE_LOG_LEVEL"].downcase.to_sym elsif config.is_a?(Hash) (config["default"] || config[:default] || "warn").to_s.to_sym else :warn end @level = LEVELS.key?(level) ? level : :warn end |