How to automatic save all terminal output to a log file?