如何捕获所有控制台错误日志剧作家

mor*_*676 5 python playwright playwright-python

在此输入图像描述

我尝试了这一切,

page.on("console", lambda msg: print(f"error: {msg.text}") if msg.type == "error" else None)
page.on("console", lambda msg: print(msg.text))
page.on("pageerror", lambda exc: print(f"uncaught exception: {exc}"))
Run Code Online (Sandbox Code Playgroud)

没有任何作用

端子输出

python main.py 
/home/xxx/.local/lib/python3.9/site-packages/trio/_core/_multierror.py:511: RuntimeWarning: You seem to already have a custom sys.excepthook handler installed. I'll skip installing Trio's custom handler, but this means MultiErrors will not show full tracebacks.
  warnings.warn(
Run Code Online (Sandbox Code Playgroud)