I have a command line tool which produces plenty of logs. I want these logs to be sent to stdout
as soon as they're made. Right now, the program finishes everything (which can take several minutes), and then sends everything to stdout
all at once. This means that currently, the user is not aware of whats going on internally, and I want to change that.
So far I've tried passing the -u
flag as a command line argument, but that doesn't change anything. I have a feeling I need to use logging.handlers.BufferingHandler
with flush()
in some capacity, but I haven't been able to figure it out through tinkering.
def some_func(flag: bool):if flag:logging.info('flag is truthy')returnlogging.warning('flag is falsy')
I'd like the above function to show the user one of those logs as soon as the log is created.
Note: currently I set the logging level with logging.root.setLevel(logging.INFO)
.
Thanks!