-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
log: improvements to sparse macros, fancy logger. #13223
Conversation
Inspired by a log statement needed for envoyproxy#10815, this patch: * Adds _MISC variants of sparse macros. * Sends _MISC log messages to fancy logger (these were previously ignored). This is a bit weird, as "misc" is also a logger and we use file-specific loggers in fancy logger, but in reality, most folks treat this macro as the generic Envoy log statement. * Avoid evaluating expressions in ENVOY_LOG* with fancy logger when beneath the configured log level. Risk level: Low Testing: Mostly covered by log_macros_test already, added some _MISC coverage in SparseLogMacrosTest. Signed-off-by: Harvey Tuch <htuch@google.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a nit and a question, otherwise looks good to me.
source/common/common/fancy_logger.cc
Outdated
@@ -90,6 +90,15 @@ void FancyContext::setAllFancyLoggers(spdlog::level::level_enum level) | |||
} | |||
} | |||
|
|||
FancyLogLevelMap FancyContext::getAllFancyLogLevels() ABSL_LOCKS_EXCLUDED(fancy_log_lock_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I lack some context here, but if this is a production code utility, would this deserve a unit test of its own, and maybe add caching to it?
If not, would it be worth considering moving this into test/ as right now it's only used there?
I don't want to bloat this PR, just curious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fancy_logger.h comments say this is test only, I don't mind renaming to getAllFancyLogLevelsForTest()
if that makes it clearer. Not sure how to move it out of this file as it needs access to internal fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please name test-only code as such. Makes it much easier to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanations. LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, modulo renaming ....ForTest
Signed-off-by: Harvey Tuch <htuch@google.com>
Inspired by a log statement needed for #10815, this patch:
Adds _MISC variants of sparse macros.
Sends _MISC log messages to fancy logger (these were previously
ignored). This is a bit weird, as "misc" is also a logger and
we use file-specific loggers in fancy logger, but in reality, most
folks treat this macro as the generic Envoy log statement.
Avoid evaluating expressions in ENVOY_LOG* with fancy logger when
beneath the configured log level.
Risk level: Low
Testing: Mostly covered by log_macros_test already, added some _MISC
coverage in SparseLogMacrosTest.
Signed-off-by: Harvey Tuch htuch@google.com