Sha256: dc320172523c729451002649b4fd79023027fc3b105e7afed1f563a2619e57d3

Contents?: true

Size: 724 Bytes

Versions: 4

Compression:

Stored size: 724 Bytes

Contents

require "logger"

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

    def call(severity, timestamp, progname, msg)
      Logstop.scrub(@formatter.call(severity, timestamp, progname, msg), ip: @ip, 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

4 entries across 4 versions & 1 rubygems

Version Path
logstop-0.2.7 lib/logstop/formatter.rb
logstop-0.2.6 lib/logstop/formatter.rb
logstop-0.2.5 lib/logstop/formatter.rb
logstop-0.2.4 lib/logstop/formatter.rb