Fix the LoggerSilence to work as described: #34055
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following the Rails guide which state that a logger needs to include
the
ActiveSupport::LoggerSilence
as well asActiveSupport::LoggerThreadSafe
modules isn't enough and won'twork.
Here is a test cases with 3 tests that all fails
https://gist.github.com/Edouard-chin/4a72930c2b1eafbbd72a80c66f102010
The problems are the following:
after_initialize
in order to setupsome instance variables.
add
method checks for the instance variable@logger
. We need tooverride the
add
(like we used to in the ActiveSupport::Loggerclass).
debug?
info?
etc... doesn't work as the bare rubymethods 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 haveto call it directly. I modified to instance the variables when the
module get included.
cc/ @rafaelfranca