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, mac: false, scrubber: nil) ⇒ Formatter

Returns a new instance of Formatter.



5
6
7
8
9
10
11
12
13
14
15
# 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, mac: false, scrubber: nil)
  @formatter = formatter || ::Logger::Formatter.new
  @url_password = url_password
  @email = email
  @credit_card = credit_card
  @phone = phone
  @ssn = ssn
  @ip = ip
  @mac = mac
  @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



32
33
34
# File 'lib/logstop/formatter.rb', line 32

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

Instance Method Details

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



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

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,
    mac: @mac,
    scrubber: @scrubber
  )
end

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

for tagged logging

Returns:

  • (Boolean)


37
38
39
# File 'lib/logstop/formatter.rb', line 37

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