forked from ungleich-public/cdist
Use proper format string with name
This commit is contained in:
parent
840e417eb7
commit
4167f9f60c
1 changed files with 2 additions and 11 deletions
13
cdist/log.py
13
cdist/log.py
|
@ -75,7 +75,7 @@ class CdistFormatter(logging.Formatter):
|
||||||
|
|
||||||
|
|
||||||
class DefaultLog(logging.Logger):
|
class DefaultLog(logging.Logger):
|
||||||
FORMAT = '%(levelname)s: %(message)s'
|
FORMAT = '%(levelname)s: %(name)s: %(message)s'
|
||||||
|
|
||||||
class StdoutFilter(logging.Filter):
|
class StdoutFilter(logging.Filter):
|
||||||
def filter(self, rec):
|
def filter(self, rec):
|
||||||
|
@ -91,8 +91,6 @@ class DefaultLog(logging.Logger):
|
||||||
|
|
||||||
formatter = CdistFormatter(self.FORMAT)
|
formatter = CdistFormatter(self.FORMAT)
|
||||||
|
|
||||||
self.addFilter(self)
|
|
||||||
|
|
||||||
stdout_handler = logging.StreamHandler(sys.stdout)
|
stdout_handler = logging.StreamHandler(sys.stdout)
|
||||||
stdout_handler.addFilter(self.StdoutFilter())
|
stdout_handler.addFilter(self.StdoutFilter())
|
||||||
stdout_handler.setLevel(logging.TRACE)
|
stdout_handler.setLevel(logging.TRACE)
|
||||||
|
@ -106,13 +104,6 @@ class DefaultLog(logging.Logger):
|
||||||
self.addHandler(stdout_handler)
|
self.addHandler(stdout_handler)
|
||||||
self.addHandler(stderr_handler)
|
self.addHandler(stderr_handler)
|
||||||
|
|
||||||
def filter(self, record):
|
|
||||||
"""Prefix messages with logger name"""
|
|
||||||
|
|
||||||
record.msg = self.name + ": " + str(record.msg)
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
def verbose(self, msg, *args, **kwargs):
|
def verbose(self, msg, *args, **kwargs):
|
||||||
self.log(logging.VERBOSE, msg, *args, **kwargs)
|
self.log(logging.VERBOSE, msg, *args, **kwargs)
|
||||||
|
|
||||||
|
@ -134,7 +125,7 @@ class TimestampingLog(DefaultLog):
|
||||||
|
|
||||||
|
|
||||||
class ParallelLog(DefaultLog):
|
class ParallelLog(DefaultLog):
|
||||||
FORMAT = '%(levelname)s: [%(process)d]: %(message)s'
|
FORMAT = '%(levelname)s: [%(process)d]: %(name)s: %(message)s'
|
||||||
|
|
||||||
|
|
||||||
class TimestampingParallelLog(TimestampingLog, ParallelLog):
|
class TimestampingParallelLog(TimestampingLog, ParallelLog):
|
||||||
|
|
Loading…
Reference in a new issue