Class: Ruby::JSONFormatter::Base

Inherits:
Logger::Formatter
  • Object
show all
Includes:
LogFormatter::Common, LogFormatter::Common::JSON
Defined in:
lib/log_formatter/ruby_json_formatter.rb

Instance Method Summary collapse

Methods included from LogFormatter::Common::JSON

#build_event

Methods included from LogFormatter::Common

#current_time, #msg2str

Constructor Details

#initialize(app = nil, ext = {}) {|@config| ... } ⇒ Base

Returns a new instance of Base.

Yields:

  • (@config)


13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/log_formatter/ruby_json_formatter.rb', line 13

def initialize(app = nil, ext = {})
  @app = app
  @ext = ext.is_a?(Hash) ? ext : {ext_info: ext.inspect}
  @config = {
    level: :log_level,
    type: :log_type,
    app: :log_app,
    timestamp: :log_timestamp
  }

  yield @config if block_given?
end

Instance Method Details

#call(severity, time, progname, message) ⇒ Object



26
27
28
# File 'lib/log_formatter/ruby_json_formatter.rb', line 26

def call(severity, time, progname, message)
  @event = build_event(message, severity, time, progname)
end