Fix missing log messages when using logging.info
What this does
Fixes missing log messages when using logging.info.
(🐛 Bug)
Previously, log messages at the INFO level (and below) were not displayed due to pre-existing logging handlers interfering with basicConfig().
This PR ensures that any previously initialized handlers are removed before configuring logging, so that the logging configuration in init_logging() always takes effect.
A warning is logged when pre-existing handlers are cleaned up.
How it was tested
- Manually verified that log messages now appear at the INFO level and above when using e.g.
python -m lerobot.record
How to checkout & try? (for the reviewer)
Run the record script and observe that INFO logs now show up.
Thank for the PR. Just to clarify: it's mainly adding the warning as existing handlers were already removed, no?
The main change is removing the handlers (logging.root.removeHandler(...)) before logging.basicConfig(...) instead of after.
logging.basicConfig(...) has no effect if there are existing handlers. In my case, there's always 1 existing handler when I run python -m lerobot.record, which makes logging.basicConfig(level=logging.INFO) have no effect. The default logging level is WARN so INFO logs don't show up.
Hi @ben-z !
We actually mostly reworked the init_logging() function in a recent commit, including custom logging levels for console and file logging, and an overall cleaner implementation (#1466).
Could you check if this new version solves the handler issue tackled in your PR ? If not, I'll be happy to elaborate on this topic !
Best,
Caroline.
Yep this is resolved by https://github.com/huggingface/lerobot/pull/1466 . Closing!