[BangPypers] Capture and save running process on Python 3.6

Noufal Ibrahim KV noufal at nibrahim.net.in
Thu Nov 2 05:55:21 EDT 2017

On Thu, Nov 02 2017, Ajinkya Bobade wrote:

> Hello,
> Hope someone can help me on this. In the following code, I want to capture
> print('Recording GPS Position...')  on sd card, for now, this is printing
> on terminal directly I want to capture this runtime process (p_1) from
> terminal and store on sd card as it is being executed how do I do
> this.

You can either run your program with a stdout redirect e.g. 

python foo.py > logfile.txt

or inside your program, replace sys.stdout with an open file object
pointing to your log file. I'd go with the former. 

Secondly, if you want to capture logs and things, you should consider
using the logging module. 



More information about the BangPypers mailing list