I know how to redirect stdout into a file:
import sys
sys.stdout = open('log.txt', 'w')
print 'test'
This will create a log.txt
where test
will be written in it.
However, test
will not be print in stdout.
How can i print and redirect test
in both terminal and file without changing every print statement in the program.
PS: I know that redirecting sys.stdout is bad (but i still need to do it)