1

My script (created in 2017) requests a couple of URLs (response = requests.post(initial_url, data = data) and parses the response content. A few days ago, the script started printing out status information from the requests module:

Starting new HTTPS connection (1): url:443
url:443 "POST /login?url=https%3A//url HTTP/1.1" 302 202
Starting new HTTPS connection (1): second.url:443
second.url:443 "GET /path HTTP/1.1" 302 None
second.url:443 "GET /login?referer=path HTTP/1.1" 302 None
second.url:443 "GET /path HTTP/1.1" 200 None

I did not change anything in my code – why does requests act so verbose?

janeden
  • 381
  • 3
  • 11
  • 3
    Looks like something in your code or perhaps in an imported module has set the logging level to a low value. –  Apr 05 '21 at 14:01
  • Thanks – I found and removed the culprit (pyonepassword). – janeden Apr 06 '21 at 19:54

2 Answers2

0

Justin's comment answered my question.

janeden
  • 381
  • 3
  • 11
  • Please, share the solution so that it can help others (including myself) – emu Jan 19 '22 at 10:04
  • Module pyonepassword modified the log level for module requests (obviously a bug). I switched to a different 1Password module to solve the problem.. – janeden Jan 20 '22 at 13:55
0

The general answer is that requests use the logging module internally. As explained in "How do I disable log messages from the Requests library?", the log level can be changed:

# ...after everything else has been imported
import logging
logging.getLogger("requests").setLevel(logging.DEBUG)
emu
  • 1,597
  • 16
  • 20