Skip to content

Commit

Permalink
Add flush function to the stream handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
ilikecake committed Jun 4, 2024
1 parent 337770e commit 4e0c2f3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions adafruit_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ def emit(self, record: LogRecord) -> None:
"""
self.stream.write(self.format(record) + self.terminator)

def flush(self) -> None:
"""flush the stream. You might need to call this if your messages
are not appearing in the log file.
"""
self.stream.flush()


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


class RotatingFileHandler(FileHandler):
Expand Down Expand Up @@ -339,7 +344,6 @@ def emit(self, record: LogRecord) -> None:
):
self.doRollover()
self.stream.write(self.format(record))
self.stream.flush()


class NullHandler(Handler):
Expand Down

0 comments on commit 4e0c2f3

Please sign in to comment.