Module: LogrageCustomLogger
- Included in:
- Admin::BaseController, Api::Admin::BaseController, Api::Aoa::V1::BaseController, Api::Dashboard::BaseController, Api::Kiosque::V1::BaseController, Api::Partner::V1::BaseController, Api::V5::BaseController, Api::V6::BaseController, Api::Vendor::V1::BaseController, ApplicationController, ApplicationV2Controller, Blgr::ApplicationController, Dashboard::V2::MainController, RestaurantPartners::ApplicationController, V2Users::BaseController
- Defined in:
- app/controllers/concerns/lograge_custom_logger.rb
Instance Method Summary collapse
-
#append_info_to_payload(payload) ⇒ Object
This module provides a custom logger that appends additional information to the log payload.
Instance Method Details
#append_info_to_payload(payload) ⇒ Object
This module provides a custom logger that appends additional information to the log payload. The `append_info_to_payload` method is called by Rails to add information to the log payload. see lograge gem documentation in config/environment/production.rb
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/concerns/lograge_custom_logger.rb', line 5 def append_info_to_payload(payload) super current_user_method = case when respond_to?(:current_user) current_user when respond_to?(:current_admin) current_admin when respond_to?(:current_owner) current_owner when respond_to?(:current_group) current_group when respond_to?(:current_staff) current_staff when respond_to?(:current_blogger) current_blogger when respond_to?(:current_dashboard_v2_restaurant_group) current_dashboard_v2_restaurant_group when respond_to?(:current_dashboard_v2_owner) current_dashboard_v2_owner else nil end payload[:current_user_type] = current_user_method&.class&.name payload[:current_user_id] = current_user_method&.id payload[:ip_address] = request.remote_ip.presence || request.ip payload[:user_agent] = request.user_agent payload[:accept_language] = request.env["HTTP_ACCEPT_LANGUAGE"] payload[:request_id] = request.uuid payload[:referer] = request.referer end |