make scoped logger work with logger objects with non-int level#486
Open
HoneyryderChuck wants to merge 1 commit into
Open
make scoped logger work with logger objects with non-int level#486HoneyryderChuck wants to merge 1 commit into
HoneyryderChuck wants to merge 1 commit into
Conversation
|
|
e7f1c74 to
d587d28
Compare
`Logger#level` returns an integer, however many other logger libraries in ruby land don't do that, most notably semantic_logger, which is nowadays recommended by rails for structured logging; `SemanticLogger::Logger` objects return `#level` as a symbol (ex: `:info`). This patch fixes it by allowing a escape hatch for non-integer levels; just call `#upcase` (which both strings and symbols support) and pass it to `Logger::Severity.const_get`.
d587d28 to
df7793c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What was changed
This patch fixes scoped loggers by allowing a escape hatch for logger objects with non-integer levels; just call
#upcase(which both strings and symbols support) and pass it toLogger::Severity.const_get.Why?
Logger#levelreturns an integer, however many other logger libraries in ruby land don't do that, most notably semantic_logger, which is nowadays recommended by rails for structured logging;SemanticLogger::Loggerobjects return#levelas a symbol (ex::info).Checklist
Closes [Bug] Does not support semantic_logger #472
How was this tested: