Open
Description
Just tried the updated logging
module to replace the StreamHandler
and FileHandler
adapted from CPython that I was previously using. Thank you @iabdalkader for this update.
StreamHandler
works as expected, however I noticed that I wasn't getting any new lines in my log file.
I looked at the previous code and saw that there's a flush
after the write
in StreamHandler.emit
.
Using this subclass for FileHandler
, it works like before:
class MyStreamHandler(StreamHandler):
def flush(self):
if self.stream and hasattr(self.stream, "flush"):
self.stream.flush()
def emit(self, record):
super().emit(record)
self.flush()
Is there a reason for not doing a flush
in emit
, maybe something specific to MicroPython that I'm not aware of?
- MicroPython and board:
MicroPython v1.19.1-915-g2bcd88d55 on 2023-03-02; Raspberry Pi Pico W with RP2040
logging
version:0.5
installed withmip
Metadata
Metadata
Assignees
Labels
No labels