How to get the terminal full history
Question:
I am trying to save everything my python app printed in the cmd, every solution I found was to get the response of a command line using Popen
from Subprocess
; what I want is to get everything. Is there a built-in function for this purpose? or should I do it manually, which I don’t prefer?
Answers:
Why don’t you use this from terminal
python main.py > output.log
you can try the script
command in your shell. It saves everything printed out to your shell from the moment you call it. End the command with exit. you can call it from your python script, hope it helps.
What you want to do, is log the output of stdout, see this answer:
Making Python loggers output all messages to stdout in addition to log file
I am trying to save everything my python app printed in the cmd, every solution I found was to get the response of a command line using Popen
from Subprocess
; what I want is to get everything. Is there a built-in function for this purpose? or should I do it manually, which I don’t prefer?
Why don’t you use this from terminal
python main.py > output.log
you can try the script
command in your shell. It saves everything printed out to your shell from the moment you call it. End the command with exit. you can call it from your python script, hope it helps.
What you want to do, is log the output of stdout, see this answer:
Making Python loggers output all messages to stdout in addition to log file