Skip to content

Commit

Permalink
adding flush to print
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Fievet committed Aug 27, 2024
1 parent 70b0ba7 commit 6637c14
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions LIReC/jobs/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ def setup_logging():
file_handler.setFormatter(formatter)
stream_handler.setFormatter(formatter)

# Define a flush method that flushes the outputs
class FlushHandler(logging.Handler):
def emit(self, record):
logging.StreamHandler.emit(self, record)
self.flush()

file_handler = FlushHandler()
stream_handler = FlushHandler()

# Add both handlers to the logger
logger.addHandler(file_handler)
logger.addHandler(stream_handler)
Expand Down

0 comments on commit 6637c14

Please sign in to comment.