mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 23:31:18 +08:00
DEV: Apply Logster.store.ignore
to DiscourseLogstashLogger
as well (#27819)
This commit updates `DiscourseLogstashLogger#add_with_opts` to avoid logging messages that matches regexp patterns configured in `Logster.store.ignore`. Those error logs are mostly triggered by clients and do not serve any useful purpose.
This commit is contained in:

committed by
GitHub

parent
d4c603984f
commit
c9775d5f72
@ -83,9 +83,14 @@ class DiscourseLogstashLogger < Logger
|
||||
#
|
||||
# In theory we could get logster to include the exception class and message in opts but logster currently does not
|
||||
# need those options so we are parsing it from the message for now and not making a change in logster.
|
||||
if progname == "web-exception" && message =~ /\A([^\(\)]+)\s{1}\(([\s\S]+)\)/
|
||||
event["exception.class"] = $1
|
||||
event["exception.message"] = $2.strip
|
||||
if progname == "web-exception"
|
||||
# `Logster.store.ignore` is set in the logster initializer and is an array of regex patterns.
|
||||
return if Logster.store&.ignore&.any? { |pattern| pattern.match(message) }
|
||||
|
||||
if message =~ /\A([^\(\)]+)\s{1}\(([\s\S]+)\)/
|
||||
event["exception.class"] = $1
|
||||
event["exception.message"] = $2.strip
|
||||
end
|
||||
end
|
||||
|
||||
if (env = opts&.dig(:env)).present?
|
||||
|
Reference in New Issue
Block a user