File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-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 ):
@@ -415,6 +418,13 @@ def getEffectiveLevel(self) -> int:
415418
416419 return self ._level
417420
421+ def flushHandlers (self ) -> None :
422+ """Flush all handlers. This will ensure that all data is immediately written to the streams.
423+ This can be useful if you need to make sure the log is written before a reset.
424+ """
425+ for handlerName in self ._handlers :
426+ handlerName .flush ()
427+
418428 def addHandler (self , hdlr : Handler ) -> None :
419429 """Adds the handler to this logger.
420430
You can’t perform that action at this time.
0 commit comments