Revision 16d7b9ff docs/developers/logging.rst
b/docs/developers/logging.rst | ||
---|---|---|
1 | 1 |
Logging |
2 | 2 |
======= |
3 | 3 |
|
4 |
Kamaki uses the standard Python logger package to log some of its |
|
5 |
functionality. |
|
4 |
Kamaki uses the standard Python logger package to log some of its functionality. |
|
6 | 5 |
|
7 |
All kamaki loggers are named or prefixed after the package they log, e.g. |
|
8 |
a logger at `kamaki/cli/argument.__init__.py` should be called
|
|
6 |
All kamaki loggers are named or prefixed after the package they log, e.g.,
|
|
7 |
a logger at `kamaki/cli/argument/__init__.py` should be called
|
|
9 | 8 |
`kamaki.cli.argument` whereas a logger at `kamaki/clients/conf.py` should be |
10 |
named `kamaki.clients/conf`. In `kamaki/clients/__init__.py` there are two
|
|
9 |
named `kamaki.clients.conf`. In `kamaki/clients/__init__.py` there are two
|
|
11 | 10 |
loggers that use the package name as prefix, and they detailed bellow. |
12 | 11 |
|
13 | 12 |
Monitor requests and responses |
14 | 13 |
------------------------------ |
15 | 14 |
|
16 | 15 |
The `kamaki.clients` logger contains two subloggers that monitor the HTTP |
17 |
communication of with the servers::
|
|
16 |
API calls::
|
|
18 | 17 |
|
19 | 18 |
kamaki.clients.send for kamaki requests to the server |
20 | 19 |
kamaki.clients.recv for server responses to kamaki |
21 | 20 |
|
22 | 21 |
These are the only loggers used for purposes other than mere debugging. Both |
23 | 22 |
loggers are defined in the CLI code and are used to (a) log HTTP communication |
24 |
to the log file as well as to (b) show users the HTTP requests and responses if
|
|
25 |
kamaki cli is called with options like "verbose" or "debug".
|
|
23 |
to the log file as well as to (b) show users the HTTP requests and responses in
|
|
24 |
"verbose" or "debug" modes.
|
|
26 | 25 |
|
27 | 26 |
Logger in external code |
28 | 27 |
----------------------- |
... | ... | |
68 | 67 |
< content-type: application/json; charset=UTF-8 |
69 | 68 |
< data size: 2425 |
70 | 69 |
|
71 |
.. note:: user token and http body content are not logged by default |
|
70 |
.. note:: user token and http body content are not logged by default. This can |
|
71 |
be switched on and off by modifing the *kamaki.client.Client.LOG_TOKEN* and |
|
72 |
*kamaki.client.Client.LOG_DATA* flags |
|
72 | 73 |
|
73 | 74 |
As a second example, let's suppose that we need to see only the http requests |
74 |
of the `pithos.list_objects()` method. We decide to print these to the console.
|
|
75 |
To achieve that goal, we should get a stream logger and deactivate it when we
|
|
76 |
do not need it anymore.
|
|
75 |
of the `pithos.list_objects()` method and print these to stdout. To achieve
|
|
76 |
that goal, we should get a stream logger and deactivate it when we do not need
|
|
77 |
it anymore. |
|
77 | 78 |
|
78 | 79 |
|
79 | 80 |
.. code-block:: python |
Also available in: Unified diff