简单的Python日志记录库

easylogging2的Python项目详细描述


轻松锁定2

pythonv2的简单易用的日志库

easylogging2versionstatuspythonwindowslinuxlicense

要求

注意事项

  • 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
      
  • 显示和隐藏来自^{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性能:

提高性能。

  • 水平表:

    LevelNumeric value
    CRITICAL< 50
    ERROR< 40
    WARNING< 30
    INFO< 20
    DEBUG< 10
    NOTSET0

许可证

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

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

推荐PyPI第三方库


热门话题
java如何从tester类访问/更改ArrayList?   java如何在Android中以编程方式更改菜单标题   spring boot在Kafka Java中为同一主题创建多个消费者组   java JVM字节码表示法,注释语法。调用动力学   java活动在旋转后泄漏了窗口PopupWindow   java允许Nashorn运行用户代码   Java Joda Time实现一个日期范围迭代器   当字符串长度为奇数时使用递归打印字符串的java基本情况   java无法从JSONArray获取JSONObject   java有没有一种方法可以使用单个示例文件进行所有测试?   java My bufferedReader读取整个文件,而不仅仅是一行。为什么?   当已有用户输入时,java变量为null   java如何将正则表达式与阿拉伯语文本一起使用   java Selenium WebDriver“单击”和JavascriptExecutor单击之间有什么区别   java在运行代码时,排序方法会在第二个数组应该按升序或降序排序时打印相同的精确数组号   java如何在HashMap中添加多个具有相同键的相同类型的对象   java有人知道为什么菜单栏在使用系统gtk主题时会显示白色文本吗?   在tomcat中用java方法访问JavaScript文件