How to save the debugging info to a file?

Viewed 1575

I'm using PDB to debug python code, I wonder is there a way to save all the info appeared on the terminal during the whole debugging process to a file? copy-paste is not realistic here.

Help me edit the tags or move this question to a more appropriate place if this question is not proper on stackoverflow.

I guess I need to write a script to track the info on the terminal form the beginning to the end of the debugging process.

Any suggestion is appreciated.

3 Answers

The script command is the most convenient way of doing this in unix based OSes, it lets you save everything that appeared in your terminal to a file. You stop recording with exit or C-d so it can go as long as you want.

You can record your entire terminal session using asciinema.

Why dont you just try:

python test.py > outlog.txt

when run in the terminal. Output will be written in to the file.

You can use tee if you want to capture terminal session:

bash | tee log.txt

now do whatever you want in the terminal. All output will be written in to the file. Do your debug process in the same terminal. You can read the file after closing the terminal.

eg:

my commands :

bash | tee log.txt
ls
echo hi
python
print hi
exit()

output of the file after closing the terminal:

log.txt
hi
hi
Related