forked from M-Labs/artiq
1
0
Fork 0

logging, aqctl_corelog: recognize log level TRACE.

This commit is contained in:
whitequark 2017-08-31 13:12:22 +00:00
parent 4883eea252
commit c9e2a085ec
2 changed files with 13 additions and 7 deletions

View File

@ -38,15 +38,16 @@ async def get_logs(host):
for line in log.decode("utf-8").splitlines(): for line in log.decode("utf-8").splitlines():
m = re.match(r"^\[.+?\] (TRACE|DEBUG| INFO| WARN|ERROR)\((.+?)\): (.+)$", line) m = re.match(r"^\[.+?\] (TRACE|DEBUG| INFO| WARN|ERROR)\((.+?)\): (.+)$", line)
if m.group(1) == 'TRACE': levelname = m.group(1)
continue if levelname == 'TRACE':
elif m.group(1) == 'DEBUG': level = logging.TRACE
elif levelname == 'DEBUG':
level = logging.DEBUG level = logging.DEBUG
elif m.group(1) == ' INFO': elif levelname == ' INFO':
level = logging.INFO level = logging.INFO
elif m.group(1) == ' WARN': elif levelname == ' WARN':
level = logging.WARN level = logging.WARN
elif m.group(1) == 'ERROR': elif levelname == 'ERROR':
level = logging.ERROR level = logging.ERROR
name = 'firmware.' + m.group(2).replace('::', '.') name = 'firmware.' + m.group(2).replace('::', '.')
text = m.group(3) text = m.group(3)
@ -63,7 +64,7 @@ def main():
server = Server({"corelog": PingTarget()}, None, True) server = Server({"corelog": PingTarget()}, None, True)
loop.run_until_complete(server.start(bind_address_from_args(args), args.port)) loop.run_until_complete(server.start(bind_address_from_args(args), args.port))
try: try:
multiline_log_config(logging.DEBUG) multiline_log_config(logging.TRACE)
loop.run_until_complete(server.wait_terminate()) loop.run_until_complete(server.wait_terminate())
finally: finally:
loop.run_until_complete(server.stop()) loop.run_until_complete(server.stop())

View File

@ -7,6 +7,10 @@ from artiq.protocols.asyncio_server import AsyncioServer
from artiq.tools import TaskObject, MultilineFormatter from artiq.tools import TaskObject, MultilineFormatter
logging.TRACE = 5
logging.addLevelName(logging.TRACE, 'TRACE')
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
_fwd_logger = logging.getLogger("fwd") _fwd_logger = logging.getLogger("fwd")
@ -23,6 +27,7 @@ _name_to_level = {
"WARNING": logging.WARNING, "WARNING": logging.WARNING,
"INFO": logging.INFO, "INFO": logging.INFO,
"DEBUG": logging.DEBUG, "DEBUG": logging.DEBUG,
"TRACE": logging.TRACE,
} }