Skip to content

Commit

Permalink
change method name to untagged
Browse files Browse the repository at this point in the history
  • Loading branch information
bdurand committed Aug 27, 2020
1 parent cd8a20d commit 1f8f459
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
24 changes: 12 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
## 1.2.8

* Add `Logger#untag` to remove previously set logging tags from a block.
* Add `Logger#untagged` to remove previously set logging tags from a block.

## 1.2.7

* Allow passing frozen hashes to `Logger.tag`. Tags passed to this method are now duplicated so the logger maintains it's own copy of the hash.
* Allow passing frozen hashes to `Logger#tag`. Tags passed to this method are now duplicated so the logger maintains it's own copy of the hash.

## 1.2.6

* Fix Logger#tag so it only ads to the current block's logger tags instead of the global tags if called inside a `Logger#tag` block.
* Fix `Logger#tag` so it only ads to the current block's logger tags instead of the global tags if called inside a `Logger#tag` block.
* Add Logger#remove_tag

## 1.2.5
Expand All @@ -18,7 +18,7 @@

## 1.2.4

* Enhance ActiveSupport::TaggedLogging support so code that Lumberjack loggers can be wrapped with a tagged logger.
* Enhance `ActiveSupport::TaggedLogging` support so code that Lumberjack loggers can be wrapped with a tagged logger.

## 1.2.3

Expand All @@ -34,7 +34,7 @@

## 1.2.0

* Enable compatibility with ActiveSupport::TaggedLogger by calling `tagged_logger!` on a logger.
* Enable compatibility with `ActiveSupport::TaggedLogger` by calling `tagged_logger!` on a logger.
* Add `tag_formatter` to logger to specify formatting of tags for output.
* Allow adding and removing classes by name to formatters.
* Allow adding and removing multiple classes in a single call to a formatter.
Expand All @@ -53,16 +53,16 @@

## 1.1.0

* Change Lumberjack::Logger to inherit from ::Logger
* Change `Lumberjack::Logger` to inherit from ::Logger
* Add support for tags on log messages
* Add global tag context for all loggers
* Add per logger tags and tag contexts
* Reimplement unit of work id as a tag on log entries
* Add support for setting datetime format on log devices
* Performance optimizations
* Add Multi device to output to multiple devices
* Add DateTimeFormatter, IdFormatter, ObjectFormatter, and StructuredFormatter
* Add rack Context middleware for setting thread global context
* Add `DateTimeFormatter`, `IdFormatter`, `ObjectFormatter`, and `StructuredFormatter`
* Add rack `Context` middleware for setting thread global context
* End support for ruby versions < 2.3
* Add support for modules in formatters

Expand All @@ -74,7 +74,7 @@

## 1.0.12

* Add support for ActionDispatch request id for better Rails compatibility.
* Add support for `ActionDispatch` request id for better Rails compatibility.

## 1.0.11

Expand All @@ -88,19 +88,19 @@

## 1.0.9

* Add method so Formatter is compatible with ActiveSupport logging extensions.
* Add method so Formatter is compatible with `ActiveSupport` logging extensions.

## 1.0.8

* Fix another internal variable name conflict with ActiveSupport logging extensions.
* Fix another internal variable name conflict with `ActiveSupport` logging extensions.

## 1.0.7

* Fix broken formatter attribute method.

## 1.0.6

* Fix internal variable name conflict with ActiveSupport logging extensions.
* Fix internal variable name conflict with `ActiveSupport` logging extensions.

## 1.0.5

Expand Down
8 changes: 4 additions & 4 deletions lib/lumberjack/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -392,18 +392,18 @@ def tags
end

# Remove all tags on the current logger and logging context within a block.
# You can still set new block scoped tags within the untagged block and provide
# You can still set new block scoped tags within theuntagged block and provide
# tags on individual log methods.
def untag(&block)
def untagged(&block)
Lumberjack.use_context(nil) do
scope_tags = thread_local_value(:lumberjack_logger_tags)
untagged = thread_local_value(:lumberjack_logger_untagged)
untagged = thread_local_value(:lumberjack_logger_untagged)
begin
set_thread_local_value(:lumberjack_logger_untagged, true)
set_thread_local_value(:lumberjack_logger_tags, nil)
tag({}, &block)
ensure
set_thread_local_value(:lumberjack_logger_untagged, untagged)
set_thread_local_value(:lumberjack_logger_untagged,untagged)
set_thread_local_value(:lumberjack_logger_tags, scope_tags)
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,12 @@
end
end

describe "untag" do
describe "untagged" do
it "should remove tags from the Lumberjack::Context" do
Lumberjack.context do
Lumberjack.tag(foo: "bar")
expect(logger.tags).to eq({"foo" => "bar"})
logger.untag do
logger.untagged do
expect(logger.tags).to eq({})
end
expect(logger.tags).to eq({"foo" => "bar"})
Expand All @@ -562,7 +562,7 @@
logger.tag(foo: "bar")
begin
expect(logger.tags).to eq({"foo" => "bar"})
logger.untag do
logger.untagged do
expect(logger.tags).to eq({})
end
expect(logger.tags).to eq({"foo" => "bar"})
Expand All @@ -574,7 +574,7 @@
it "should remove scoped tags from teh logger" do
logger.tag(foo: "bar") do
expect(logger.tags).to eq({"foo" => "bar"})
logger.untag do
logger.untagged do
expect(logger.tags).to eq({})
end
expect(logger.tags).to eq({"foo" => "bar"})
Expand All @@ -584,10 +584,10 @@
it "should allow adding tags inside the block" do
logger.tag(foo: "bar") do
expect(logger.tags).to eq({"foo" => "bar"})
logger.untag do
logger.untagged do
logger.tag(stuff: "other") do
expect(logger.tags).to eq({"stuff" => "other"})
logger.untag do
logger.untagged do
expect(logger.tags).to eq({})
logger.tag(thing: 1)
expect(logger.tags).to eq({"thing" => 1})
Expand Down

0 comments on commit 1f8f459

Please sign in to comment.