micropython / micropython/micropython-lib
logging.basicConfig(force=False) on empty handler list never initializes Formatter and Handler
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 1.1k
- Avg merge
- 7d 6h
- Merged PRs (30d)
- 3
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in python-stdlib/logging/logging.py around line 235, where basicConfig(force=False) evaluates Logger.handlers. Compare that logic with Logger.hasHandlers() and trace initialization for the empty-handler case. Done means a logger created after basicConfig receives a working Handler and Formatter without changing the documented MicroPython asctime limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100