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

logging.basicConfig(force=False) on empty handler list never initializes Formatter and Handler #979

Open
nielsson4711 opened this issue Feb 25, 2025 · 0 comments

Comments

@nielsson4711
Copy link

nielsson4711 commented Feb 25, 2025

Aiming to add minimalistic logging capabilities soon within starting phase of a micropythion program, one would call:

#minimalistic
logging.basicConfig(stream=stream.sys level=logging.DEBUG)
logger = logging.getLogger('thelog')

Aiming to get a fancy timestamp and information ordering, the call could look like:

# explicit formatting
log_fmt_mipy = "%(name)s - %(levelname)s - %(message)s"
log_fmt_dat_mipy = "%(asctime)s.%(msecs)03d"
logging.basicConfig(stream=stream.sys level=logging.DEBUG)
logger = logging.getLogger('thelog')

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.

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