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"
else
payload[:level] = "ERROR"
end
payload[:level] = case payload[:status]
when 200
'INFO'
when 302
'WARN'
else
'ERROR'
end
end
end

View file

@ -1,8 +1,7 @@
Rails.application.configure do
config.lograge.enabled = true
config.lograge.keep_original_rails_log = true
config.lograge.formatter = Lograge::Formatters::Json.new
config.lograge.formatter = Lograge::Formatters::Json.new
config.colorize_logging = false
config.lograge.custom_payload do |controller|
{
@ -12,17 +11,13 @@ Rails.application.configure do
end
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
end
# ignore update_presence events in log
return true if event.payload[:channel_class] == 'RoomChannel'
end
end