Skip to content

Commit

Permalink
Rename default_attributes parameter
Browse files Browse the repository at this point in the history
Use `attributes` instead of `default_attributes`.
  • Loading branch information
unflxw committed Nov 12, 2024
1 parent 27e05af commit 6244731
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions lib/appsignal/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,23 @@ class Logger < ::Logger
FATAL => 7
}.freeze

attr_reader :level, :default_attributes
attr_reader :level

# Create a new logger instance
#
# @param group Name of the group for this logger.
# @param level Log level to filter with
# @param level Minimum log level to report. Log lines below this level will be ignored.
# @param format Format to use to parse log line attributes.
# @param attributes Default attributes for all log lines.
# @return [void]
def initialize(group, level: INFO, format: PLAINTEXT, default_attributes: {})
def initialize(group, level: INFO, format: PLAINTEXT, attributes: {})
raise TypeError, "group must be a string" unless group.is_a? String

@group = group
@level = level
@format = format
@mutex = Mutex.new
@default_attributes = default_attributes
@default_attributes = attributes
end

# We support the various methods in the Ruby
Expand Down Expand Up @@ -157,6 +159,8 @@ def silence(_severity = ERROR, &block)

private

attr_reader :default_attributes

def add_with_attributes(severity, message, group, attributes)
Thread.current[:appsignal_logger_attributes] = default_attributes.merge!(attributes)
add(severity, message, group)
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/appsignal/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@

describe "a logger with default attributes" do
it "adds the attributes when a message is logged" do
logger = Appsignal::Logger.new("group", :default_attributes => { :some_key => "some_value" })
logger = Appsignal::Logger.new("group", :attributes => { :some_key => "some_value" })

expect(Appsignal::Extension).to receive(:log).with("group", 6, 0, "Some message",
Appsignal::Utils::Data.generate({ :other_key => "other_value", :some_key => "some_value" }))
Expand Down

0 comments on commit 6244731

Please sign in to comment.