Better invalid data logging

This commit is contained in:
Florian Bruhin 2014-10-13 22:51:11 +02:00
parent f9c2eb836f
commit 19be96b4a8

View File

@ -21,6 +21,7 @@
import json import json
import getpass import getpass
import binascii
from PyQt5.QtCore import pyqtSlot, QObject from PyQt5.QtCore import pyqtSlot, QObject
from PyQt5.QtNetwork import QLocalSocket, QLocalServer from PyQt5.QtNetwork import QLocalSocket, QLocalServer
@ -133,13 +134,14 @@ class IPCServer(QObject):
try: try:
decoded = data.decode('utf-8') decoded = data.decode('utf-8')
except UnicodeDecodeError: except UnicodeDecodeError:
log.ipc.error("Ignoring invalid UTF-8 IPC data.") log.ipc.error("Ignoring invalid IPC data.")
log.ipc.debug("invalid data: {}".format(binascii.hexlify(data)))
return return
try: try:
args = json.loads(decoded) args = json.loads(decoded)
except ValueError: except ValueError:
log.ipc.error("Ignoring invalid json IPC data '{}'.".format( log.ipc.error("Ignoring invalid IPC data.")
decoded)) log.ipc.debug("invalid json: {}".format(decoded.strip()))
return return
log.ipc.debug("Processing: {}".format(decoded)) log.ipc.debug("Processing: {}".format(decoded))
app = objreg.get('app') app = objreg.get('app')