Class: ActiveSupport::Logger
- Inherits:
-
Logger
- Object
- Logger
- ActiveSupport::Logger
- Includes:
- LoggerSilence
- Defined in:
- lib/activesupport/logger.rb
Defined Under Namespace
Classes: SimpleFormatter
Class Method Summary collapse
-
.logger_outputs_to?(logger, *sources) ⇒ Boolean
Returns true if the logger destination matches one of the sources.
Instance Method Summary collapse
-
#initialize(*args, **kwargs) ⇒ Logger
constructor
A new instance of Logger.
Methods included from LoggerSilence
Constructor Details
#initialize(*args, **kwargs) ⇒ Logger
Returns a new instance of Logger.
40 41 42 43 |
# File 'lib/activesupport/logger.rb', line 40 def initialize(*args, **kwargs) super @formatter ||= SimpleFormatter.new end |
Class Method Details
.logger_outputs_to?(logger, *sources) ⇒ Boolean
Returns true if the logger destination matches one of the sources
logger = Logger.new(STDOUT)
ActiveSupport::Logger.logger_outputs_to?(logger, STDOUT)
# => true
logger = Logger.new('/var/log/rails.log')
ActiveSupport::Logger.logger_outputs_to?(logger, '/var/log/rails.log')
# => true
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/activesupport/logger.rb', line 23 def self.logger_outputs_to?(logger, *sources) # NOTE: This is the only line altered for this gem. # We can't risk this gem loading the vanilla BroadcastLogger via autoload # But we also can't make this gem depend on activesupport/broadcast_logger, # as that would be a circular dependency. loggers = if defined?(BroadcastLogger) && logger.is_a?(BroadcastLogger) logger.broadcasts else [logger] end logdevs = loggers.map { |logger| logger.instance_variable_get(:@logdev) } logger_sources = logdevs.filter_map { |logdev| logdev.try(:filename) || logdev.try(:dev) } normalize_sources(sources).intersect?(normalize_sources(logger_sources)) end |