Module: TisoftLogging
- Defined in:
- lib/tisoft_logging.rb,
lib/tisoft_logging/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"1.0.2"
Class Method Summary collapse
Class Method Details
.setup(config:, user_method: :current_user, host: '127.0.0.1', fluentd_enable: true) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/tisoft_logging.rb', line 8 def self.setup(config:, user_method: :current_user, host: '127.0.0.1', fluentd_enable: true) config.log_level = :info if fluentd_enable config.logger = ActFluentLoggerRails::Logger. new(settings: { host: host, port: 24224, tag: "rails.#{Rails.application.class.parent_name.to_s.downcase}", messages_type: 'string', severity_key: 'INFO' }) end config.lograge.enabled = true config.lograge.formatter = Lograge::Formatters::Json.new config.lograge.custom_payload do |controller| { ip: controller.request.remote_ip, user_agent: controller.request.user_agent, user_id: controller.send(user_method)&.id } end config.lograge. = lambda do |event| exceptions = %w(controller action format id) { params: event.payload[:params].except(*exceptions) } end config end |