pythonpyqt6qwebengineview

How to disable QWebEngineView logging with webEngineContextLog?


I'm using a QWebEngineView in my application. After upgrading to PyQt6 it has started to output the logging information shown below. How can I disable these messages?

I have found the code that is emitting them here: logContext

It looks like I have to change the output of webEngineContextLog.isInfoEnabled() to False, but it is unclear how to achieve this.

Logging output:

qt.webenginecontext:

GL Type: desktop
Surface Type: OpenGL
Surface Profile: CompatibilityProfile
Surface Version: 4.6
QSG RHI Backend: OpenGL
Using Supported QSG Backend: yes
Using Software Dynamic GL: no
Using Multithreaded OpenGL: yes

Init Parameters:
  *  application-name python
  *  browser-subprocess-path C:\Users\xxx\miniconda3\envs\xxx\lib\site-packages\PyQt6\Qt6\bin\QtWebEngineProcess.exe
  *  create-default-gl-context
  *  disable-es3-gl-context
  *  disable-features ConsolidatedMovementXY,InstalledApp,BackgroundFetch,WebOTP,WebPayments,WebUSB,PictureInPicture
  *  disable-speech-api
  *  enable-features NetworkServiceInProcess,TracingServiceInProcess
  *  enable-threaded-compositing
  *  in-process-gpu
  *  use-gl desktop

Minimal code to reproduce:

from PyQt6.QtWidgets import QApplication
from PyQt6.QtWebEngineWidgets import QWebEngineView
app = QApplication(['test'])
QWebEngineView().settings()

Solution

  • I stumbled over the same problem today when I tried to integrate a silent unit test into my current project.

    After a quick investigation and having a look at how it is logged here in the function logContext, I came up with the following solution which works fine for me:

    from PySide6.QtCore import QUrl, QLoggingCategory
    from PySide6.QtWidgets import (QApplication, QMainWindow)
    from PySide6.QtWebEngineWidgets import QWebEngineView
    
    web_engine_context_log = QLoggingCategory("qt.webenginecontext")
    web_engine_context_log.setFilterRules("*.info=false")
    web_view = QWebEngineView()