forked from M-Labs/artiq
1
0
Fork 0

coredevice/comm_serial: use lazy formatting in logging

This commit is contained in:
Sebastien Bourdeauducq 2015-03-27 18:54:19 +01:00
parent f4cb97b709
commit 3108ffeef6
1 changed files with 10 additions and 10 deletions

View File

@ -75,7 +75,7 @@ class Comm(AutoDB):
def set_baud(self, baud):
self.port.baudrate = baud
self.port.flush()
logger.debug("baud rate set to {}".format(baud))
logger.debug("baud rate set to %d", baud)
def set_remote_baud(self, baud):
_write_exactly(self.port, struct.pack(
@ -89,7 +89,7 @@ class Comm(AutoDB):
else:
# FIXME: when loading immediately after a board reset,
# we erroneously get some zeros back.
logger.warning("unexpected sync character: {:02x}".format(int(recv)))
logger.warning("unexpected sync character: %02x", recv)
handshake = 0
if recv != 0:
fails += 1
@ -112,9 +112,9 @@ class Comm(AutoDB):
for i in range(length):
(c, ) = struct.unpack("B", _read_exactly(self.port, 1))
log_message += chr(c)
logger.info("DEVICE LOG: " + log_message)
logger.info("DEVICE LOG: %s", log_message)
else:
logger.debug("message received: {!r}".format(msg))
logger.debug("message received: %r", msg)
return msg
def get_runtime_env(self):
@ -134,7 +134,7 @@ class Comm(AutoDB):
">lBB", _read_exactly(self.port, 6))
ref_freq = (ref_freq_i + Fraction(ref_freq_fn, ref_freq_fd))*units.Hz
ref_period = 1/ref_freq
logger.debug("environment ref_period: {}".format(ref_period))
logger.debug("environment ref_period: %s", ref_period)
return Environment(ref_period)
def switch_clock(self, external):
@ -160,7 +160,7 @@ class Comm(AutoDB):
">lbl", 0x5a5a5a5a, _H2DMsgType.RUN_KERNEL.value, len(kname)))
for c in kname:
_write_exactly(self.port, struct.pack(">B", ord(c)))
logger.debug("running kernel: {}".format(kname))
logger.debug("running kernel: %s", kname)
def _receive_rpc_values(self):
r = []
@ -188,11 +188,11 @@ class Comm(AutoDB):
def _serve_rpc(self, rpc_map, user_exception_map):
rpc_num = struct.unpack(">h", _read_exactly(self.port, 2))[0]
args = self._receive_rpc_values()
logger.debug("rpc service: {} ({})".format(rpc_num, args))
eid, r = self.rpc_wrapper.run_rpc(user_exception_map, rpc_map[rpc_num], args)
logger.debug("rpc service: %d %r", rpc_num, args)
eid, r = self.rpc_wrapper.run_rpc(
user_exception_map, rpc_map[rpc_num], args)
_write_exactly(self.port, struct.pack(">ll", eid, r))
logger.debug("rpc service: {} ({}) == {}".format(
rpc_num, args, r))
logger.debug("rpc service: %d %r == %r", rpc_num, args, r)
def _serve_exception(self, user_exception_map):
eid, p0, p1, p2 = struct.unpack(">lqqq",