Skip to content

Commit c6ebe4a

Browse files
committed
Add documentation on logging and add classifiers to setup.py
1 parent ade102d commit c6ebe4a

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-1
lines changed

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,5 @@ Contents
7070
task
7171
wal
7272
errors
73+
logging
7374
classes

docs/logging.rst

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
.. _logging-page:
2+
3+
Logging
4+
-------
5+
6+
By default, :class:`arango.ArangoClient` logs API call history using the
7+
``arango`` logger at ``logging.DEBUG`` level.
8+
9+
Here is an example showing how the logger can be enabled and customized:
10+
11+
.. code-block:: python
12+
13+
import logging
14+
15+
from arango import ArangoClient
16+
17+
logger = logging.getLogger('arango')
18+
19+
# Set the logging level
20+
logger.setLevel(logging.DEBUG)
21+
22+
# Attach a custom handler
23+
handler = logging.StreamHandler()
24+
formatter = logging.Formatter('[%(levelname)s] %(message)s')
25+
handler.setFormatter(formatter)
26+
logger.addHandler(handler)
27+
28+
# Initialize and use the client to see the changes
29+
client = ArangoClient(
30+
username='root',
31+
password='',
32+
enable_logging=True
33+
)
34+
client.databases()
35+
client.endpoints()
36+
client.log_levels()
37+
38+
39+
The logging output for above would look something like this:
40+
41+
.. code-block:: bash
42+
43+
[DEBUG] GET http://127.0.0.1:8529/_db/_system/_api/database 200
44+
[DEBUG] GET http://127.0.0.1:8529/_db/_system/_api/endpoint 200
45+
[DEBUG] GET http://127.0.0.1:8529/_db/_system/_admin/log/level 200
46+
47+
48+
In order to see the full request information, turn on logging for the requests_
49+
library which **python-arango** uses under the hood:
50+
51+
.. _requests: https://github.com/kennethreitz/requests
52+
53+
.. code-block:: python
54+
55+
import requests
56+
import logging
57+
58+
try: # for Python 3
59+
from http.client import HTTPConnection
60+
except ImportError:
61+
from httplib import HTTPConnection
62+
HTTPConnection.debuglevel = 1
63+
64+
logging.basicConfig()
65+
logging.getLogger().setLevel(logging.DEBUG)
66+
requests_log = logging.getLogger("requests.packages.urllib3")
67+
requests_log.setLevel(logging.DEBUG)
68+
requests_log.propagate = True

setup.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,19 @@
1313
url='https://github.com/joowani/python-arango',
1414
packages=find_packages(),
1515
include_package_data=True,
16-
install_requires=['requests', 'six']
16+
install_requires=['requests', 'six'],
17+
classifiers=[
18+
'Intended Audience :: Developers',
19+
'Intended Audience :: End Users/Desktop',
20+
'Intended Audience :: Information Technology',
21+
'License :: OSI Approved :: MIT License',
22+
'Operating System :: MacOS',
23+
'Operating System :: Microsoft :: Windows',
24+
'Operating System :: POSIX',
25+
'Operating System :: Unix',
26+
'Programming Language :: Python',
27+
'Programming Language :: Python :: 2',
28+
'Programming Language :: Python :: 3',
29+
'Topic :: Documentation :: Sphinx'
30+
]
1731
)

0 commit comments

Comments
 (0)