Rescue from errors when trying to append custom payloads to lograge output.
This commit is contained in:
parent
cff9b8846d
commit
2ff3444568
|
@ -8,19 +8,20 @@ if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV["
|
||||||
Rails.application.configure do
|
Rails.application.configure do
|
||||||
config.lograge.enabled = true
|
config.lograge.enabled = true
|
||||||
|
|
||||||
# Seeing RuntimeError (Missing rack.input)
|
config.lograge.custom_payload do |controller|
|
||||||
# for: `/topics/timings`
|
begin
|
||||||
#
|
{
|
||||||
#
|
ip: controller.request.remote_ip,
|
||||||
# config.lograge.custom_payload do |controller|
|
username: controller.current_user&.username,
|
||||||
# username = controller.try(:current_user)&.username rescue nil
|
}
|
||||||
# {
|
rescue => e
|
||||||
# ip: controller.request.remote_ip,
|
Rails.logger.warn("Failed to append custom payload: #{e.message}\n#{e.backtrace.join("\n")}")
|
||||||
# username: username,
|
{}
|
||||||
# }
|
end
|
||||||
# end
|
end
|
||||||
|
|
||||||
config.lograge.custom_options = lambda do |event|
|
config.lograge.custom_options = lambda do |event|
|
||||||
|
begin
|
||||||
exceptions = %w(controller action format id)
|
exceptions = %w(controller action format id)
|
||||||
|
|
||||||
params = event.payload[:params].except(*exceptions)
|
params = event.payload[:params].except(*exceptions)
|
||||||
|
@ -48,6 +49,10 @@ if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV["
|
||||||
end
|
end
|
||||||
|
|
||||||
output
|
output
|
||||||
|
rescue => e
|
||||||
|
Rails.logger.warn("Failed to append custom options: #{e.message}\n#{e.backtrace.join("\n")}")
|
||||||
|
{}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ENV["LOGSTASH_URI"]
|
if ENV["LOGSTASH_URI"]
|
||||||
|
|
Loading…
Reference in New Issue