1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 03:08:14 +00:00

Filter /settings from log

Fix #1026
This commit is contained in:
Julien Duponchelle 2017-05-12 10:48:43 +02:00
parent 18cfcaa081
commit 961dbb5162
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -98,6 +98,16 @@ class WinStreamHandler(logging.StreamHandler):
self.handleError(record)
class LogFilter:
"""
This filter some noise from the logs
"""
def filter(record):
if record.name == "aiohttp.access" and "/settings" in record.msg and "200" in record.msg:
return 0
return 1
def init_logger(level, logfile=None, quiet=False):
if logfile and len(logfile) > 0:
stream_handler = logging.FileHandler(logfile)
@ -111,5 +121,7 @@ def init_logger(level, logfile=None, quiet=False):
if quiet:
stream_handler.addFilter(logging.Filter(name="user_facing"))
logging.getLogger('user_facing').propagate = False
if level > logging.DEBUG:
stream_handler.addFilter(LogFilter)
logging.basicConfig(level=level, handlers=[stream_handler])
return logging.getLogger('user_facing')