I would like to log all the output of a Python script. I tried:
import sys
log = []
class writer(object):
def write(self, data):
log.append(dat
Actually, if you're using linux/mac os, you can just use file redirect to do that. For example, if you're going to run "a.py" and record all the messages it will generate into file "a.out", it would just be
python a.py 2>&1 > a.out
The first part redirects stderr to stdout, and the second redirects that to a file called a.out.
For a longer list of redirection operators in Linux/Unix, see https://askubuntu.com/questions/420981/how-do-i-save-terminal-output-to-a-file