mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
29 lines
757 B
Ruby
29 lines
757 B
Ruby
if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV["ENABLE_LOGRAGE"]
|
|
require 'lograge'
|
|
|
|
Rails.application.configure do
|
|
config.lograge.enabled = true
|
|
|
|
logstash_uri = ENV["LOGSTASH_URI"]
|
|
|
|
config.lograge.custom_options = lambda do |event|
|
|
exceptions = %w(controller action format id)
|
|
|
|
output = {
|
|
params: event.payload[:params].except(*exceptions),
|
|
database: RailsMultisite::ConnectionManagement.current_db
|
|
}
|
|
|
|
output[:type] = :rails if logstash_uri
|
|
output
|
|
end
|
|
|
|
if logstash_uri
|
|
require 'logstash-logger'
|
|
|
|
config.lograge.formatter = Lograge::Formatters::Logstash.new
|
|
config.lograge.logger = LogStashLogger.new(uri: logstash_uri)
|
|
end
|
|
end
|
|
end
|