mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 13:09:18 +08:00
EXPERIMENTAL: Allow Logstash formatter to be enable for lograge logs.
This commit is contained in:
parent
076df104dc
commit
d888d3c54c
1
Gemfile
1
Gemfile
|
@ -173,6 +173,7 @@ gem 'memory_profiler', require: false, platform: :mri
|
||||||
gem 'cppjieba_rb', require: false
|
gem 'cppjieba_rb', require: false
|
||||||
|
|
||||||
gem 'lograge', require: false
|
gem 'lograge', require: false
|
||||||
|
gem 'logstash-event', require: false
|
||||||
gem 'logster'
|
gem 'logster'
|
||||||
|
|
||||||
gem 'sassc', require: false
|
gem 'sassc', require: false
|
||||||
|
|
|
@ -155,6 +155,7 @@ GEM
|
||||||
activesupport (>= 4, < 5.2)
|
activesupport (>= 4, < 5.2)
|
||||||
railties (>= 4, < 5.2)
|
railties (>= 4, < 5.2)
|
||||||
request_store (~> 1.0)
|
request_store (~> 1.0)
|
||||||
|
logstash-event (1.2.02)
|
||||||
logster (1.2.8)
|
logster (1.2.8)
|
||||||
loofah (2.1.1)
|
loofah (2.1.1)
|
||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
|
@ -438,6 +439,7 @@ DEPENDENCIES
|
||||||
http_accept_language (~> 2.0.5)
|
http_accept_language (~> 2.0.5)
|
||||||
listen
|
listen
|
||||||
lograge
|
lograge
|
||||||
|
logstash-event
|
||||||
logster
|
logster
|
||||||
lru_redux
|
lru_redux
|
||||||
mail
|
mail
|
||||||
|
|
|
@ -7,11 +7,18 @@ if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV["
|
||||||
config.lograge.custom_options = lambda do |event|
|
config.lograge.custom_options = lambda do |event|
|
||||||
exceptions = %w(controller action format id)
|
exceptions = %w(controller action format id)
|
||||||
|
|
||||||
|
params = event.payload[:params].except(*exceptions)
|
||||||
|
params[:files].map!(&:headers) if params[:files]
|
||||||
|
|
||||||
output = {
|
output = {
|
||||||
params: event.payload[:params].except(*exceptions),
|
params: params,
|
||||||
database: RailsMultisite::ConnectionManagement.current_db,
|
database: RailsMultisite::ConnectionManagement.current_db,
|
||||||
time: event.time,
|
time: event.time,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if ENV["LOGSTASH_FORMATTER"]
|
||||||
|
config.lograge.formatter = Lograge::Formatters::Logstash.new
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user