我有一个Python脚本,可以连续运行,通过记录器实例将状态消息输出到控制台和日志文件。
这样很好。
然而,我真正喜欢的是将最重要的细节浓缩成一个始终可见的"仪表板"在控制台的底部。像这样:
Timestamp - Logger info - Minor status update 1
Timestamp - Logger info - Status has changed
Timestamp - Logger info - Status has changed again
Timestamp - Logger info - Successfully opened file
Timestamp - Logger info - Successfully closed file
Timestamp - Logger info - Never gonna give you up
Timestamp - Logger info - Never gonna let you down...
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Statistics: Critical errors so far: 0. Processing: 12 units/second. +
+ Current running time: 44839 seconds. Foos barred: 3. Bars fooed: 11. +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
这样做有好办法吗?我还没有找到任何......
我知道它可行,像wget这样的工具一直在做:
$ wget http://releases.ubuntu.com/16.04.3/ubuntu-16.04.3-desktop-amd64.iso
--2018-01-06 13:15:57-- http://releases.ubuntu.com/16.04.3/ubuntu-16.04.3-desktop-amd64.iso
Resolving releases.ubuntu.com... 91.189.88.166, 2001:67c:1560:8001::7
Connecting to releases.ubuntu.com|91.189.88.166|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1587609600 (1.5G) [application/x-iso9660-image]
Saving to: ‘ubuntu-16.04.3-desktop-amd64.iso’
ubuntu-16.04.3-desktop-amd64.iso 0%[ ] 4.64M 857KB/s eta 42m 12s
我特别不是在寻找web based tool或图形界面,就像大多数人似乎在询问"仪表板" ...只是一种面向命令行界面的方式来扩展我和#39;我已经做了一点。
执行此操作的一种方法是使用ANSI control characters - 但我担心会丢掉记录器输出(我想保留!)。
我到目前为止找到的最佳解决方案是tqdm,这是一个纯粹的进度条......不幸的是,我并没有尝试衡量进度,"只需在显示屏底部显示一些重要的统计信息。并且,尽管它很性感,我还不确定它是否会与记录器配合使用!