Class: Logstop::Formatter

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

Instance Method Summary collapse

Constructor Details

#initialize(formatter = nil, url_password: true, email: true, credit_card: true, phone: true, ssn: true, ip: false, scrubber: nil) ⇒ Formatter

Returns a new instance of Formatter.



5
6
7
8
9
10
11
12
13
14
# File 'lib/logstop/formatter.rb', line 5

def initialize(formatter = nil, url_password: true, email: true, credit_card: true, phone: true, ssn: true, ip: false, scrubber: nil)
  @formatter = formatter || ::Logger::Formatter.new
  @url_password = url_password
  @email = email
  @credit_card = credit_card
  @phone = phone
  @ssn = ssn
  @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



30
31
32
# File 'lib/logstop/formatter.rb', line 30

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

Instance Method Details

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



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/logstop/formatter.rb', line 16

def call(severity, timestamp, progname, msg)
  Logstop.scrub(
    @formatter.call(severity, timestamp, progname, msg),
    url_password: @url_password,
    email: @email,
    credit_card: @credit_card,
    phone: @phone,
    ssn: @ssn,
    ip: @ip,
    scrubber: @scrubber
  )
end

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

for tagged logging

Returns:

  • (Boolean)


35
36
37
# File 'lib/logstop/formatter.rb', line 35

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