Class: Logasm::Adapters::StdoutAdapter
- Inherits:
-
Object
- Object
- Logasm::Adapters::StdoutAdapter
- Extended by:
- Forwardable
- Defined in:
- lib/logasm/adapters/stdout_adapter.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(level) ⇒ StdoutAdapter
constructor
A new instance of StdoutAdapter.
- #log(level, metadata = {}) ⇒ Object
Constructor Details
#initialize(level) ⇒ StdoutAdapter
Returns a new instance of StdoutAdapter.
12 13 14 15 |
# File 'lib/logasm/adapters/stdout_adapter.rb', line 12 def initialize(level, *) @logger = Logger.new(STDOUT) @logger.level = level end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
8 9 10 |
# File 'lib/logasm/adapters/stdout_adapter.rb', line 8 def logger @logger end |
Instance Method Details
#log(level, metadata = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/logasm/adapters/stdout_adapter.rb', line 17 def log(level, = {}) = [:message] data = .select { |key, value| key != :message } log_data = [ , data.empty? ? nil : Oj.dump(data, mode: :compat, time_format: :ruby) ].compact.join(' ') @logger.public_send level, log_data end |