Class: Logstop::Formatter

Inherits:
Logger::Formatter
  • Object
show all
Defined in:
lib/logstop/formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(formatter = nil, ip: false, scrubber: nil) ⇒ Formatter

Returns a new instance of Formatter.



5
6
7
8
9
# File 'lib/logstop/formatter.rb', line 5

def initialize(formatter = nil, ip: false, scrubber: nil)
  @formatter = formatter || ::Logger::Formatter.new
  @ip = ip
  @scrubber = scrubber
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object

for tagged logging



16
17
18
# File 'lib/logstop/formatter.rb', line 16

def method_missing(method_name, *arguments, &block)
  @formatter.send(method_name, *arguments, &block)
end

Instance Method Details

#call(severity, timestamp, progname, msg) ⇒ Object



11
12
13
# File 'lib/logstop/formatter.rb', line 11

def call(severity, timestamp, progname, msg)
  Logstop.scrub(@formatter.call(severity, timestamp, progname, msg), ip: @ip, scrubber: @scrubber)
end

#respond_to?(method_name, include_private = false) ⇒ Boolean

for tagged logging

Returns:

  • (Boolean)


21
22
23
# File 'lib/logstop/formatter.rb', line 21

def respond_to?(method_name, include_private = false)
  @formatter.send(:respond_to?, method_name, include_private) || super
end