From 786dc14057e994b7e9a3598a2da954af5de85997 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 16 Oct 2015 20:07:31 +0800 Subject: [PATCH] protocols/logging: fix split, warn on format errors --- artiq/protocols/logging.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/artiq/protocols/logging.py b/artiq/protocols/logging.py index 44376da7c..ae2d5a0e2 100644 --- a/artiq/protocols/logging.py +++ b/artiq/protocols/logging.py @@ -5,6 +5,7 @@ from artiq.protocols.asyncio_server import AsyncioServer from artiq.tools import TaskObject +logger = logging.getLogger(__name__) _fwd_logger = logging.getLogger("fwd") @@ -59,13 +60,17 @@ class Server(AsyncioServer): except: return line = line[:-1] - linesplit = line.split(":", 4) + linesplit = line.split(":", 3) if len(linesplit) != 4: + logger.warning("received improperly formatted message, " + "dropping connection") return source, level, name, message = linesplit try: level = int(level) except: + logger.warning("received improperly formatted level, " + "dropping connection") return log_with_name(name, level, message, extra={"source": source})