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怎么字体加阴影_如何添加阴影