Sha256: 0eb2288aaf7699fe1d5a79c5a35c7d68a43f645262b3d5fb97076b91b44e48be

Contents?: true

Size: 661 Bytes

Versions: 1

Compression:

Stored size: 661 Bytes

Contents

require "logger"

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

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

1 entries across 1 versions & 1 rubygems

Version Path
logstop-0.2.3 lib/logstop/formatter.rb