forked from ungleich-public/cdist
Merge branch 'fix/logging/custom-levels' into 'master'
Define custom log functions on logging.Logger See merge request ungleich-public/cdist!1011
This commit is contained in:
commit
4307e8e7fa
1 changed files with 8 additions and 6 deletions
14
cdist/log.py
14
cdist/log.py
|
@ -36,25 +36,27 @@ import threading
|
||||||
logging.OFF = logging.CRITICAL + 10 # disable logging
|
logging.OFF = logging.CRITICAL + 10 # disable logging
|
||||||
logging.addLevelName(logging.OFF, 'OFF')
|
logging.addLevelName(logging.OFF, 'OFF')
|
||||||
|
|
||||||
|
|
||||||
logging.VERBOSE = logging.INFO - 5
|
logging.VERBOSE = logging.INFO - 5
|
||||||
logging.addLevelName(logging.VERBOSE, 'VERBOSE')
|
logging.addLevelName(logging.VERBOSE, 'VERBOSE')
|
||||||
|
|
||||||
|
|
||||||
def _verbose(msg, *args, **kwargs):
|
def _verbose(self, msg, *args, **kwargs):
|
||||||
logging.log(logging.VERBOSE, msg, *args, **kwargs)
|
self.log(logging.VERBOSE, msg, args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
logging.verbose = _verbose
|
logging.Logger.verbose = _verbose
|
||||||
|
|
||||||
|
|
||||||
logging.TRACE = logging.DEBUG - 5
|
logging.TRACE = logging.DEBUG - 5
|
||||||
logging.addLevelName(logging.TRACE, 'TRACE')
|
logging.addLevelName(logging.TRACE, 'TRACE')
|
||||||
|
|
||||||
|
|
||||||
def _trace(msg, *args, **kwargs):
|
def _trace(self, msg, *args, **kwargs):
|
||||||
logging.log(logging.TRACE, msg, *args, **kwargs)
|
self.log(logging.TRACE, msg, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
logging.trace = _trace
|
logging.Logger.trace = _trace
|
||||||
|
|
||||||
|
|
||||||
class CdistFormatter(logging.Formatter):
|
class CdistFormatter(logging.Formatter):
|
||||||
|
|
Loading…
Reference in a new issue