class QtHandler(logging.Handler):

    def __init__(self):
        logging.Handler.__init__(self)

def emit(self, record):
    record = self.format(record)
XStream.stdout().write('{}\n'.format(record))
handler = QtHandler()
handler.setFormatter(logging.Formatter('%(levelname)s: %(message)s'))
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)
How to Redirect Logger Output into PyQt Text Widget