我有一个 python 代码通过 googleapiclient API 从 google 驱动器下载文件。python代码使用logger来打印信息。我将基本日志级别设置为INFO。但是,调用 API 会产生一些记录器信息。具体来说,另一个不需要的记录器信息是:
2019-02-12 03:52:21,269 INFO URL being requested:
2019-02-12 03:52:21,091 INFO Starting new HTTP connection
2019-02-12 03:52:19,691 INFO Attempting refresh to obtain initial access_token
从我用谷歌搜索到的,logging.getLogger("requests").setLevel(logging.WARNING)似乎能够静音Starting new HTTP connection. 但我怎样才能让另外两个静音呢?
在 python aiohttp 中,我们可以在 inClientSession或 a (例如) 中设置超时session.get。https://docs.aiohttp.org/en/stable/client_quickstart.html
假设我们这样做
async with aiohttp.ClientSession(timeout=<customized timeout>) as session:
async with session.get(<url1>):
xxx
async with session.get(<url2>):
xxx
Run Code Online (Sandbox Code Playgroud)
该customized timeout是整个async with aiohttp.ClientSession()或每个async with session.get?