I can set the log level for everything coming from the requests package in the usual fashion:
logging.getLogger('requests').setLevel(...)
But I have a requests.Session
which is especially chatty, and I want to set the log level separately for requests originating from that session. The following code sample shows what I'd like to do (the line marked XX).
import requests
import logging
requests.get('https://example.com/').close()
# log output:
# 2020-04-13 19:01:44 [DEBUG] Starting new HTTPS connection (1): example.com:443
# 2020-04-13 19:01:44 [DEBUG] https://example.com:443 "GET / HTTP/1.1" 200 648
s = requests.Session()
s.logger.setLevel(logging.INFO) # XX this doesn't exist, but illustrates what I want to do
s.get('https://example.com/').close() # nothing should be logged