Skip to content
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

Merged
merged 3 commits into from
Sep 25, 2020

Conversation

htuch
Copy link
Member

@htuch htuch commented Sep 22, 2020

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

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>
@htuch htuch requested a review from oschaaf September 22, 2020 21:32
Copy link
Member

@oschaaf oschaaf left a 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.

test/common/common/log_macros_test.cc Show resolved Hide resolved
@@ -90,6 +90,15 @@ void FancyContext::setAllFancyLoggers(spdlog::level::level_enum level)
}
}

FancyLogLevelMap FancyContext::getAllFancyLogLevels() ABSL_LOCKS_EXCLUDED(fancy_log_lock_) {
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

oschaaf
oschaaf previously approved these changes Sep 23, 2020
Copy link
Member

@oschaaf oschaaf left a 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

Copy link
Contributor

@ggreenway ggreenway left a 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

@htuch htuch merged commit 755dd0d into envoyproxy:master Sep 25, 2020
@htuch htuch deleted the warn-v2-upgrade branch September 25, 2020 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants