Python 从代码运行时禁用类自动调试模式

Python 从代码运行时禁用类自动调试模式,python,Python,输出 from my_stream import custom_stream stream = custom_stream() for i in os.listdir('html_files'): stream.get_im(i) 我在custom\u stream类中没有任何日志记录,运行时如何将其静音 自定义\u流使用selenium获取图像,然后PIL进行一些图像处理尝试: 如果这不起作用,请制作一个我不确定,试试我的解决方案,如果它起作用,将我的解决方案标记为已接受,如果它不起

输出

from my_stream import custom_stream
stream = custom_stream()
for i in os.listdir('html_files'):
    stream.get_im(i)
我在
custom\u stream
类中没有任何日志记录,运行时如何将其静音

自定义\u流使用
selenium
获取图像,然后
PIL
进行一些图像处理

尝试:


如果这不起作用,请制作一个

我不确定,试试我的解决方案,如果它起作用,将我的解决方案标记为已接受,如果它不起作用,我们将继续查找
logger=logging.getLogger('selenium.webdriver.remote.remote\u connection')logger.setLevel(logging.WARNING)
这将禁用大多数消息no,还没有,使用此解决方案打印的消息更少,但仍然提供了调试功能。您还可以尝试禁用以下记录器:“urllib3.connectionpool”和“PIL.PngImagePlugin”是的,这是修复方法(我使用的每个模块上都有记录器警告),非常感谢。
l2020-06-25 09:01:54 [urllib3.connectionpool] DEBUG: http://127.0.0.1:33987 "POST /session/6d9d82226d6f55d263f86812c4893958/element HTTP/1.1" 200 88
2020-06-25 09:01:54 [selenium.webdriver.remote.remote_connection] DEBUG: Finished Request
2020-06-25 09:01:54 [selenium.webdriver.remote.remote_connection] DEBUG: GET http://127.0.0.1:33987/session/6d9d82226d6f55d263f86812c4893958/element/e5d1254d-6dbf-4539-a4bc-6c533fe8918d/screenshot {"id": "e5d1254d-6dbf-4539-a4bc-6c533fe8918d"}
2020-06-25 09:01:55 [urllib3.connectionpool] DEBUG: http://127.0.0.1:33987 "GET /session/6d9d82226d6f55d263f86812c4893958/element/e5d1254d-6dbf-4539-a4bc-6c533fe8918d/screenshot HTTP/1.1" 200 3397480
2020-06-25 09:01:55 [selenium.webdriver.remote.remote_connection] DEBUG: Finished Request
2020-06-25 09:01:55 [PIL.PngImagePlugin] DEBUG: STREAM b'IHDR' 16 13
2020-06-25 09:01:55 [PIL.PngImagePlugin] DEBUG: STREAM b'sRGB' 41 1
2020-06-25 09:01:55 [PIL.PngImagePlugin] DEBUG: STREAM b'IDAT' 54 8192
2020-06-25 09:01:56 [selenium.webdriver.remote.remote_connection] DEBUG: POST http://127.0.0.1:50869/session/29bee4ee8c77c76473d09818581277ab/url {"url": "file:///home/usr/html_files/172e63.html"}
import logging
from selenium.webdriver.remote.remote_connection import LOGGER
LOGGER.setLevel(logging.WARNING)