Skip to content

Commit 4e0c2f3

Browse files
committed
Add flush function to the stream handler.
1 parent 337770e commit 4e0c2f3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

adafruit_logging.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@ def emit(self, record: LogRecord) -> None:
206206
"""
207207
self.stream.write(self.format(record) + self.terminator)
208208

209+
def flush(self) -> None:
210+
"""flush the stream. You might need to call this if your messages
211+
are not appearing in the log file.
212+
"""
213+
self.stream.flush()
214+
209215

210216
class FileHandler(StreamHandler):
211217
"""File handler for working with log files off of the microcontroller (like
@@ -239,7 +245,6 @@ def emit(self, record: LogRecord) -> None:
239245
:param record: The record (message object) to be logged
240246
"""
241247
self.stream.write(self.format(record))
242-
self.stream.flush()
243248

244249

245250
class RotatingFileHandler(FileHandler):
@@ -339,7 +344,6 @@ def emit(self, record: LogRecord) -> None:
339344
):
340345
self.doRollover()
341346
self.stream.write(self.format(record))
342-
self.stream.flush()
343347

344348

345349
class NullHandler(Handler):

0 commit comments

Comments
 (0)