mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:40:53 -06:00
f595d599dd
`Rails.logger.chained` was provided by Logster before Rails 7.1 introduced their broadcast logger. Now all the loggers are added to `Rails.logger.broadcasts`. Some code in our initializers was still using `chained` instead of `broadcasts`.
28 lines
795 B
Ruby
28 lines
795 B
Ruby
# frozen_string_literal: true
|
|
|
|
if Rails.env.production? || ENV["ENABLE_LOGS_TRUNCATION"] == "1"
|
|
def set_or_extend_truncate_logs_formatter(logger)
|
|
if logger.formatter
|
|
logger.formatter.extend(
|
|
Module.new do
|
|
def call(*args)
|
|
truncate_logs_formatter.call(super(*args))
|
|
end
|
|
|
|
def truncate_logs_formatter
|
|
@formatter ||=
|
|
TruncateLogsFormatter.new(log_line_max_chars: GlobalSetting.log_line_max_chars)
|
|
end
|
|
end,
|
|
)
|
|
else
|
|
logger.formatter =
|
|
TruncateLogsFormatter.new(log_line_max_chars: GlobalSetting.log_line_max_chars)
|
|
end
|
|
end
|
|
|
|
Rails.application.config.to_prepare do
|
|
Rails.logger.broadcasts.each { |logger| set_or_extend_truncate_logs_formatter(logger) }
|
|
end
|
|
end
|