fix: enable lograge in superadmin path (#7026)

* fix: lograge superadmin path
* chore: add spec for superadmin devise session controller
* chore: address review comment
This commit is contained in:
Vishnu Narayanan
2023-05-08 13:43:55 +05:30
committed by GitHub
parent 3dedfee350
commit 51fb3b7e8e
3 changed files with 16 additions and 2 deletions

View File

@@ -4,12 +4,13 @@ if ActiveModel::Type::Boolean.new.cast(ENV.fetch('LOGRAGE_ENABLED', false)).pres
Rails.application.configure do
config.lograge.enabled = true
config.lograge.formatter = Lograge::Formatters::Json.new
config.lograge.custom_payload do |controller|
# Fixes https://github.com/chatwoot/chatwoot/issues/6922
user_id = controller.try(:current_user).try(:id) unless controller.is_a?(SuperAdmin::Devise::SessionsController)
{
host: controller.request.host,
remote_ip: controller.request.remote_ip,
user_id: controller.current_user.try(:id)
user_id: user_id
}
end