spyoungtech / grequests

Requests + Gevent = <3
https://pypi.python.org/pypi/grequests
BSD 2-Clause "Simplified" License
4.46k stars 331 forks source link

Disable error printing on in terminal #41

Closed alibozorgkhan closed 10 years ago

alibozorgkhan commented 10 years ago

Hi, Is there anyway to turn the logging off? Errors like:

Timeout: (<requests.packages.urllib3.connectionpool.HTTPConnectionPool object at 0x1112bafd0>, 'Connection to 163.125.156.220 timed out. (connect timeout=10)') <Greenlet at 0x11117d9b0: <bound method AsyncRequest.send of <grequests.AsyncRequest object at 0x1112e7210>>(stream=False)> failed with Timeout

are written in terminal. I found http://stackoverflow.com/questions/11029717/how-do-i-disable-log-messages-from-the-requests-library to silent the log messeges of requests, but it doesn't work for grequests. Any ideas? thanx.

newmaniese commented 10 years ago

GRequests actually doesn't have any logging in it, so I believe what you are seeing are the logs from Requests. The stackoverflow post is showing you how to set the output log level to WARNING, you are seeing an error, which is higher and therefore emitted.

If you want no logs, there are lots of ways to do this better, but you can just do:

import logging
logging.disable(logging.CRITICAL)

This will discard all logging in Python in general.