Skip to content

Instantly share code, notes, and snippets.

@chiiph

chiiph/error.py

Created May 29, 2013
Embed
What would you like to do?
import sys
import logging
from functools import partial
from PySide import QtCore, QtGui
class Obj(QtCore.QObject, logging.Handler):
sig = QtCore.Signal(dict)
def __init__(self):
QtCore.QObject.__init__(self)
logging.Handler.__init__(self)
def emit(self, logRecord):
# This is intended to be logging.Handler
# implementation of emit, not the QObject one
self.sig.emit({"a":123, "b":321})
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
handler = Obj()
logger = logging.getLogger(name='test')
logger.setLevel(logging.DEBUG)
logger.addHandler(handler)
w = QtGui.QWidget()
b = QtGui.QPushButton(w)
b.clicked.connect(partial(logger.debug, "ASD"))
w.show()
app.exec_()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.