Class: PiiScrubber::Integrations::LoggerFormatter

Inherits:
Logger::Formatter
  • Object
show all
Defined in:
lib/pii_scrubber/integrations/logger_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_formatter = nil, **options) ⇒ LoggerFormatter

Returns a new instance of LoggerFormatter.



10
11
12
13
14
# File 'lib/pii_scrubber/integrations/logger_formatter.rb', line 10

def initialize(original_formatter = nil, **options)
  super()
  @original_formatter = original_formatter || ::Logger::Formatter.new
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/pii_scrubber/integrations/logger_formatter.rb', line 8

def options
  @options
end

#original_formatterObject (readonly)

Returns the value of attribute original_formatter.



8
9
10
# File 'lib/pii_scrubber/integrations/logger_formatter.rb', line 8

def original_formatter
  @original_formatter
end

Instance Method Details

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



16
17
18
19
20
21
22
23
# File 'lib/pii_scrubber/integrations/logger_formatter.rb', line 16

def call(severity, time, program_name, message)
  scrubbed_msg = format_message(message)
  if original_formatter.respond_to?(:call)
    original_formatter.call(severity, time, program_name, scrubbed_msg)
  else
    super(severity, time, program_name, scrubbed_msg)
  end
end