python日志模块为什么打印到界面_如何将外部模块的日志消息打印到主Python模块的终端窗口?...
我正在写一个Python命令行程序。在
有一个主Python脚本文件,用作入口点。当用户运行这个脚本时,它将执行一些外部Python脚本文件。外部Python脚本文件也可以执行其他外部Python脚本文件。外部文件的数量是可变的。在
Python脚本将使用以下方式执行外部Python脚本:p = subprocess.Popen(args)
or
p = subprocess.call(args)
当我在终端窗口中运行主Python脚本时,它将在运行时在屏幕上打印实时日志消息。现在,我希望从主Python脚本调用的所有外部Python脚本获取所有日志消息,并将其打印到同一个终端窗口(我用来运行主脚本的终端窗口)。在
例如,以下是脚本执行的顺序:
^{pr2}$
当我在终端窗口中运行主脚本时,是否可以像下面这样在终端窗口上获得实时日志消息?在[time-hh-mm-ss][log message from main script]Script is running..
[time-hh-mm-ss][log message from main script]Calling script layer-1-script-1..
[time-hh-mm-ss][log message from layer-1-script-1]Script is running..
[time-hh-mm-ss][log message from layer-1-script-1]Calling script layer-2-script-1..
[time-hh-mm-ss][log message from layer-2-script-1]Script is running..
[time-hh-mm-ss][log message from layer-2-script-1]Calling script layer-2-script-2..
[time-hh-mm-ss][log message from layer-2-script-2]Script is running..
[time-hh-mm-ss][log message from layer-2-script-2]Calling script layer-1-script-2..
[time-hh-mm-ss][log message from layer-1-script-2]Script is running..
[time-hh-mm-ss][log message from layer-1-script-2]Calling script layer-1-script-3..
[time-hh-mm-ss][log message from layer-2-script-3]Script is running..
[time-hh-mm-ss][log message from main script]Back to main script. Script is running..
有没有可能我可以在终端窗口中得到一个real time log messages类似的内容?在
总结
以上是生活随笔为你收集整理的python日志模块为什么打印到界面_如何将外部模块的日志消息打印到主Python模块的终端窗口?...的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: dp线长什么样子_怎么样选择好的DP线?
- 下一篇: python怎么字体加阴影_如何添加阴影