Sha256: 5d163102f03cd56ba6454a6f2d487a721df05b4b6e8f2e3ea11e3488ebbb1ace

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require 'lograge'

module LogToolbox
  class LogrageConfig
    # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
    def self.configure
      Rails.application.configure do
        config.lograge.enabled = true
        config.lograge.base_controller_class = 'ActionController::API'
        config.lograge.formatter = Lograge::Formatters::Json.new

        config.lograge.custom_options = lambda do |event|
          {
            activityID: event.payload[:activityID],
            event_at: event.payload[:event_at],
            level: 'INFO',
            service_name: event.payload[:service_name],
            version: event.payload[:version],
            origin_ipv4: event.payload[:origin_ipv4],
            destination_ipv4: event.payload[:destination_ipv4],
            username: event.payload[:username],
            exception_stack: event.payload[:exception_stack],
            response: event.payload[:response]
          }
        end
      end
      # rubocop:enable Metrics/AbcSize,Metrics/MethodLength
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
log_toolbox-1.2.0 lib/log_toolbox/lograge_config.rb