-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add lograge to improve logging (#5423)
- Add lograge gem to improve rails logging using `LOGRAGE_ENABLED` env variable - When enabled Single line log for requests in JSON formatting - Switch sidekiq also to use JSON formatting Fixes: chatwoot/product#437 --------- Co-authored-by: Sojan Jose <sojan@pepalo.com>
- Loading branch information
1 parent
a521762
commit 71c5a1e
Showing
6 changed files
with
56 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,5 +76,4 @@ | |
Bullet.bullet_logger = true | ||
Bullet.rails_logger = true | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
if ActiveModel::Type::Boolean.new.cast(ENV.fetch('LOGRAGE_ENABLED', false)).present? | ||
require 'lograge' | ||
|
||
Rails.application.configure do | ||
config.lograge.enabled = true | ||
config.lograge.formatter = Lograge::Formatters::Json.new | ||
|
||
config.lograge.custom_payload do |controller| | ||
{ | ||
host: controller.request.host, | ||
remote_ip: controller.request.remote_ip, | ||
user_id: controller.current_user.try(:id) | ||
} | ||
end | ||
|
||
config.lograge.custom_options = lambda do |event| | ||
param_exceptions = %w[controller action format id] | ||
{ | ||
params: event.payload[:params]&.except(*param_exceptions) | ||
} | ||
end | ||
|
||
config.lograge.ignore_custom = lambda do |event| | ||
# ignore update_presence events in log | ||
return true if event.payload[:channel_class] == 'RoomChannel' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters