Class: Applicaster::Logger::Formatter
- Inherits:
-
Logger::Formatter
- Object
- Logger::Formatter
- Applicaster::Logger::Formatter
- Includes:
- LogStashLogger::TaggedLogging::Formatter
- Defined in:
- lib/applicaster/logger/formatter.rb
Instance Attribute Summary collapse
-
#default_fields ⇒ Object
Returns the value of attribute default_fields.
Instance Method Summary collapse
- #call(severity, time, progname, message) ⇒ Object
-
#initialize(options = {}) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize(options = {}) ⇒ Formatter
Returns a new instance of Formatter.
15 16 17 18 |
# File 'lib/applicaster/logger/formatter.rb', line 15 def initialize( = {}) @default_fields = .with_indifferent_access @datetime_format = nil end |
Instance Attribute Details
#default_fields ⇒ Object
Returns the value of attribute default_fields.
13 14 15 |
# File 'lib/applicaster/logger/formatter.rb', line 13 def default_fields @default_fields end |
Instance Method Details
#call(severity, time, progname, message) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/applicaster/logger/formatter.rb', line 20 def call(severity, time, progname, ) data = default_fields. deep_merge(()). merge({ severity: severity, host: HOST }). deep_merge(Applicaster::Logger::ThreadContext.current) event = LogStash::Event.new(data) event. = time.utc.iso8601(3) event. = "#{event.to_json}\n" end |