Skip to content

Commit

Permalink
Avoid overriding previously defined custom options for lograge. Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
bolshakov committed Jan 18, 2018
1 parent 64f31b4 commit 58c4c18
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion elasticsearch-rails/lib/elasticsearch/rails/lograge.rb
Expand Up @@ -33,8 +33,15 @@ class Railtie < ::Rails::Railtie
include Elasticsearch::Rails::Instrumentation::ControllerRuntime
end

previous_lograge_custom_options = config.lograge.custom_options
config.lograge.custom_options = lambda do |event|
{ es: event.payload[:elasticsearch_runtime].to_f.round(2) }
previous_lograge_custom_options_hash =
if previous_lograge_custom_options && previous_lograge_custom_options.respond_to?(:call)
previous_lograge_custom_options.call(event)
else
{}
end
previous_lograge_custom_options_hash.merge(es: event.payload[:elasticsearch_runtime].to_f.round(2))
end
end
end
Expand Down

0 comments on commit 58c4c18

Please sign in to comment.