对于这个小例子,
from PySide6 import QtCore, QtWidgets, QtWebEngineWidgets
# or
# from PySide2 import QtCore, QtWidgets, QtWebEngineWidgets
class BetterWebView(QtWebEngineWidgets.QWebEngineView):
def __init__(self):
super().__init__()
self.load(QtCore.QUrl())
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
view = BetterWebView()
view.load(QtCore.QUrl("https://www.qt.io"))
view.show()
sys.exit(app.exec_())
运行后,我得到了一个错误列表,例如
[12248:2260:0721/112136.109:ERROR:ssl_client_socket_impl.cc(975)] handshake failed; returned -1, SSL error code 1, net_error -107
[12248:2260:0721/112136.110:ERROR:ssl_client_socket_impl.cc(975)] handshake failed; returned -1, SSL error code 1, net_error -107
js: While parsing speculation rules: A rule contains an unknown key: "eagerness".
[12248:2260:0721/112136.411:ERROR:ssl_client_socket_impl.cc(975)] handshake failed; returned -1, SSL error code 1, net_error -107
[12248:2260:0721/112136.412:ERROR:ssl_client_socket_impl.cc(975)] handshake failed; returned -1, SSL error code 1, net_error -107
[12248:2260:0721/112136.414:ERROR:ssl_client_socket_impl.cc(975)] handshake failed; returned -1, SSL error code 1, net_error -107
[12248:2260:0721/112136.416:ERROR:ssl_client_socket_impl.cc(975)] handshake failed; returned -1, SSL error code 1, net_error -107
[12248:2260:0721/112136.443:ERROR:ssl_client_socket_impl.cc(975)] handshake failed; returned -1, SSL error code 1, net_error -107
[12248:2260:0721/112136.444:ERROR:ssl_client_socket_impl.cc(975)] handshake failed; returned -1, SSL error code 1, net_error -107
[12248:2260:0721/112136.758:ERROR:ssl_client_socket_impl.cc(975)] handshake failed; returned -1, SSL error code 1, net_error -107
[12248:2260:0721/112136.760:ERROR:ssl_client_socket_impl.cc(975)] handshake failed; returned -1, SSL error code 1, net_error -107
[12248:2260:0721/112141.494:ERROR:ssl_client_socket_impl.cc(975)] handshake failed; returned -1, SSL error code 1, net_error -107
[12248:2260:0721/112141.494:ERROR:ssl_client_socket_impl.cc(975)] handshake failed; returned -1, SSL error code 1, net_error -107
[12248:2260:0721/112141.497:ERROR:ssl_client_socket_impl.cc(975)] handshake failed; returned -1, SSL error code 1, net_error -107
[12248:2260:0721/112141.498:ERROR:ssl_client_socket_impl.cc(975)] handshake failed; returned -1, SSL error code 1, net_error -107
它们对我的情况没有帮助,我想知道如何抑制(不显示)它们?
有两种方法可以停止记录,
os.environ["QTWEBENGINE_CHROMIUM_FLAGS"] = "--log-level=3"
或
sys.argv.extend(['--webEngineArgs',"--log-level=3"])