Skip to content

Commit

Permalink
Rename optional data in Loggable concern (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
dickdavis authored Aug 11, 2024
1 parent 5ca73b1 commit 34d270f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions app/models/concerns/event_logger_rails/loggable_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions lib/event_logger_rails/extensions/loggable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/event_logger_rails/extensions/loggable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_three

private

def optional_data
def optional_event_logger_data
{
foo: 'bar'
}
Expand Down

0 comments on commit 34d270f

Please sign in to comment.