aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-09-27 11:54:10 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-09-27 12:38:20 -0400
commit8f8951b4c1caf9bf5667a22b146ba22d184208e1 (patch)
tree03c17696ff2fdb67589be7c1f2dc3cbf6c240eae /klippy
parent6e5bcc69bc3ec6997212605ec43420997e4ed731 (diff)
downloadkutter-8f8951b4c1caf9bf5667a22b146ba22d184208e1.tar.gz
kutter-8f8951b4c1caf9bf5667a22b146ba22d184208e1.tar.xz
kutter-8f8951b4c1caf9bf5667a22b146ba22d184208e1.zip
serialhdl: Make dump_debug() output atomic
Build a single (very large) logging message with the debug state. This prevents the output from being fragmented. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rw-r--r--klippy/mcu.py4
-rw-r--r--klippy/serialhdl.py14
2 files changed, 10 insertions, 8 deletions
diff --git a/klippy/mcu.py b/klippy/mcu.py
index f618f582..14bf5817 100644
--- a/klippy/mcu.py
+++ b/klippy/mcu.py
@@ -451,8 +451,8 @@ class MCU:
return
self._is_shutdown = True
self._shutdown_msg = msg = params['#msg']
- logging.info("%s: %s", params['#name'], self._shutdown_msg)
- self._serial.dump_debug()
+ logging.info("MCU '%s' %s: %s\n%s", self._name, params['#name'],
+ self._shutdown_msg, self._serial.dump_debug())
prefix = "MCU '%s' shutdown: " % (self._name,)
if params['#name'] == 'is_shutdown':
prefix = "Previous MCU '%s' shutdown: " % (self._name,)
diff --git a/klippy/serialhdl.py b/klippy/serialhdl.py
index ed7b3274..411c77b1 100644
--- a/klippy/serialhdl.py
+++ b/klippy/serialhdl.py
@@ -141,26 +141,28 @@ class SerialReader:
self.ffi_lib.serialqueue_free_commandqueue)
# Dumping debug lists
def dump_debug(self):
- logging.info("Dumping serial stats: %s"
- , self.stats(self.reactor.monotonic()))
+ out = []
+ out.append("Dumping serial stats: %s" % (
+ self.stats(self.reactor.monotonic()),))
sdata = self.ffi_main.new('struct pull_queue_message[1024]')
rdata = self.ffi_main.new('struct pull_queue_message[1024]')
scount = self.ffi_lib.serialqueue_extract_old(
self.serialqueue, 1, sdata, len(sdata))
rcount = self.ffi_lib.serialqueue_extract_old(
self.serialqueue, 0, rdata, len(rdata))
- logging.info("Dumping send queue %d messages" % (scount,))
+ out.append("Dumping send queue %d messages" % (scount,))
for i in range(scount):
msg = sdata[i]
cmds = self.msgparser.dump(msg.msg[0:msg.len])
- logging.info("Sent %d %f %f %d: %s" % (
+ out.append("Sent %d %f %f %d: %s" % (
i, msg.receive_time, msg.sent_time, msg.len, ', '.join(cmds)))
- logging.info("Dumping receive queue %d messages" % (rcount,))
+ out.append("Dumping receive queue %d messages" % (rcount,))
for i in range(rcount):
msg = rdata[i]
cmds = self.msgparser.dump(msg.msg[0:msg.len])
- logging.info("Receive: %d %f %f %d: %s" % (
+ out.append("Receive: %d %f %f %d: %s" % (
i, msg.receive_time, msg.sent_time, msg.len, ', '.join(cmds)))
+ return '\n'.join(out)
# Default message handlers
def handle_unknown(self, params):
logging.warn("Unknown message type %d: %s" % (