mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Yet another PEP 8 :)
This commit is contained in:
1 parent
7cf409c392
commit
bbee5f90a0
106 files changed
+9
-29
No files matched your search
@@ -31,6 +31,7 @@ class ColouredFormatter(logging.Formatter):
|
||||
PINK = '\x1b[35m'
|
||||
|
||||
def format(self, record, colour=False):
|
||||
|
||||
message = super().format(record)
|
||||
|
||||
if not colour:
|
||||
@@ -57,13 +58,16 @@ class ColouredFormatter(logging.Formatter):
|
||||
|
||||
|
||||
class ColouredStreamHandler(logging.StreamHandler):
|
||||
|
||||
def format(self, record, colour=False):
|
||||
|
||||
if not isinstance(self.formatter, ColouredFormatter):
|
||||
self.formatter = ColouredFormatter()
|
||||
|
||||
return self.formatter.format(record, colour)
|
||||
|
||||
def emit(self, record):
|
||||
|
||||
stream = self.stream
|
||||
try:
|
||||
msg = self.format(record, stream.isatty())
|
||||
@@ -74,7 +78,7 @@ class ColouredStreamHandler(logging.StreamHandler):
|
||||
self.handleError(record)
|
||||
|
||||
|
||||
def init_logger(level,quiet=False):
|
||||
def init_logger(level, quiet=False):
|
||||
|
||||
stream_handler = ColouredStreamHandler(sys.stdout)
|
||||
stream_handler.formatter = ColouredFormatter("{asctime} {levelname:8} {filename}:{lineno}#RESET# {message}", "%Y-%m-%d %H:%M:%S", "{")
|
||||
@@ -83,5 +87,3 @@ def init_logger(level,quiet=False):
|
||||
logging.getLogger('user_facing').propagate = False
|
||||
logging.basicConfig(level=level, handlers=[stream_handler])
|
||||
return logging.getLogger('user_facing')
|
||||
|
||||
|
||||
Reference in new issue
Block a user