lerobot icon indicating copy to clipboard operation
lerobot copied to clipboard

Fix missing log messages when using logging.info

Open ben-z opened this issue 7 months ago • 2 comments

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.

ben-z avatar Jun 07 '25 05:06 ben-z

Thank for the PR. Just to clarify: it's mainly adding the warning as existing handlers were already removed, no?

aliberts avatar Jun 10 '25 16:06 aliberts

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.

ben-z avatar Jun 10 '25 16:06 ben-z

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.

CarolinePascal avatar Jul 08 '25 17:07 CarolinePascal

Yep this is resolved by https://github.com/huggingface/lerobot/pull/1466 . Closing!

ben-z avatar Jul 10 '25 21:07 ben-z