Python logging - Is there something below DEBUG?

前端 未结 4 1870
闹比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条回答
  •  萌比男神i
    2021-02-01 07:21

    The answer from @voitek works great, but he forgot to monkey patch logging.verbose.

    logging.VERBOSE = 5
    logging.addLevelName(logging.VERBOSE, "VERBOSE")
    logging.Logger.verbose = lambda inst, msg, *args, **kwargs: inst.log(logging.VERBOSE, msg, *args, **kwargs)
    logging.verbose = lambda msg, *args, **kwargs: logging.log(logging.VERBOSE, msg, *args, **kwargs)
    

    This will now also work with;

    logging.verbose(*args, **kwargs)
    

提交回复
热议问题