简单的Python日志记录库
easylogging2的Python项目详细描述
轻松锁定2
pythonv2的简单易用的日志库
要求
- Python-3-->;http://www.python.org/download/
注意事项
- 9个月后,这个图书馆恢复得更好,也更有用。在
- 这个库非常简单,所以它并不比日志库更好,它是从它派生出来的。在
- 创建这个库是因为我想要一个简单易用的日志库。在
安装
- 在
克隆此回购:
在$ git clone https://github.com/AI35/easylogging2
- 在
使用pip:
^{pr2}$ 在
使用
- 在
首先需要导入lib和Set name:
在import easylogging2 log = easylogging2.logname(__file__)
- 在
使用您需要的功能:
- 在关键日志(消息)
- 在日志.错误(msg,exc_info)default:exc\u info=False
- 在日志警告(消息)
- 在日志信息(消息)
- 在日志.调试(消息)
- 在
您可以从Cmd或PowerShell启动日志记录:
在$ Python yourfile.py --logging --logfile usage: youefile.py [--logging] [--logfile] optional arguments: --logging Display log in Console --logfile Create log file
- 在
{str}将在^ 1之后看到新文件$日志记录.conf:
- 更改level数字以在控制台中显示日志,而不使用--日志记录(0显示所有级别)。
在level=50
- 更改file_levelnumber,用--logfile(50 hide all level)设置日志文件中的级别。
-此选项适用于--logfile without use--logging(如果使用--logging,文件将写入所有级别)
在file_level=0
- 更改level数字以在控制台中显示日志,而不使用--日志记录(0显示所有级别)。
- 在
显示和隐藏来自^{str 1}的错误信息$日志记录.conf:
-显示错误信息(easylogging.错误(消息,例外信息))
-真或假或无
-*(None)表示exc_info取用户输入的值,例如:easylogging.错误(msg,exc_info=True)
在exc_info=None
- 在
您可以运行测试.py文件查看其工作原理。在
在 - 在
您可以使用此库中的所有日志记录函数(例如:简易日志记录.函数)
在 - 在
formatter:
-您可以使用所有默认的日志记录格式。
formatter = %(asctime)s - %(name)s - %(levelname)s - %(message)s
-来自日志格式化程序函数:
在Formatter instances are used to convert a LogRecord to text. Formatters need to know how a LogRecord is constructed. They are responsible for converting a LogRecord to (usually) a string which can be interpreted by either a human or an external system. The base Formatter allows a formatting string to be specified. If none is supplied, the the style-dependent default value, "%(message)s", "{message}", or "${message}", is used. The Formatter can be initialized with a format string which makes use of knowledge of the LogRecord attributes - e.g. the default value mentioned above makes use of the fact that the user's message and arguments are pre- formatted into a LogRecord's message attribute. Currently, the useful attributes in a LogRecord are described by: %(name)s Name of the logger (logging channel) %(levelno)s Numeric logging level for the message (DEBUG, INFO, WARNING, ERROR, CRITICAL) %(levelname)s Text logging level for the message ("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL") %(pathname)s Full pathname of the source file where the logging call was issued (if available) %(filename)s Filename portion of pathname %(module)s Module (name portion of filename) %(lineno)d Source line number where the logging call was issued (if available) %(funcName)s Function name %(created)f Time when the LogRecord was created (time.time() return value) %(asctime)s Textual time when the LogRecord was created %(msecs)d Millisecond portion of the creation time %(relativeCreated)d Time in milliseconds when the LogRecord was created, relative to the time the logging module was loaded (typically at application startup time) %(thread)d Thread ID (if available) %(threadName)s Thread name (if available) %(process)d Process ID (if available) %(message)s The result of record.getMessage(), computed just as the record is emitted
长日志
V 2.0.5一些修复:
-将一些变量设为私有。
V 2.0.1性能:
提高性能。
- 在
水平表:
在Level Numeric value CRITICAL < 50 ERROR < 40 WARNING < 30 INFO < 20 DEBUG < 10 NOTSET 0
许可证
Copyright 2019 LinePY - ALI B OTHMAN(AI35), Inc.
easylogging2
Licensed under the GNU License , you may not use this
file except in compliance with the License.
You may obtain a copy of the License at :
https://github.com/AI35/easylogging2/blob/master/LICENSE
ALI.B.OTH-ORG:LinePY- 项目
标签: