Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation on logging and add classifiers to setup.py
- Loading branch information
Showing
3 changed files
with
84 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,4 +70,5 @@ Contents | |
task | ||
wal | ||
errors | ||
logging | ||
classes |
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,68 @@ | ||
.. _logging-page: | ||
|
||
Logging | ||
------- | ||
|
||
By default, :class:`arango.ArangoClient` logs API call history using the | ||
``arango`` logger at ``logging.DEBUG`` level. | ||
|
||
Here is an example showing how the logger can be enabled and customized: | ||
|
||
.. code-block:: python | ||
import logging | ||
from arango import ArangoClient | ||
logger = logging.getLogger('arango') | ||
# Set the logging level | ||
logger.setLevel(logging.DEBUG) | ||
# Attach a custom handler | ||
handler = logging.StreamHandler() | ||
formatter = logging.Formatter('[%(levelname)s] %(message)s') | ||
handler.setFormatter(formatter) | ||
logger.addHandler(handler) | ||
# Initialize and use the client to see the changes | ||
client = ArangoClient( | ||
username='root', | ||
password='', | ||
enable_logging=True | ||
) | ||
client.databases() | ||
client.endpoints() | ||
client.log_levels() | ||
The logging output for above would look something like this: | ||
|
||
.. code-block:: bash | ||
[DEBUG] GET http://127.0.0.1:8529/_db/_system/_api/database 200 | ||
[DEBUG] GET http://127.0.0.1:8529/_db/_system/_api/endpoint 200 | ||
[DEBUG] GET http://127.0.0.1:8529/_db/_system/_admin/log/level 200 | ||
In order to see the full request information, turn on logging for the requests_ | ||
library which **python-arango** uses under the hood: | ||
|
||
.. _requests: https://github.com/kennethreitz/requests | ||
|
||
.. code-block:: python | ||
import requests | ||
import logging | ||
try: # for Python 3 | ||
from http.client import HTTPConnection | ||
except ImportError: | ||
from httplib import HTTPConnection | ||
HTTPConnection.debuglevel = 1 | ||
logging.basicConfig() | ||
logging.getLogger().setLevel(logging.DEBUG) | ||
requests_log = logging.getLogger("requests.packages.urllib3") | ||
requests_log.setLevel(logging.DEBUG) | ||
requests_log.propagate = True |
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