Skip to content

Commit 3108ffe

Browse files
committedMar 27, 2015
coredevice/comm_serial: use lazy formatting in logging
1 parent f4cb97b commit 3108ffe

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed
 

‎artiq/coredevice/comm_serial.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def build(self):
7575
def set_baud(self, baud):
7676
self.port.baudrate = baud
7777
self.port.flush()
78-
logger.debug("baud rate set to {}".format(baud))
78+
logger.debug("baud rate set to %d", baud)
7979

8080
def set_remote_baud(self, baud):
8181
_write_exactly(self.port, struct.pack(
@@ -89,7 +89,7 @@ def set_remote_baud(self, baud):
8989
else:
9090
# FIXME: when loading immediately after a board reset,
9191
# we erroneously get some zeros back.
92-
logger.warning("unexpected sync character: {:02x}".format(int(recv)))
92+
logger.warning("unexpected sync character: %02x", recv)
9393
handshake = 0
9494
if recv != 0:
9595
fails += 1
@@ -112,9 +112,9 @@ def _get_device_msg(self):
112112
for i in range(length):
113113
(c, ) = struct.unpack("B", _read_exactly(self.port, 1))
114114
log_message += chr(c)
115-
logger.info("DEVICE LOG: " + log_message)
115+
logger.info("DEVICE LOG: %s", log_message)
116116
else:
117-
logger.debug("message received: {!r}".format(msg))
117+
logger.debug("message received: %r", msg)
118118
return msg
119119

120120
def get_runtime_env(self):
@@ -134,7 +134,7 @@ def get_runtime_env(self):
134134
">lBB", _read_exactly(self.port, 6))
135135
ref_freq = (ref_freq_i + Fraction(ref_freq_fn, ref_freq_fd))*units.Hz
136136
ref_period = 1/ref_freq
137-
logger.debug("environment ref_period: {}".format(ref_period))
137+
logger.debug("environment ref_period: %s", ref_period)
138138
return Environment(ref_period)
139139

140140
def switch_clock(self, external):
@@ -160,7 +160,7 @@ def run(self, kname):
160160
">lbl", 0x5a5a5a5a, _H2DMsgType.RUN_KERNEL.value, len(kname)))
161161
for c in kname:
162162
_write_exactly(self.port, struct.pack(">B", ord(c)))
163-
logger.debug("running kernel: {}".format(kname))
163+
logger.debug("running kernel: %s", kname)
164164

165165
def _receive_rpc_values(self):
166166
r = []
@@ -188,11 +188,11 @@ def _receive_rpc_values(self):
188188
def _serve_rpc(self, rpc_map, user_exception_map):
189189
rpc_num = struct.unpack(">h", _read_exactly(self.port, 2))[0]
190190
args = self._receive_rpc_values()
191-
logger.debug("rpc service: {} ({})".format(rpc_num, args))
192-
eid, r = self.rpc_wrapper.run_rpc(user_exception_map, rpc_map[rpc_num], args)
191+
logger.debug("rpc service: %d %r", rpc_num, args)
192+
eid, r = self.rpc_wrapper.run_rpc(
193+
user_exception_map, rpc_map[rpc_num], args)
193194
_write_exactly(self.port, struct.pack(">ll", eid, r))
194-
logger.debug("rpc service: {} ({}) == {}".format(
195-
rpc_num, args, r))
195+
logger.debug("rpc service: %d %r == %r", rpc_num, args, r)
196196

197197
def _serve_exception(self, user_exception_map):
198198
eid, p0, p1, p2 = struct.unpack(">lqqq",

0 commit comments

Comments
 (0)
Please sign in to comment.