Use repr() for IPC logging messages

This commit is contained in:
Florian Bruhin 2016-07-28 07:06:53 +02:00
parent 285cf105f0
commit caab826e8a

View File

@ -299,7 +299,7 @@ class IPCServer(QObject):
try: try:
decoded = data.decode('utf-8') decoded = data.decode('utf-8')
except UnicodeDecodeError: except UnicodeDecodeError:
log.ipc.error("invalid utf-8: {}".format(binascii.hexlify(data))) log.ipc.error("invalid utf-8: {!r}".format(binascii.hexlify(data)))
self._handle_invalid_data() self._handle_invalid_data()
return return
@ -354,7 +354,7 @@ class IPCServer(QObject):
while self._socket is not None and self._socket.canReadLine(): while self._socket is not None and self._socket.canReadLine():
data = bytes(self._socket.readLine()) data = bytes(self._socket.readLine())
self.got_raw.emit(data) self.got_raw.emit(data)
log.ipc.debug("Read from socket 0x{:x}: {}".format( log.ipc.debug("Read from socket 0x{:x}: {!r}".format(
id(self._socket), data)) id(self._socket), data))
self._handle_data(data) self._handle_data(data)
self._timer.start() self._timer.start()
@ -482,7 +482,7 @@ def send_to_running_instance(socketname, command, target_arg, *,
json_data['cwd'] = cwd json_data['cwd'] = cwd
line = json.dumps(json_data) + '\n' line = json.dumps(json_data) + '\n'
data = line.encode('utf-8') data = line.encode('utf-8')
log.ipc.debug("Writing: {}".format(data)) log.ipc.debug("Writing: {!r}".format(data))
socket.writeData(data) socket.writeData(data)
socket.waitForBytesWritten(WRITE_TIMEOUT) socket.waitForBytesWritten(WRITE_TIMEOUT)
if socket.error() != QLocalSocket.UnknownSocketError: if socket.error() != QLocalSocket.UnknownSocketError: