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-11-14 19:02:34 -06:00
|
|
|
if Rails.configuration.multisite
|
|
|
|
Rails.logger.formatter = ActiveSupport::Logger::SimpleFormatter.new
|
|
|
|
end
|
|
|
|
|
2017-10-27 04:54:45 -05:00
|
|
|
Rails.application.configure do
|
|
|
|
config.lograge.enabled = true
|
|
|
|
|
2017-11-02 01:40:18 -05:00
|
|
|
logstash_formatter = ENV["LOGSTASH_FORMATTER"]
|
|
|
|
|
2017-10-27 04:54:45 -05:00
|
|
|
config.lograge.custom_options = lambda do |event|
|
|
|
|
exceptions = %w(controller action format id)
|
2017-10-27 09:54:50 -05:00
|
|
|
|
2017-10-31 19:37:11 -05:00
|
|
|
params = event.payload[:params].except(*exceptions)
|
|
|
|
params[:files].map!(&:headers) if params[:files]
|
|
|
|
|
2017-10-27 10:31:17 -05:00
|
|
|
output = {
|
2017-11-08 01:19:45 -06:00
|
|
|
params: params.to_query,
|
2017-10-27 11:46:16 -05:00
|
|
|
database: RailsMultisite::ConnectionManagement.current_db,
|
2017-10-27 09:54:50 -05:00
|
|
|
}
|
2017-11-02 01:40:18 -05:00
|
|
|
|
|
|
|
output[:time] = event.time unless logstash_formatter
|
|
|
|
output
|
2017-10-27 04:54:45 -05:00
|
|
|
end
|
2017-10-31 19:37:11 -05:00
|
|
|
|
2017-11-02 01:40:18 -05:00
|
|
|
if logstash_formatter
|
2017-10-31 19:37:11 -05:00
|
|
|
config.lograge.formatter = Lograge::Formatters::Logstash.new
|
|
|
|
end
|
2017-10-27 04:54:45 -05:00
|
|
|
end
|
|
|
|
end
|