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' gem 'spring-watcher-listen'
end 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) def append_info_to_payload(payload)
super super
case payload[:level] = case payload[:status]
when payload[:status] == 200 when 200
payload[:level] = "INFO" 'INFO'
when payload[:status] == 302 when 302
payload[:level] = "WARN" 'WARN'
else else
payload[:level] = "ERROR" 'ERROR'
end end
end end
end end

View file

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