forked from M-Labs/artiq
1
0
Fork 0

protocols/logging: document, take level numbers for consistency with master publish

This commit is contained in:
Sebastien Bourdeauducq 2015-10-16 18:34:37 +08:00
parent f3e61e265c
commit c0796249b3
1 changed files with 8 additions and 3 deletions

View File

@ -38,6 +38,11 @@ _init_string = b"ARTIQ logging\n"
class Server(AsyncioServer):
"""Remote logging TCP server.
Takes one log entry per line, in the format:
source:levelno:name:message
"""
async def _handle_connection_cr(self, reader, writer):
try:
line = await reader.readline()
@ -56,10 +61,10 @@ class Server(AsyncioServer):
linesplit = line.split(":", 4)
if len(linesplit) != 4:
return
source, levelname, name, message = linesplit
source, level, name, message = linesplit
try:
level = _name_to_level[levelname]
except KeyError:
level = int(level)
except:
return
log_with_name(name, level, message,
extra={"source": source})