Python logging - Is there something below DEBUG?

前端 未结 4 1902
闹比i
闹比i 2021-02-01 06:53

In some other technologies we occasionally used a log level below DEBUG that I believe was called \"verbose\". I realize that the need for such a level is very subjective. But

4条回答
  •  南旧
    南旧 (楼主)
    2021-02-01 07:18

    DEBUG is the lowest level out of the ones provided by the logging module: ('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'). Their numeric values are here: http://docs.python.org/howto/logging.html#logging-levels

    You can create custom levels (though the docs say that that should rarely be necessary and may even be undesirable). If you want to add a level, the technique is simple:

    >>> logging.addLevelName(5, "VERBOSE")
    

    Eventhough you can add a custom level, it may be a better approach to add some filters that provide a finer level of control.

提交回复
热议问题