Skip to content

Commit

Permalink
BroadcastLogger#formatter is its first logger's formatter
Browse files Browse the repository at this point in the history
There is no practical value in BroadcastLogger storing its own copy of
the formatter. In all observed cases, it is assigned to the value of the
initial Logger, and it is never used by BroadcastLogger.
  • Loading branch information
armstrjare committed Sep 29, 2024
1 parent ca25c72 commit 5ae6a52
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
9 changes: 1 addition & 8 deletions activesupport/lib/active_support/broadcast_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class BroadcastLogger

# Returns all the logger that are part of this broadcast.
attr_reader :broadcasts
attr_reader :formatter
attr_accessor :progname

def initialize(*loggers)
Expand Down Expand Up @@ -110,6 +109,7 @@ def stop_broadcasting_to(logger)
<< log add debug info warn error fatal unknown
debug! info! warn! error! fatal!
level= sev_threshold= local_level local_level= close
formatter formatter=
]
LOGGER_METHODS.each do |method|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
Expand All @@ -124,12 +124,6 @@ def level
@broadcasts.map(&:level).min
end

def formatter=(formatter)
dispatch(:formatter=, formatter)

@formatter = formatter
end

# +True+ if the log level allows entries with severity Logger::DEBUG to be written
# to at least one broadcast. +False+ otherwise.
def debug?
Expand Down Expand Up @@ -163,7 +157,6 @@ def fatal?
def initialize_copy(other)
@broadcasts = []
@progname = other.progname.dup
@formatter = other.formatter.dup

broadcast_to(*other.broadcasts.map(&:dup))
end
Expand Down
4 changes: 1 addition & 3 deletions railties/lib/rails/application/bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ module Bootstrap
end
else
Rails.logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase)
broadcast_logger = ActiveSupport::BroadcastLogger.new(Rails.logger)
broadcast_logger.formatter = Rails.logger.formatter
Rails.logger = broadcast_logger
Rails.logger = ActiveSupport::BroadcastLogger.new(Rails.logger)
end
end

Expand Down

0 comments on commit 5ae6a52

Please sign in to comment.