Sha256: 21fd601c6b294d662f74492713270b558bb0e9df8f6ca681cd20d9068eb0a334

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require "logger"

module Logstop
  class Formatter < ::Logger::Formatter
    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

    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

    # for tagged logging
    def method_missing(method_name, *arguments, &block)
      @formatter.send(method_name, *arguments, &block)
    end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
logstop-0.4.0 lib/logstop/formatter.rb
logstop-0.3.1 lib/logstop/formatter.rb
logstop-0.3.0 lib/logstop/formatter.rb