Sha256: e64336d7086aaf26f7d62ccc37e9082a4d1ad9618905dcfd1d9f4a273995b0a2

Contents?: true

Size: 1012 Bytes

Versions: 8

Compression:

Stored size: 1012 Bytes

Contents

# frozen_string_literal: true

require 'lograge'

if Rails.env.staging? || Rails.env.production?
  Rails.application.configure do
    config.colorize_logging = false

    config.lograge.enabled = true
    config.lograge.formatter = ::Lograge::Formatters::Raw.new
    config.lograge.base_controller_class = [
      'ActionController::API',
      'ActionController::Base'
    ]

    config.lograge.ignore_actions = ['EIVO::StatusController#index']

    config.lograge.custom_options = ->(event) do
      result = {
        params: event.payload[:params].except('controller', 'action', 'format'),
        request_id: event.payload[:request_id]
      }

      result[:user_id] = event.payload[:user_id] if event.payload[:user_id]
      result[:organization_id] = event.payload[:organization_id] if event.payload[:organization_id]

      # https://github.com/roidrage/lograge/pull/307
      if event.respond_to?(:allocations)
        result[:allocations] = event.allocations
      end

      result
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
eivo-rails-api-0.1.11 config/initializers/logger.rb
eivo-rails-api-0.1.10 config/initializers/logger.rb
eivo-rails-0.1.10 config/initializers/logger.rb
eivo-rails-api-0.1.9 config/initializers/logger.rb
eivo-rails-api-0.1.8 config/initializers/logger.rb
eivo-rails-0.1.9 config/initializers/logger.rb
eivo-rails-0.1.8 config/initializers/logger.rb
eivo-rails-api-0.1.7 config/initializers/logger.rb