并行记录到控制台和日志文件

duallog的Python项目详细描述


DualLog软件包

python包,允许同时记录控制台和日志文件。

Duallog screenshot

如何安装DualLog?

您可以使用pip安装duallog,也可以从源安装。 下面是两种方法的说明。

通过PIP安装

在终端中,运行pip install duallog

从源安装

  1. 下载并解压缩此存储库。
  2. 打开终端并导航到存储库。
  3. 从存储库中执行python setup.py install

如何使用DualLog?

使用duallog非常简单,如下面的最小示例脚本所示。

# Import the duallog package to set up simultaneous logging to screen and console.importduallog# Import the logging package to generate log messages.importlogging# Set up dual logging and tell duallog where to store the logfiles.duallog.setup('logtest')# Generate some log messages.logging.debug('Debug messages are only sent to the logfile.')logging.info('Info messages are not shown on the console, too.')logging.warning('Warnings appear both on the console and in the logfile.')logging.error('Errors get the same treatment.')logging.critical('And critical messages, of course.')

此程序的输出显示在本页顶部的屏幕截图中。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
我可以用C++代码使用java代码吗?   java使用JSR303在派生类中提供更具体的约束   java在这个查找唯一路径数算法中我做错了什么?   java如何为2个不同的服务提供商使用2个不同的SSL证书?   java在Gridview上绘制文本   java使用连接for循环构建字符串名   java StringBuilder拆分无法处理某些文件   java事件关注EditText   Java Web Start“找不到URL的缓存资源”   java程序从命令行运行的速度比在Eclipse中慢   java为什么HttpServletRequest会截断#字符上的url输入?   java自定义折叠工具栏平滑标题大小调整   使用Mockito对安卓 java中调用另一个静态函数的函数进行单元测试   http在java客户机中使用cachecontrol头   java如何使用。是否使用Delimiter从输入文件中排除标点符号和数字?   使用上下文作为参数/参数的java   java更有效地从Jar中提取文件   java为多个JButton提供相同的actionListener