mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
Do not color logger message
This commit is contained in:
parent
4488cc3960
commit
0b97509a74
@ -34,7 +34,7 @@ class ColouredFormatter(logging.Formatter):
|
||||
message = super().format(record)
|
||||
|
||||
if not colour:
|
||||
return message
|
||||
return message.replace("#RESET#", "")
|
||||
|
||||
level_no = record.levelno
|
||||
if level_no >= logging.CRITICAL:
|
||||
@ -50,6 +50,7 @@ class ColouredFormatter(logging.Formatter):
|
||||
else:
|
||||
colour = self.RESET
|
||||
|
||||
message = message.replace("#RESET#", self.RESET)
|
||||
message = '{colour}{message}{reset}'.format(colour=colour, message=message, reset=self.RESET)
|
||||
|
||||
return message
|
||||
@ -76,7 +77,7 @@ class ColouredStreamHandler(logging.StreamHandler):
|
||||
def init_logger(level,quiet=False):
|
||||
|
||||
stream_handler = ColouredStreamHandler(sys.stdout)
|
||||
stream_handler.formatter = ColouredFormatter("{asctime} {levelname:8} {filename}:{lineno} {message}", "%Y-%m-%d %H:%M:%S", "{")
|
||||
stream_handler.formatter = ColouredFormatter("{asctime} {levelname:8} {filename}:{lineno}#RESET# {message}", "%Y-%m-%d %H:%M:%S", "{")
|
||||
if quiet:
|
||||
stream_handler.addFilter(logging.Filter(name="user_facing"))
|
||||
logging.getLogger('user_facing').propagate = False
|
||||
|
Loading…
Reference in New Issue
Block a user