本地日志(一种不会污染全局范围的日志工具)

llog的Python项目详细描述


※下面有日语说明

English description

This package a logging tool that doesn't pollute the global scope.

How to use

fromllogimportLLogtest_log=LLog("./test_log.log")test_log.debug({"msg":"test1"})test_log.debug({"msg":"test2"})test_log.debug({"msg":"test3"})

Output result: test_log.log

{"date":"2020-09-22 03:32:59.614418","level":"DEBUG","summary_stack":{"function":"<module>","filename":"test_root.py"},"contents":{"msg":"test1"}}{"date":"2020-09-22 03:32:59.616413","level":"DEBUG","summary_stack":{"function":"<module>","filename":"test_root.py"},"contents":{"msg":"test2"}}{"date":"2020-09-22 03:32:59.617411","level":"DEBUG","summary_stack":{"function":"<module>","filename":"test_root.py"},"contents":{"msg":"test3"}}

You can check the contents of the log file (the last n entries) as follows:

test_log.tail(n=2)

Result: standard output (console)

[log #1] {
  "date": "2020-09-22 03:32:59.616413",
  "level": "DEBUG",
  "summary_stack": {
    "function": "<module>",
    "filename": "test_root.py"
  },
  "contents": {"msg": "test2"}
}
[log #2] {
  "date": "2020-09-22 03:32:59.617411",
  "level": "DEBUG",
  "summary_stack": {
    "function": "<module>",
    "filename": "test_root.py"
  },
  "contents": {"msg": "test3"}
}

日语说明

能够详细管理日志设置范围的日志工具(不与其他工具的日志设置冲突)

简单的使用方法

fromllogimportLLogtest_log=LLog("./test_log.log")test_log.debug({"msg":"test1"})test_log.debug({"msg":"test2"})test_log.debug({"msg":"test3"})

输出结果:testlog.log

{"date":"2020-09-22 03:32:59.614418","level":"DEBUG","summary_stack":{"function":"<module>","filename":"test_root.py"},"contents":{"msg":"test1"}}{"date":"2020-09-22 03:32:59.616413","level":"DEBUG","summary_stack":{"function":"<module>","filename":"test_root.py"},"contents":{"msg":"test2"}}{"date":"2020-09-22 03:32:59.617411","level":"DEBUG","summary_stack":{"function":"<module>","filename":"test_root.py"},"contents":{"msg":"test3"}}

可以如下确认日志文件的内容(末尾n件)。

test_log.tail(n=2)

结果:标准输出(控制台)

[log #1] {
  "date": "2020-09-22 03:32:59.616413",
  "level": "DEBUG",
  "summary_stack": {
    "function": "<module>",
    "filename": "test_root.py"
  },
  "contents": {"msg": "test2"}
}
[log #2] {
  "date": "2020-09-22 03:32:59.617411",
  "level": "DEBUG",
  "summary_stack": {
    "function": "<module>",
    "filename": "test_root.py"
  },
  "contents": {"msg": "test3"}
}

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

推荐PyPI第三方库


热门话题
“电话目录”数据结构的java实现   使用PC remote读取JSP页面上的文件时出现java错误   无法在不同目录中从Java执行Python脚本   java无法在windows 8.1上运行javafx应用程序   java航空公司系统如何防止两个用户同时预订同一个座位?   反射如何在java方法中获取每个参数的名称和值?   阅读中的字符串问题。txt文档并在Java中编辑   java JTextPane行包装问题   使用PowerMock Android Junit时出现java ClassNotFoundException   java输入和If语句   java如何在不使用剪贴板或操作CTRL+C、CTRL+V的情况下将字符串中的“\t”或“tab”发送到selenium中的文本框中   tomcat7将Java应用程序部署到Digitalocean中的Tomcat根目录   响应中嵌套映射的java问题(Jersey)