Class: Loggem::Logger
- Inherits:
-
Object
- Object
- Loggem::Logger
- Defined in:
- lib/loggem/logger.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
- #formatter ⇒ Object writeonly
Instance Method Summary collapse
-
#initialize(logger = ::Logger.new(STDOUT)) ⇒ Logger
constructor
A new instance of Logger.
- #method_missing(method, *arguments) ⇒ Object
Constructor Details
#initialize(logger = ::Logger.new(STDOUT)) ⇒ Logger
Returns a new instance of Logger.
11 12 13 14 15 |
# File 'lib/loggem/logger.rb', line 11 def initialize(logger = ::Logger.new(STDOUT)) @logger = logger @context = {} @formatter = ::Loggem::Formatters::Json.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *arguments) ⇒ Object
39 40 41 |
# File 'lib/loggem/logger.rb', line 39 def method_missing(method, *arguments) logger.public_send method, *arguments end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
7 8 9 |
# File 'lib/loggem/logger.rb', line 7 def context @context end |
#formatter=(formatter) ⇒ Object
19 20 21 22 23 |
# File 'lib/loggem/logger.rb', line 19 def formatter=(formatter) raise ArgumentError.new("Formatter must respond to 'call'") unless formatter.respond_to?(:call) @formatter = formatter end |