micropython / micropython/micropython-lib
asctime in logging will never output because strftime is not an attribute of time
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 1.1k
- Avg merge
- 7d 6h
- Merged PRs (30d)
- 3
Description
Expexted behaviour:
Using this formatter the log output will include a timestamp.
logging.Formatter('%(asctime)s | %(name)s | %(levelname)s - %(message)s')
Like this:
Tue Feb 17 09:42:58 2009 | MAIN | INFO - test
Actual behaviour:
Timestamp will always be None
None | MAIN | INFO - test
Cause:
The formatTime() method checks for the strftime attribute, which does not exist in the Micropython implementation:
def formatTime(self, datefmt, record):
if hasattr(time, "strftime"):
return time.strftime(datefmt, time.localtime(record.ct))
return None
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 by locating the logging implementation that defines Formatter.formatTime and inspect the MicroPython time API used there. Reproduce the Formatter example from the issue, then verify that a formatted record includes a timestamp instead of None and that existing logging behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100