Don't add time to logs when using logstash formatter.

This commit is contained in:
Guo Xiang Tan 2017-11-02 14:40:18 +08:00
parent edf4af608e
commit 09cee4c315
1 changed files with 6 additions and 2 deletions

View File

@ -4,6 +4,8 @@ if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV["
Rails.application.configure do
config.lograge.enabled = true
logstash_formatter = ENV["LOGSTASH_FORMATTER"]
config.lograge.custom_options = lambda do |event|
exceptions = %w(controller action format id)
@ -13,11 +15,13 @@ if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV["
output = {
params: params,
database: RailsMultisite::ConnectionManagement.current_db,
time: event.time,
}
output[:time] = event.time unless logstash_formatter
output
end
if ENV["LOGSTASH_FORMATTER"]
if logstash_formatter
config.lograge.formatter = Lograge::Formatters::Logstash.new
end
end