feat: configure lograge

This commit is contained in:
Vishnu Narayanan 2022-09-14 21:18:26 +05:30
parent 1ba2199712
commit 3a04a8af36
No known key found for this signature in database
GPG key ID: 000B7FD5001541AC
3 changed files with 14 additions and 20 deletions

View file

@ -186,4 +186,4 @@ group :development, :test do
gem 'spring-watcher-listen'
end
gem "lograge", "~> 0.12.0"
gem 'lograge', '~> 0.12.0'

View file

@ -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

View file

@ -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
# ignore update_presence events in log
return true if event.payload[:channel_class] == 'RoomChannel'
end
end
end