Sha256: 860f11230807a9682071e7fcdc8aa7da95695621ad5618ae02d247c7d9452efe

Contents?: true

Size: 759 Bytes

Versions: 1

Compression:

Stored size: 759 Bytes

Contents

module LineLog
  class Customizer
    class << self; attr_accessor :formatter, :data end

    def initialize(app, logger=nil, formatter=LineLog::Formatters::KeyValue.new)
      @app = app
      @logger = logger
      self.class.formatter = formatter
    end

    # making it thread safe. Visit https://github.com/cerner/gc_stats/issues/3 for more info about this
    def call(event)
      dup._call(event)
    end

    def _call(event)
      began_at = Time.now
      @app.call(event).tap do |request_data|
        request_status = request_data.first # status is on the first position, it is an array
        message = LineLog::MessageBuilder.new(event, request_status, began_at).call
        LineLog::Writer.call(message, @logger)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
line_log-0.1.1 lib/line_log/customizer.rb