Skip to content

Commit

Permalink
Add documentation on logging and add classifiers to setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
joowani committed Apr 20, 2017
1 parent 328d8be commit 61dcb15
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/index.rst
Expand Up @@ -70,4 +70,5 @@ Contents
task
wal
errors
logging
classes
68 changes: 68 additions & 0 deletions docs/logging.rst
@@ -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
16 changes: 15 additions & 1 deletion setup.py
Expand Up @@ -13,5 +13,19 @@
url='https://github.com/joowani/python-arango',
packages=find_packages(),
include_package_data=True,
install_requires=['requests', 'six']
install_requires=['requests', 'six'],
classifiers=[
'Intended Audience :: Developers',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Information Technology',
'License :: OSI Approved :: MIT License',
'Operating System :: MacOS',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: Unix',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: Documentation :: Sphinx'
]
)

0 comments on commit 61dcb15

Please sign in to comment.