I am writing a Python 3 application in which I want to log my messages to screen as well as a log file. I have set that up using logging handlers.
However, additionally, I also want to pipe the stdout and stderr output of any subprocess calls I make in the script to the same logging handlers (i.e both screen and log file).
I can do stdout=subprocess.PIPE, stderr=subprocess.STDOUT to capture the output in a variable and then log that variable. But that means nothing shows up on screen until that process is finished. However, I want the output to "stream" on the screen and in the log file, as the process is running.
Anyway to get this connection between subprocess output and logging handlers established in real-time?