You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
logging.basicConfig(force=False) on empty handler list never initializes Formatter and Handler #979
The Object "logger" as Logger instance on either case will NEVER get a working Handler and Formatter upon initialization. This is because logging.basicConfig() in (current) line 235 evaluates the list object Logger.handlers instead of the integer number Logger.hasHandlers().
NOTE: Initialization of a date format of type "asctime" within micropython, as shown in the code above, is not (yet) supported (by design) and thus requires explicit implementation efforts.
I took a look at this while fixing some other bugs and and found that logging.basicConfig() creates and configures only the root logger (i.e. a logger named "root"). This is the same behaviour as the CPython standard library, described in the documentation and source code. I think this could be made a bit clearer in the MicroPython logging.basicConfig() function by:
changing the variable name from generic (logger) to specific (root) which aligns with the CPython library;
changing the test on line 235, as you suggest, to read if force or not logger.hasHandlers():.
I'll add these changes to the fixes I'm making.
The time.strftime() function which Formatters require to process "asctime" is, in fact, implemented in micropython-lib/python-stdlib/time and the time module is de facto a requirement of the logging module. It's been noted in another Issue that perhaps this needs to be a little better documented.
Activity
jamesquilty commentedon Oct 21, 2026
I took a look at this while fixing some other bugs and and found that
logging.basicConfig()creates and configures only the root logger (i.e. a logger named "root"). This is the same behaviour as the CPython standard library, described in the documentation and source code. I think this could be made a bit clearer in the MicroPythonlogging.basicConfig()function by:logger) to specific (root) which aligns with the CPython library;if force or not logger.hasHandlers():.I'll add these changes to the fixes I'm making.
The
time.strftime()function which Formatters require to process "asctime" is, in fact, implemented in micropython-lib/python-stdlib/time and the time module is de facto a requirement of the logging module. It's been noted in another Issue that perhaps this needs to be a little better documented.logging: Refactor basicConfig to clarify it configures the root logger.