File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,9 @@ def emit(self, record: LogRecord) -> None:
179179
180180 raise NotImplementedError ()
181181
182+ def flush (self ) -> None :
183+ """Placeholder for flush function in subclasses."""
184+
182185
183186# pylint: disable=too-few-public-methods
184187class StreamHandler (Handler ):
@@ -206,6 +209,12 @@ def emit(self, record: LogRecord) -> None:
206209 """
207210 self .stream .write (self .format (record ) + self .terminator )
208211
212+ def flush (self ) -> None :
213+ """flush the stream. You might need to call this if your messages
214+ are not appearing in the log file.
215+ """
216+ self .stream .flush ()
217+
209218
210219class FileHandler (StreamHandler ):
211220 """File handler for working with log files off of the microcontroller (like
@@ -239,6 +248,7 @@ def emit(self, record: LogRecord) -> None:
239248 :param record: The record (message object) to be logged
240249 """
241250 self .stream .write (self .format (record ))
251+ self .stream .flush ()
242252
243253
244254class RotatingFileHandler (FileHandler ):
@@ -338,6 +348,7 @@ def emit(self, record: LogRecord) -> None:
338348 ):
339349 self .doRollover ()
340350 self .stream .write (self .format (record ))
351+ self .stream .flush ()
341352
342353
343354class NullHandler (Handler ):
You can’t perform that action at this time.
0 commit comments