DEV: Recover @timestamp in unicorn logs when logstash logger is enabled (#28008)

This is a regression introduced in 28f5550886
This commit is contained in:
Alan Guo Xiang Tan 2024-07-22 15:21:41 +08:00 committed by GitHub
parent e0f066bed3
commit 5105fce899
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -44,7 +44,8 @@ Discourse::Application.configure do
config.log_level = ENV["DISCOURSE_DEV_LOG_LEVEL"] if ENV["DISCOURSE_DEV_LOG_LEVEL"]
config.active_record.logger = nil if ENV["RAILS_DISABLE_ACTIVERECORD_LOGS"] == "1"
config.active_record.logger = nil if ENV["RAILS_DISABLE_ACTIVERECORD_LOGS"] == "1" ||
ENV["ENABLE_LOGSTASH_LOGGER"] == "1"
config.active_record.verbose_query_logs = true if ENV["RAILS_VERBOSE_QUERY_LOGS"] == "1"
if defined?(BetterErrors)

View File

@ -11,7 +11,11 @@ if enable_logstash_logger
require_relative "../lib/discourse_logstash_logger"
require_relative "../lib/unicorn_logstash_patch"
FileUtils.touch(unicorn_stderr_path) if !File.exist?(unicorn_stderr_path)
logger DiscourseLogstashLogger.logger(logdev: unicorn_stderr_path, type: :unicorn)
logger DiscourseLogstashLogger.logger(
logdev: unicorn_stderr_path,
type: :unicorn,
customize_event: lambda { |event| event["@timestamp"] = ::Time.now.utc },
)
else
logger Logger.new(STDOUT)
end