Sha256: 6209d559250b249e73c32bccf44ebcceef995f68f63a057c776ef36b952c81e1

Contents?: true

Size: 688 Bytes

Versions: 1

Compression:

Stored size: 688 Bytes

Contents

require 'lograge'
require 'lograge_tagged/version'

module LogrageTagged
  class TaggedKeyValueFormatter < Lograge::Formatters::KeyValue
    def initialize(tag = "request.app")
      @tag = tag
    end
    def call(data)
      "[#{@tag}] #{super}"
    end
  end

  class Railtie < Rails::Railtie
    require 'lograge/railtie'

    config.after_initialize do |app|
      app.config.lograge.formatter = LogrageTagged::TaggedKeyValueFormatter.new
      app.config.lograge.custom_options = ->(event) { { params: event.payload[:params] } }
      if app.config.lograge.enabled
        Lograge.set_formatter
        Lograge.set_lograge_log_options
      end
    end
  end if defined?(Rails)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lograge-tagged-0.3.2 lib/lograge_tagged.rb