Module: Threatinator::Logger
- Defined in:
- lib/threatinator/logger.rb
Defined Under Namespace
Modules: Levels
Class Method Summary collapse
- .configure_logger(config) ⇒ Object
- .default_logger ⇒ Object
- .level ⇒ Object
- .level=(l) ⇒ Object
- .level_string ⇒ Object
- .levels ⇒ Object
- .logger_for(name) ⇒ Object
Class Method Details
.configure_logger(config) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/threatinator/logger.rb', line 27 def self.configure_logger(config) if config.level if l = self.levels.index(config.level) default_logger.level = l else default_logger.warn("Ignoring unknown logging level: #{config.level.inspect}.") end end end |
.default_logger ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/threatinator/logger.rb', line 13 def self.default_logger return @logger unless @logger.nil? @logger = logger_for('Threatinator') formatter = ::Log4r::PatternFormatter.new(:pattern => '[%d] %l %C: %M') console_outputter = ::Log4r::StderrOutputter.new('console', formatter: formatter) @logger.add console_outputter @logger.level = ::Log4r::INFO @logger end |
.level ⇒ Object
37 38 39 |
# File 'lib/threatinator/logger.rb', line 37 def self.level default_logger.level end |
.level=(l) ⇒ Object
41 42 43 |
# File 'lib/threatinator/logger.rb', line 41 def self.level=(l) default_logger.level = l end |
.level_string ⇒ Object
45 46 47 |
# File 'lib/threatinator/logger.rb', line 45 def self.level_string levels[level] end |
.levels ⇒ Object
49 50 51 |
# File 'lib/threatinator/logger.rb', line 49 def self.levels default_logger.levels end |
.logger_for(name) ⇒ Object
9 10 11 |
# File 'lib/threatinator/logger.rb', line 9 def self.logger_for(name) ::Log4r::Logger[name] || ::Log4r::Logger.new(name) end |