我想log.txt
为每个输出行设置一个文件时间戳。它正在做我希望它在终端输出中做的事情。我将如何在log.txt
文件中设置时间戳?
命令:
python ig.py |& tee -a log.txt | ts '[%Y-%m-%d %H:%M:%S]'
终端输出:
[2017-04-19 08:38:48] DEBUG:__main__:Liking 1494171280764517709
[2017-04-19 08:38:49] DEBUG:__main__:Sleeping for 33.919725732684476
log.txt 输出:
DEBUG:__main__:Liking 1494171280764517709
DEBUG:__main__:Sleeping for 33.919725732684476
移动ts
之前的tee
时间戳,以便在将时间戳写入文件之前将其添加到输出中:
python ig.py |& ts '[%Y-%m-%d %H:%M:%S]' | tee -a log.txt
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句