Class: Logification::Logger
- Inherits:
-
Object
- Object
- Logification::Logger
- Includes:
- Helpers::LoggingMethods, Helpers::Wrapper
- Defined in:
- lib/logification/logger.rb
Constant Summary
Constants included from Helpers::LoggingMethods
Instance Attribute Summary collapse
-
#base_logger ⇒ Object
Returns the value of attribute base_logger.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nested_count ⇒ Object
Returns the value of attribute nested_count.
Instance Method Summary collapse
- #default_logger(name) ⇒ Object
- #duplicate(name, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Logger
constructor
A new instance of Logger.
- #level ⇒ Object
- #level=(value) ⇒ Object
Methods included from Helpers::Wrapper
Methods included from Helpers::LoggingMethods
#debug, #error, #fatal, #info, #warn
Constructor Details
#initialize(options = {}) ⇒ Logger
Returns a new instance of Logger.
16 17 18 19 20 21 |
# File 'lib/logification/logger.rb', line 16 def initialize(={}) self.name = [:name] || "logification" self.base_logger = [:base_logger] || default_logger(@name) self.nested_count = [:nested_count] || 0 self.level = [:level] || :debug end |
Instance Attribute Details
#base_logger ⇒ Object
Returns the value of attribute base_logger.
11 12 13 |
# File 'lib/logification/logger.rb', line 11 def base_logger @base_logger end |
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/logification/logger.rb', line 11 def name @name end |
#nested_count ⇒ Object
Returns the value of attribute nested_count.
11 12 13 |
# File 'lib/logification/logger.rb', line 11 def nested_count @nested_count end |
Instance Method Details
#default_logger(name) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/logification/logger.rb', line 23 def default_logger(name) Log4r::Logger.new(name).tap do |l| l.outputters = Log4r::Outputter.stdout.tap do |o| o.formatter = Log4r::PatternFormatter.new(pattern: "%d %.04l [%C] - %M") end l.level = translate_level(:debug) end end |
#duplicate(name, options = {}) ⇒ Object
45 46 47 48 |
# File 'lib/logification/logger.rb', line 45 def duplicate(name, ={}) settings = current_settings.merge() self.class.new(settings.merge(name: name)) end |
#level ⇒ Object
36 37 38 |
# File 'lib/logification/logger.rb', line 36 def level LOG4R_LEVEL_TRANSLATION.key(base_logger.level) end |
#level=(value) ⇒ Object
40 41 42 43 |
# File 'lib/logification/logger.rb', line 40 def level=(value) base_logger.level = translate_level(value) @level = value end |