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

Add EoL and use SetConsoleSinkLevel #148

Merged
merged 2 commits into from
Sep 25, 2024
Merged

Conversation

caguero
Copy link
Contributor

@caguero caguero commented Sep 22, 2024

This patch:

  1. Adds newlines to the logging messages used in the log example.
  2. Uses SetConsoleSinkLevel() to only change the verbosity level of the console.

This is the result we should see in the console:

(2024-09-22 20:41:34.090) [info] [:] info
(2024-09-22 20:41:34.090) [warning] [:] warn
(2024-09-22 20:41:34.090) [error] [:] error
(2024-09-22 20:41:34.090) [critical] [:] critical

And this is the result we should see in /tmp/my_log.txt:

(2024-09-22 20:41:34.090) [trace] [:] trace
(2024-09-22 20:41:34.090) [info] [:] info
(2024-09-22 20:41:34.090) [warning] [:] warn
(2024-09-22 20:41:34.090) [error] [:] error
(2024-09-22 20:41:34.090) [critical] [:] critical

If we change the verbosity level using the original call logger.RawLogger().set_level(spdlog::level::trace); the result is confusing because the console only shows:

(2024-09-22 20:44:34.801) [error] [:] error
(2024-09-22 20:44:34.801) [critical] [:] critical

The reason for this is because we have a logger level set to trace and the console sink levels set to err in Logger.cc. spdlog seems to choose the verbosity with higher priority between sinks and logger.

Summary

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

Signed-off-by: Carlos Agüero <[email protected]>
@caguero caguero requested a review from azeey as a code owner September 22, 2024 18:48
@azeey azeey merged commit fb1cc81 into gz-utils3 Sep 25, 2024
11 checks passed
@azeey azeey deleted the caguero/console_example branch September 25, 2024 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants