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): 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): async def _handle_connection_cr(self, reader, writer):
try: try:
line = await reader.readline() line = await reader.readline()
@ -56,10 +61,10 @@ class Server(AsyncioServer):
linesplit = line.split(":", 4) linesplit = line.split(":", 4)
if len(linesplit) != 4: if len(linesplit) != 4:
return return
source, levelname, name, message = linesplit source, level, name, message = linesplit
try: try:
level = _name_to_level[levelname] level = int(level)
except KeyError: except:
return return
log_with_name(name, level, message, log_with_name(name, level, message,
extra={"source": source}) extra={"source": source})