mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 06:15:48 +08:00
89d9ffa884
See https://github.com/dwbutler/logstash-logger#uri-configuration for a list of available methods.
36 lines
941 B
Ruby
36 lines
941 B
Ruby
if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV["ENABLE_LOGRAGE"]
|
|
require 'lograge'
|
|
|
|
if Rails.configuration.multisite
|
|
Rails.logger.formatter = ActiveSupport::Logger::SimpleFormatter.new
|
|
end
|
|
|
|
Rails.application.configure do
|
|
config.lograge.enabled = true
|
|
|
|
config.lograge.custom_options = lambda do |event|
|
|
exceptions = %w(controller action format id)
|
|
|
|
params = event.payload[:params].except(*exceptions)
|
|
params[:files].map!(&:headers) if params[:files]
|
|
|
|
output = {
|
|
params: params.to_query,
|
|
database: RailsMultisite::ConnectionManagement.current_db,
|
|
}
|
|
|
|
output
|
|
end
|
|
|
|
if ENV["LOGSTASH_URI"]
|
|
config.lograge.formatter = Lograge::Formatters::Logstash.new
|
|
|
|
require 'discourse_logstash_logger'
|
|
|
|
config.lograge.logger = DiscourseLogstashLogger.logger(
|
|
uri: ENV['LOGSTASH_URI'], type: :rails
|
|
)
|
|
end
|
|
end
|
|
end
|