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

Function to attach spdlog to Python logger #422

Open
aaron-skydio opened this issue Jan 14, 2025 Discussed in #420 · 0 comments
Open

Function to attach spdlog to Python logger #422

aaron-skydio opened this issue Jan 14, 2025 Discussed in #420 · 0 comments

Comments

@aaron-skydio
Copy link
Member

Discussed in #420

Originally posted by tchittesh January 9, 2025
I'm using the python symforce.opt.Optimizer which is printing optimization info

[2025-01-10 01:44:21.428] [info] LM<sym::Optimize> [iter   21] lambda: 4.768e-03, error prev/linear/new: 0.000/0.000/0.000, rel reduction: 0.15934
[2025-01-10 01:44:21.447] [info] LM<sym::Optimize> [iter   22] lambda: 2.384e-03, error prev/linear/new: 0.000/0.000/0.000, rel reduction: 0.19686
[2025-01-10 01:44:21.467] [info] LM<sym::Optimize> [iter   23] lambda: 1.192e-03, error prev/linear/new: 0.000/0.000/0.000, rel reduction: 0.25366

Is there a way to capture this output (generated by spdlog in C++) or redirect it to stdout? Some naive approaches like

from symforce import logger as symforce_logger, LOGGING_FORMAT as SYMFORCE_LOGGING_FORMAT
symforce_logger.handlers.clear()
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.WARNING)
formatter = logging.Formatter(SYMFORCE_LOGGING_FORMAT)
handler.setFormatter(formatter)
symforce_logger.addHandler(handler)

don't seem to work

Conclusion in the discussion was that it would be nice to be able to attach spdlog to the Python logger, which would let us wrap one function to do that (rather than the entire spdlog interface), and then people will be able to manage things through the python logger

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

No branches or pull requests

1 participant