1

Some log output from Qt is controlled by the category logging (eg. The JavaScript console output on QWebEnginePage).

The QLoggingCategory in C++ can be used for that, but there isn't the same class in PyQt5.

Is there any way to control the category logging in PyQt5, or mute them all?

NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
Licht Takeuchi
  • 103
  • 1
  • 6
  • I don't understand the question - what do you mean with "control the category logging"? Could you show an example of what you'd do in C++? – The Compiler Jun 14 '16 at 07:12
  • You might want to contact PyQt [on their mailing list](https://www.riverbankcomputing.com/mailman/listinfo/pyqt) which is their primary support way. – NoDataDumpNoContribution Jun 14 '16 at 08:41

1 Answers1

0

Not a straight solution, but you can create something like this:

class MyPage (QtWebEngineWidgets.QWebEnginePage):
    def javaScriptConsoleMessage(self, level, message, lineNumber, sourceId):
        #Send the log entry to Python's logging or do whatever you want
        logging.info("level: {}, source: {}, "+
                 "line: {}, message: {}".format(level,
                                                sourceId,
                                               lineNumber,
                                               message))

Then replace the default page of the QWebEngineView:

self.page = MyPage(owner)
self.browser.setPage(self.page)