forked from M-Labs/artiq
1
0
Fork 0

protocols/logging: fix split, warn on format errors

This commit is contained in:
Sebastien Bourdeauducq 2015-10-16 20:07:31 +08:00
parent 9e96a687e2
commit 786dc14057
1 changed files with 6 additions and 1 deletions

View File

@ -5,6 +5,7 @@ from artiq.protocols.asyncio_server import AsyncioServer
from artiq.tools import TaskObject from artiq.tools import TaskObject
logger = logging.getLogger(__name__)
_fwd_logger = logging.getLogger("fwd") _fwd_logger = logging.getLogger("fwd")
@ -59,13 +60,17 @@ class Server(AsyncioServer):
except: except:
return return
line = line[:-1] line = line[:-1]
linesplit = line.split(":", 4) linesplit = line.split(":", 3)
if len(linesplit) != 4: if len(linesplit) != 4:
logger.warning("received improperly formatted message, "
"dropping connection")
return return
source, level, name, message = linesplit source, level, name, message = linesplit
try: try:
level = int(level) level = int(level)
except: except:
logger.warning("received improperly formatted level, "
"dropping connection")
return return
log_with_name(name, level, message, log_with_name(name, level, message,
extra={"source": source}) extra={"source": source})