[PR]
Logging
Tweepy uses the logging
standard library module.
The simplest way to set up logging is using logging.basicConfig()
, e.g.:
import logging
logging.basicConfig(level=logging.DEBUG)
This will output logging from Tweepy, as well as other libraries (like Tweepy's
dependencies) that use the logging
module, directly to the console.
The optional level
argument can be any
logging level.
To configure logging for Tweepy (or each individual library) specifically, you
can use logging.getLogger()
to retrieve the logger for the library. For
example:
import logging
logger = logging.getLogger("tweepy")
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename="tweepy.log")
logger.addHandler(handler)
More advanced configuration is possible with the logging
module.
For more information, see the
logging module documentation and
tutorials.