From 34d270f6344b7316919fb080a4027b0d9642e506 Mon Sep 17 00:00:00 2001 From: Dick Davis Date: Sat, 10 Aug 2024 23:54:00 -0500 Subject: [PATCH] Rename optional data in Loggable concern (#48) --- .../concerns/event_logger_rails/loggable_controller.rb | 4 ++-- app/models/concerns/event_logger_rails/loggable_model.rb | 4 ++-- lib/event_logger_rails/extensions/loggable.rb | 4 ++-- spec/lib/event_logger_rails/extensions/loggable_spec.rb | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/concerns/event_logger_rails/loggable_controller.rb b/app/controllers/concerns/event_logger_rails/loggable_controller.rb index c7168d2..6f08be4 100644 --- a/app/controllers/concerns/event_logger_rails/loggable_controller.rb +++ b/app/controllers/concerns/event_logger_rails/loggable_controller.rb @@ -10,13 +10,13 @@ module LoggableController # Includes the controller name and action in the log output. # # @return [Hash] The data to include in log output. - def optional_data + def optional_event_logger_data { action: action_name, controller: controller_name.camelcase } end - private :optional_data + private :optional_event_logger_data end end diff --git a/app/models/concerns/event_logger_rails/loggable_model.rb b/app/models/concerns/event_logger_rails/loggable_model.rb index 782fdf9..aeff74a 100644 --- a/app/models/concerns/event_logger_rails/loggable_model.rb +++ b/app/models/concerns/event_logger_rails/loggable_model.rb @@ -10,13 +10,13 @@ module LoggableModel # Includes the model name and instance ID in the log output. # # @return [Hash] The data to include in log output. - def optional_data + def optional_event_logger_data { model: self.class.name, instance_id: id } end - private :optional_data + private :optional_event_logger_data end end diff --git a/lib/event_logger_rails/extensions/loggable.rb b/lib/event_logger_rails/extensions/loggable.rb index ab0e428..8c727d5 100644 --- a/lib/event_logger_rails/extensions/loggable.rb +++ b/lib/event_logger_rails/extensions/loggable.rb @@ -13,7 +13,7 @@ def log_event(event, **kwargs) EventLoggerRails.log( event, level: kwargs[:level] || nil, - data: (kwargs[:data] || {}).merge(optional_data) + data: (kwargs[:data] || {}).merge(optional_event_logger_data) ) end @@ -23,7 +23,7 @@ def log_event(event, **kwargs) # # @return [Hash] The data to include in log output. # @note This method can be overridden by classes that implement Loggable. - def optional_data + def optional_event_logger_data {} end end diff --git a/spec/lib/event_logger_rails/extensions/loggable_spec.rb b/spec/lib/event_logger_rails/extensions/loggable_spec.rb index 12ef33b..858f8b7 100644 --- a/spec/lib/event_logger_rails/extensions/loggable_spec.rb +++ b/spec/lib/event_logger_rails/extensions/loggable_spec.rb @@ -21,7 +21,7 @@ def test_three private - def optional_data + def optional_event_logger_data { foo: 'bar' }