lib/semantic_logger/base.rb in semantic_logger-2.9.1 vs lib/semantic_logger/base.rb in semantic_logger-2.9.2
- old
+ new
@@ -111,14 +111,14 @@
# Add the supplied tags to the list of tags to log for this thread whilst
# the supplied block is active
# Returns nil if no tags are currently set
# To support: ActiveSupport::TaggedLogging V3 and above
def tagged(*tags)
- push_tags(*tags)
- yield
+ new_tags = push_tags(*tags)
+ yield self
ensure
- pop_tags(tags.size)
+ pop_tags(new_tags.size)
end
# Previous method for supplying tags
alias_method :with_tags, :tagged
@@ -129,14 +129,16 @@
t = Thread.current[:semantic_logger_tags]
t.nil? ? [] : t.clone
end
# Add tags to the current scope
+ # Returns the list of tags pushed after flattening them out and removing blanks
def push_tags *tags
# Need to flatten and reject empties to support calls from Rails 4
new_tags = tags.flatten.collect(&:to_s).reject(&:empty?)
t = Thread.current[:semantic_logger_tags]
Thread.current[:semantic_logger_tags] = t.nil? ? new_tags : t.concat(new_tags)
+ new_tags
end
# Remove specified number of tags from the current tag list
def pop_tags(quantity=1)
t = Thread.current[:semantic_logger_tags]