-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.. _logging: | ||
|
||
******* | ||
Logging | ||
******* | ||
|
||
Tweepy uses the :mod:`logging` standard library module. | ||
|
||
The simplest way to set up logging is using :func:`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 :mod:`logging` module, directly to the console. | ||
|
||
The optional ``level`` argument can be any | ||
:ref:`logging level <python:levels>`. | ||
|
||
To configure logging for Tweepy (or each individual library) specifically, you | ||
can use :func:`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 :mod:`logging` module. | ||
For more information, see the | ||
:doc:`logging module documentation <python:library/logging>` and | ||
:doc:`tutorials <python:howto/logging>`. |