diff options
author | Edouard CHIN <edouard.chin@shopify.com> | 2018-10-02 17:02:27 -0400 |
---|---|---|
committer | Edouard CHIN <edouard.chin@shopify.com> | 2018-10-02 17:17:23 -0400 |
commit | 05ad44eb89047ac13e31149fa6cbc1459c5545a9 (patch) | |
tree | 88a785a5de6ddeaf03e233b51d89fbdbf0cadc38 /activesupport/lib/active_support/logger.rb | |
parent | 92fece96da28d9f641bc8a8db1187b91c94cabfb (diff) | |
download | rails-05ad44eb89047ac13e31149fa6cbc1459c5545a9.tar.gz rails-05ad44eb89047ac13e31149fa6cbc1459c5545a9.tar.bz2 rails-05ad44eb89047ac13e31149fa6cbc1459c5545a9.zip |
Fix the LoggerSilence to work as described:
- Following the Rails guide which state that a logger needs to include
the `ActiveSupport::LoggerSilence` as well as
`ActiveSupport::LoggerThreadSafe` modules isn't enough and won't
work.
Here is a test cases with 3 tests that all fails
https://gist.github.com/Edouard-chin/4a72930c2b1eafbbd72a80c66f102010
The problems are the following:
1) The logger needs to call `after_initialize` in order to setup
some instance variables.
2) The silence doesn't actually work because the bare ruby Logger
`add` method checks for the instance variable `@logger`. We need to
override the `add` (like we used to in the ActiveSupport::Logger
class).
3) Calling `debug?` `info?` etc... doesn't work as the bare ruby
methods will check for the instance variable. Again we need to
override this methods (like we used to in the ActiveSupport::Logger
class)
The LoggerSilence won't work without LoggerThreadSafe, but the later
is not public API, the user shouldn't have to include it so I
modified to include it automatically.
Same for the `after_initialize` method. I find unuintitive to have
to call it directly. I modified to instance the variables when the
module get included.
Diffstat (limited to 'activesupport/lib/active_support/logger.rb')
-rw-r--r-- | activesupport/lib/active_support/logger.rb | 15 |
1 files changed, 0 insertions, 15 deletions
diff --git a/activesupport/lib/active_support/logger.rb b/activesupport/lib/active_support/logger.rb index 8152a182b4..b8555c887b 100644 --- a/activesupport/lib/active_support/logger.rb +++ b/activesupport/lib/active_support/logger.rb @@ -6,7 +6,6 @@ require "logger" module ActiveSupport class Logger < ::Logger - include ActiveSupport::LoggerThreadSafeLevel include LoggerSilence # Returns true if the logger destination matches one of the sources @@ -81,20 +80,6 @@ module ActiveSupport def initialize(*args) super @formatter = SimpleFormatter.new - after_initialize if respond_to? :after_initialize - end - - def add(severity, message = nil, progname = nil, &block) - return true if @logdev.nil? || (severity || UNKNOWN) < level - super - end - - Logger::Severity.constants.each do |severity| - class_eval(<<-EOT, __FILE__, __LINE__ + 1) - def #{severity.downcase}? # def debug? - Logger::#{severity} >= level # DEBUG >= level - end # end - EOT end # Simple formatter which only displays the message. |