Replace logstasher with lograge
This commit is contained in:
parent
8f165c2ced
commit
a6a4790a35
6 changed files with 74 additions and 25 deletions
30
config/initializers/lograge.rb
Normal file
30
config/initializers/lograge.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
Rails.application.configure do
|
||||
config.lograge.formatter = Lograge::Formatters::Logstash.new
|
||||
config.lograge.base_controller_class = ['ActionController::Base', 'Manager::ApplicationController']
|
||||
|
||||
# This will allow to override custom options from environement file
|
||||
# injected by ansible.
|
||||
if !config.lograge.custom_options
|
||||
config.lograge.custom_options = lambda do |event|
|
||||
{
|
||||
type: 'tps',
|
||||
user_id: event.payload[:user_id],
|
||||
user_email: event.payload[:user_email],
|
||||
user_roles: event.payload[:user_roles],
|
||||
user_agent: event.payload[:user_agent],
|
||||
browser: event.payload[:browser],
|
||||
browser_version: event.payload[:browser_version],
|
||||
platform: event.payload[:platform]
|
||||
}.compact
|
||||
end
|
||||
|
||||
config.lograge.custom_payload do |controller|
|
||||
{
|
||||
xhr: !!controller.request.xhr?
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
config.lograge.keep_original_rails_log = true
|
||||
config.lograge.logger = ActiveSupport::Logger.new Rails.root.join('log', "logstash_#{Rails.env}.log")
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue