[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)
Discussed in #420
Originally posted by tchittesh January 9, 2025
I'm using the python
symforce.opt.Optimizerwhich is printing optimization infoIs there a way to capture this output (generated by spdlog in C++) or redirect it to stdout? Some naive approaches like
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