Fixes #3556 - Backtrace lines pollute log.
This commit is contained in:
parent
7700a25ca6
commit
d11d1d4106
2 changed files with 21 additions and 2 deletions
|
@ -3,7 +3,11 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
||||
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
||||
# Rails.backtrace_cleaner.add_silencer { |line| %r{puma|rubygems}.match?(line) }
|
||||
|
||||
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
||||
# You can add backtrace filters to modify lines of data.
|
||||
# Rails.backtrace_cleaner.add_filter { |line| line.gsub(Rails.root.to_s, '') }
|
||||
|
||||
# You can also remove all the silencers and filters if you're trying to debug a problem that might stem from framework code.
|
||||
# Rails.backtrace_cleaner.remove_silencers!
|
||||
# Rails.backtrace_cleaner.remove_filters!
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
# This customization adds the id of the current Thread to all log lines.
|
||||
# The #msg2str method will be extended, so that the "Rails.bracktrace_cleaner" can be used to clean the exceptions.
|
||||
# It was introduced to make it more easy to follow the execution of tasks in the log in threaded processes.
|
||||
#
|
||||
# before:
|
||||
|
@ -18,5 +19,19 @@ class Logger
|
|||
def call(severity, time, progname, msg)
|
||||
format(FORMAT_WITH_THREAD_ID, severity[0..0], format_datetime(time), Process.pid, Thread.current.object_id, severity, progname, msg2str(msg))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def msg2str(msg)
|
||||
case msg
|
||||
when ::String
|
||||
msg
|
||||
when ::Exception
|
||||
# "#{ msg.message } (#{ msg.class })\n#{ msg.backtrace.join("\n") if msg.backtrace }"
|
||||
"#{msg.message} (#{msg.class})\n#{Rails.backtrace_cleaner.clean(msg.backtrace).join("\n") if msg.backtrace}"
|
||||
else
|
||||
msg.inspect
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue