feat: configure lograge
This commit is contained in:
parent
1ba2199712
commit
3a04a8af36
3 changed files with 14 additions and 20 deletions
2
Gemfile
2
Gemfile
|
@ -186,4 +186,4 @@ group :development, :test do
|
|||
gem 'spring-watcher-listen'
|
||||
end
|
||||
|
||||
gem "lograge", "~> 0.12.0"
|
||||
gem 'lograge', '~> 0.12.0'
|
||||
|
|
|
@ -27,14 +27,13 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
def append_info_to_payload(payload)
|
||||
super
|
||||
case
|
||||
when payload[:status] == 200
|
||||
payload[:level] = "INFO"
|
||||
when payload[:status] == 302
|
||||
payload[:level] = "WARN"
|
||||
payload[:level] = case payload[:status]
|
||||
when 200
|
||||
'INFO'
|
||||
when 302
|
||||
'WARN'
|
||||
else
|
||||
payload[:level] = "ERROR"
|
||||
'ERROR'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
Rails.application.configure do
|
||||
|
||||
config.lograge.enabled = true
|
||||
config.lograge.keep_original_rails_log = true
|
||||
config.lograge.formatter = Lograge::Formatters::Json.new
|
||||
|
@ -13,16 +12,12 @@ Rails.application.configure do
|
|||
|
||||
config.lograge.custom_options = lambda do |event|
|
||||
{
|
||||
:level => event.payload[:level]
|
||||
level: event.payload[:level]
|
||||
}
|
||||
end
|
||||
|
||||
config.lograge.ignore_custom = lambda do |event|
|
||||
# ignore update_presence events in log
|
||||
if event.payload[:channel_class] == "RoomChannel"
|
||||
return true
|
||||
return true if event.payload[:channel_class] == 'RoomChannel'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue