2017-10-27 04:54:45 -05:00
|
|
|
if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV["ENABLE_LOGRAGE"]
|
2017-10-27 09:54:50 -05:00
|
|
|
require 'lograge'
|
|
|
|
|
2017-10-27 04:54:45 -05:00
|
|
|
Rails.application.configure do
|
|
|
|
config.lograge.enabled = true
|
|
|
|
|
|
|
|
config.lograge.custom_options = lambda do |event|
|
|
|
|
exceptions = %w(controller action format id)
|
2017-10-27 09:54:50 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
params: event.payload[:params].except(*exceptions),
|
|
|
|
type: :rails
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
if (logstash_uri = ENV["LOGSTASH_URI"].present?)
|
|
|
|
require 'logstash-logger'
|
|
|
|
|
|
|
|
config.lograge.formatter = Lograge::Formatters::Logstash.new
|
|
|
|
|
|
|
|
config.lograge.logger = LogStashLogger.new(
|
|
|
|
type: :tcp,
|
|
|
|
uri: logstash_uri
|
|
|
|
)
|
2017-10-27 04:54:45 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|