Class: ActiveSupport::Logger
- Inherits:
-
Object
- Object
- ActiveSupport::Logger
- Defined in:
- lib/rails_semantic_logger/extensions/active_support/logger.rb
Overview
More hacks to try and stop Rails from being its own worst enemy.
Class Method Summary collapse
-
._semantic_logger_original_new ⇒ Object
Keep a handle on the genuine constructor so that callers which supply a real log destination still get a real logger (see #new below).
-
.logger_outputs_to?(*_args) ⇒ Boolean
Prevent Rails from trying to merge/broadcast loggers (e.g. ActiveRecord's
consolehook andrails server's log_to_stdout). -
.new(*args, **kwargs) ⇒ Object
Historically every
ActiveSupport::Logger.new(...)call was redirected to SemanticLogger, silently discarding the requested destination.
Class Method Details
._semantic_logger_original_new ⇒ Object
Keep a handle on the genuine constructor so that callers which supply a real log destination still get a real logger (see #new below).
9 |
# File 'lib/rails_semantic_logger/extensions/active_support/logger.rb', line 9 alias _semantic_logger_original_new new |
.logger_outputs_to?(*_args) ⇒ Boolean
Prevent Rails from trying to merge/broadcast loggers (e.g. ActiveRecord's
console hook and rails server's log_to_stdout). SemanticLogger already
multiplexes through its own appenders, and SemanticLogger::Logger does not
implement #broadcast_to, so the merge path would otherwise raise.
17 18 19 |
# File 'lib/rails_semantic_logger/extensions/active_support/logger.rb', line 17 def logger_outputs_to?(*_args) true end |
.new(*args, **kwargs) ⇒ Object
Historically every ActiveSupport::Logger.new(...) call was redirected to
SemanticLogger, silently discarding the requested destination. That broke
third-party callers such as Webpacker's ActiveSupport::Logger.new(STDOUT),
whose output never reached STDOUT (issue #141). Only redirect to
SemanticLogger when no destination is supplied; otherwise honor the caller
and build a genuine logger pointed at the requested destination.
27 28 29 30 31 32 33 |
# File 'lib/rails_semantic_logger/extensions/active_support/logger.rb', line 27 def new(*args, **kwargs) if args.empty? && kwargs.empty? SemanticLogger[self] else _semantic_logger_original_new(*args, **kwargs) end end |