Skip to content

Commit

Permalink
Regression test ref rails#45854
Browse files Browse the repository at this point in the history
  • Loading branch information
Edouard-chin committed Jun 29, 2023
1 parent ca6ecfe commit 0dc3c23
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/broadcast_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def broadcast_to(*loggers)
end

# Remove a logger from the broadcast. When a logger is removed, messages sent to
# the broadcast will no longer be written to the sink.
# the broadcast will no longer be written to its sink.
#
# @param logger [Logger]
def stop_broadcasting_to(logger)
Expand Down
16 changes: 16 additions & 0 deletions activesupport/test/tagged_logging_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,22 @@ class TaggedLoggingWithoutBlockTest < ActiveSupport::TestCase
assert_equal "[OMG] Broadcasting...\n", broadcast_output.string
end

test "#tagged without a block doesn't leak to other loggers" do
sink1 = StringIO.new
logger1= ActiveSupport::Logger.new(sink1).extend(ActiveSupport::TaggedLogging)
sink2 = StringIO.new
logger2= ActiveSupport::Logger.new(sink2).extend(ActiveSupport::TaggedLogging)
broadcast_logger = ActiveSupport::BroadcastLogger.new.extend(ActiveSupport::TaggedLogging)
broadcast_logger.broadcast_to(logger1, logger2)

broadcast_logger.tagged('tag')
broadcast_logger.info('text')

assert_equal("text\n", sink1.string)
assert_equal("text\n", sink2.string)
end


test "accepts non-String objects" do
@logger.tagged("tag") { @logger.info [1, 2, 3] }
assert_equal "[tag] [1, 2, 3]\n", @output.string
Expand Down

0 comments on commit 0dc3c23

Please sign in to comment.