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 cfb6b69
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion elasticsearch-rails/lib/elasticsearch/rails/lograge.rb
Expand Up @@ -33,8 +33,18 @@ 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
if previous_lograge_custom_options.respond_to?(:call)
previous_lograge_custom_options.call(event)
else
previous_lograge_custom_options
end
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 cfb6b69

Please sign in to comment.