2018-08-14 22:39:34 +02:00
|
|
|
require_relative './active_job_log_subscriber'
|
|
|
|
|
2018-08-12 10:31:28 +02:00
|
|
|
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',
|
2018-08-14 22:39:34 +02:00
|
|
|
tags: ['request', event.payload[:exception] ? 'exception' : nil].compact,
|
2018-08-12 10:31:28 +02:00
|
|
|
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],
|
2018-08-14 22:39:34 +02:00
|
|
|
platform: event.payload[:platform]
|
2018-08-12 10:31:28 +02:00
|
|
|
}.compact
|
|
|
|
end
|
|
|
|
|
|
|
|
config.lograge.custom_payload do |controller|
|
|
|
|
{
|
2018-08-13 16:40:16 +02:00
|
|
|
xhr: !!controller&.request&.xhr?
|
2018-08-12 10:31:28 +02:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
config.lograge.keep_original_rails_log = true
|
|
|
|
config.lograge.logger = ActiveSupport::Logger.new Rails.root.join('log', "logstash_#{Rails.env}.log")
|
2018-08-14 22:39:34 +02:00
|
|
|
|
|
|
|
if config.lograge.enabled
|
|
|
|
ActiveJobLogSubscriber.attach_to :active_job
|
|
|
|
end
|
2018-08-12 10:31:28 +02:00
|
|
|
end
|