From 472f412c6c15501280ac576ae2decc91e2812ed2 Mon Sep 17 00:00:00 2001 From: Carlos Cueto Date: Mon, 17 Jun 2024 14:34:35 +0100 Subject: [PATCH] Improve comms debug print --- mosaic/comms/comms.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/mosaic/comms/comms.py b/mosaic/comms/comms.py index 7b26350c..dc3ac16c 100644 --- a/mosaic/comms/comms.py +++ b/mosaic/comms/comms.py @@ -771,19 +771,20 @@ def _process_send(self, method, cmd=None, reply=False, **kwargs): 'cmd': cmd, } + msg = serialise(msg) + msg_size = sizeof(msg) + if not method.startswith('log') and not method.startswith('update_monitored_node'): if method == 'cmd': method = '%s:%s.%s' % (method, cmd['type'], cmd['method']) - self.logger.debug('Sending cmd %s %s to %s (%s) from %s' % (method, cmd['method'], - self.uid, cmd['uid'], - self._runtime.uid)) + self.logger.debug('Sending cmd %s %s to %s (%s) from %s ' + '(size %.2f MB)' % (method, cmd['method'], self.uid, cmd['uid'], + self._runtime.uid, msg_size/1024**2)) else: - self.logger.debug('Sending msg %s to %s from %s' % (method, self.uid, - self._runtime.uid)) - - msg = serialise(msg) - msg_size = sizeof(msg) + self.logger.debug('Sending msg %s to %s from %s ' + '(size %.2f MB)' % (method, self.uid, self._runtime.uid, + msg_size/1024**2)) compression = [] compressed_msg = []