forked from ungleich-public/cdist
[cdist.log] Define custom log functions on logging.Logger
Define out custom logger functions on logging.Logger so that they are passed on to all other loggers. Also, the logger functions need to take a self argument so that they can log on the corrent Logger.
This commit is contained in:
parent
f730aa7679
commit
fed01ded83
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.addLevelName(logging.OFF, 'OFF')
|
||||
|
||||
|
||||
logging.VERBOSE = logging.INFO - 5
|
||||
logging.addLevelName(logging.VERBOSE, 'VERBOSE')
|
||||
|
||||
|
||||
def _verbose(msg, *args, **kwargs):
|
||||
logging.log(logging.VERBOSE, msg, *args, **kwargs)
|
||||
def _verbose(self, msg, *args, **kwargs):
|
||||
self.log(logging.VERBOSE, msg, args, **kwargs)
|
||||
|
||||
|
||||
logging.verbose = _verbose
|
||||
logging.Logger.verbose = _verbose
|
||||
|
||||
|
||||
logging.TRACE = logging.DEBUG - 5
|
||||
logging.addLevelName(logging.TRACE, 'TRACE')
|
||||
|
||||
|
||||
def _trace(msg, *args, **kwargs):
|
||||
logging.log(logging.TRACE, msg, *args, **kwargs)
|
||||
def _trace(self, msg, *args, **kwargs):
|
||||
self.log(logging.TRACE, msg, *args, **kwargs)
|
||||
|
||||
|
||||
logging.trace = _trace
|
||||
logging.Logger.trace = _trace
|
||||
|
||||
|
||||
class CdistFormatter(logging.Formatter):
|
||||
|
|
Loading…
Reference in a new issue