This answer says it's as simple as:
pipe python logging stdout stream output to grep
python main.py 2>&1 | grep INFO
I have the following file, which I've tried with print()
and sys.stdout.write()
.
import sys
from time import sleep
while True:
sleep(1)
sys.stdout.write("this is a thing")
# Also tried print()
I'm trying to collect "thing"
with:
python output.py 2>&1 | grep "thing"