diff --git a/lib/rackstash/buffer.rb b/lib/rackstash/buffer.rb index 7e464c3..a5bff79 100644 --- a/lib/rackstash/buffer.rb +++ b/lib/rackstash/buffer.rb @@ -263,15 +263,11 @@ module Rackstash # @param new_tags [Array<#to_s, #call>] Strings to add as tags to the buffer. # You can either give (arrays of) strings here or procs which return # a string or an array of strings when called. - # @param scope [nil, Object] If anything other then `nil` is given here, we - # will evaluate any procs given in the tags in the context of this - # object. If `nil` is given (the default) the procs are directly called - # in the context where they were created. # @return [Fields::Tags] the resolved tags which are set on the buffer. # All strings are frozen. - def tag(*new_tags, scope: nil) + def tag(*new_tags) timestamp - tags.merge!(new_tags, scope: scope) + tags.merge!(new_tags) end # @return [Fields::Tags] a tags list containing the defined tags for the diff --git a/lib/rackstash/logger.rb b/lib/rackstash/logger.rb index d80df51..35dca97 100644 --- a/lib/rackstash/logger.rb +++ b/lib/rackstash/logger.rb @@ -187,8 +187,8 @@ module Rackstash end # (see Buffer#tag) - def tag(*new_tags, scope: nil) - buffer.tag(*new_tags, scope: scope) + def tag(*new_tags) + buffer.tag(*new_tags) end # (see Buffer#tags) diff --git a/lib/rackstash/rack/middleware.rb b/lib/rackstash/rack/middleware.rb index 1b6d8e7..149aa02 100644 --- a/lib/rackstash/rack/middleware.rb +++ b/lib/rackstash/rack/middleware.rb @@ -246,7 +246,7 @@ module Rackstash scope: request, force: false ) unless @request_fields.nil? - @logger.tag(@request_tags, scope: request) unless @request_tags.nil? + @logger.tags.merge!(@request_tags, scope: request) unless @request_tags.nil? end # @param env [Hash] the Rack environment @@ -285,7 +285,7 @@ module Rackstash force: false ) unless @response_fields.nil? - @logger.tag(@response_tags, scope: headers) unless @response_tags.nil? + @logger.tags.merge!(@response_tags, scope: headers) unless @response_tags.nil? end # @param env [Hash] The Rack environment diff --git a/spec/rackstash/buffer_spec.rb b/spec/rackstash/buffer_spec.rb index 0678459..5cfbada 100644 --- a/spec/rackstash/buffer_spec.rb +++ b/spec/rackstash/buffer_spec.rb @@ -486,12 +486,12 @@ RSpec.describe Rackstash::Buffer do } it 'expands single-value proc objects' do - buffer.tag(-> { self }, scope: object) + buffer.tag(-> { object }) expect(buffer.tags).to contain_exactly('Hello') end it 'expands multi-value proc objects' do - buffer.tag(-> { [[self, 'foobar'], 123] }, scope: object) + buffer.tag(-> { [[object, 'foobar'], 123] }) expect(buffer.tags).to contain_exactly('Hello', 'foobar', '123') end end