Skip to content

Commit 122c3ff

Browse files
<Vishal> Updated index.rst
1 parent 792a34d commit 122c3ff

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

docs/index.rst

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
DRF API Logger
2-
==============
2+
##############
33

44
|version| |Downloads| |image1| |Open Source| |Donate|
55

@@ -32,7 +32,7 @@ signals for different use cases, or you can do both.
3232
response time.
3333

3434
Installation
35-
------------
35+
************
3636

3737
Install or add drf-api-logger.
3838

@@ -71,13 +71,12 @@ Add in MIDDLEWARE
7171
'drf_api_logger.middleware.api_logger_middleware.APILoggerMiddleware', # Add here
7272
]
7373
74-
\* Add these lines in the Django Rest Framework settings file.
75-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
74+
7675
7776
Store logs into the database
78-
----------------------------
77+
****************************
7978

80-
Log every request into the database.
79+
Log every request into the database. Add these lines in the Django Rest Framework settings file.
8180

8281
.. code:: python
8382
@@ -112,7 +111,7 @@ Note: Make sure to migrate. It will create a table for the logger if
112111
the table.
113112

114113
To listen for the logger signals.
115-
---------------------------------
114+
*********************************
116115

117116
Listen to the signal as soon as any API is called. So you can log the
118117
API data into a file or for different use cases.
@@ -154,7 +153,7 @@ Example code to listen to the API Logger Signal.
154153
API_LOGGER_SIGNAL.listen -= listener_one
155154
156155
Queue
157-
~~~~~
156+
=====
158157

159158
DRF API Logger usage queue to hold the logs before inserting them into
160159
the database. Once the queue is full, it bulk inserts into the database.
@@ -166,7 +165,7 @@ Specify the queue size.
166165
DRF_LOGGER_QUEUE_MAX_SIZE = 50 # Default to 50 if not specified.
167166
168167
Interval
169-
~~~~~~~~
168+
=====
170169

171170
DRF API Logger also waits for a period of time. If the queue is not full
172171
and there are some logs to be inserted, it inserts after the interval
@@ -188,7 +187,7 @@ into the database by specifying the namespace of the app as a list.
188187
DRF_API_LOGGER_SKIP_NAMESPACE = ['APP_NAMESPACE1', 'APP_NAMESPACE2']
189188
190189
Skip URL Name
191-
~~~~~~~~~~~~~
190+
=============
192191

193192
You can also skip any API to be logged by using the url_name of the API.
194193

@@ -199,7 +198,7 @@ You can also skip any API to be logged by using the url_name of the API.
199198
Note: It does not log Django Admin Panel API calls.
200199

201200
Hide Sensitive Data From Logs
202-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
201+
=============================
203202

204203
You may wish to hide sensitive information from being exposed in the
205204
logs. You do this by setting ``DRF_API_LOGGER_EXCLUDE_KEYS`` in
@@ -211,7 +210,7 @@ settings.py to a list of your desired sensitive keys. The default is
211210
# Sensitive data will be replaced with "***FILTERED***".
212211
213212
Change the default database to store API logs
214-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
213+
=============================================
215214

216215
.. code:: python
217216
@@ -221,7 +220,7 @@ Change the default database to store API logs
221220
"""
222221
223222
Want to identify slow APIs? (Optional)
224-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
223+
======================================
225224

226225
You can also identify slow APIs by specifying
227226
``DRF_API_LOGGER_SLOW_API_ABOVE`` in settings.py.
@@ -235,7 +234,7 @@ slow or fast API.
235234
# Specify in milli-seconds.
236235
237236
Want to log only selected request methods? (Optional)
238-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
237+
=====================================================
239238

240239
You can log only selected methods by specifying
241240
``DRF_API_LOGGER_METHODS`` in settings.py.
@@ -245,7 +244,7 @@ You can log only selected methods by specifying
245244
DRF_API_LOGGER_METHODS = ['GET', 'POST', 'DELETE', 'PUT'] # Default to an empty list (Log all the requests).
246245
247246
Want to log only selected response status codes? (Optional)
248-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
247+
============================================================
249248

250249
You can log only selected responses by specifying
251250
``DRF_API_LOGGER_STATUS_CODES`` in settings.py.
@@ -255,7 +254,7 @@ You can log only selected responses by specifying
255254
DRF_API_LOGGER_STATUS_CODES = [200, 400, 404, 500] # Default to an empty list (Log all responses).
256255
257256
Want to see the API information in the local timezone? (Optional)
258-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
257+
=================================================================
259258

260259
You can also change the timezone by specifying
261260
``DRF_API_LOGGER_TIMEDELTA`` in settings.py. It won’t change the
@@ -272,7 +271,7 @@ Database timezone. It will remain UTC or the timezone you have defined.
272271
DRF_API_LOGGER_TIMEDELTA = -30 # Example
273272
274273
Ignore data based on maximum request or response body? (Optional)
275-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
274+
=================================================================
276275

277276
Request/Response bodies By default, DRF API LOGGER will save the request
278277
and response bodies for each request for future viewing no matter how
@@ -289,7 +288,7 @@ This behavior can be configured with the following options additional:
289288
DRF_API_LOGGER_MAX_RESPONSE_BODY_SIZE = 1024 # default to -1, no limit.
290289
291290
API with or without Host
292-
~~~~~~~~~~~~~~~~~~~~~~~~
291+
========================
293292

294293
You can specify whether an endpoint of API should have absolute URI or
295294
not by setting this variable in the DRF settings.py file.
@@ -300,7 +299,7 @@ not by setting this variable in the DRF settings.py file.
300299
# Possible values are ABSOLUTE, FULL_PATH or RAW_URI
301300
302301
Tracing
303-
~~~~~~~
302+
=======
304303

305304
You can enable tracing by specifying ``DRF_API_LOGGER_ENABLE_TRACING``
306305
in settings.py. This will add a tracing ID (UUID.uuid4()) in the signals
@@ -313,7 +312,7 @@ In views, you can use request.tracing_id to get the tracing ID.
313312
DRF_API_LOGGER_ENABLE_TRACING = True # default to False
314313
315314
Want to generate your tracing uuid?
316-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
315+
===================================
317316

318317
By default, the DRF API Logger uses uuid.uuid4() to generate tracing id.
319318
If you want to use your custom function to generate uuid, specify
@@ -324,7 +323,7 @@ DRF_API_LOGGER_TRACING_FUNC in the setting.py file.
324323
DRF_API_LOGGER_TRACING_FUNC = 'foo.bar.func_name'
325324
326325
Tracing already present in headers?
327-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
326+
===================================
328327

329328
If the tracing ID is already coming as a part of request headers, you
330329
can specify the header name.
@@ -359,7 +358,7 @@ values are: 1. ABSOLUTE (Default) :
359358
return an insecure URI.
360359

361360
Use the DRF API Logger Model to query
362-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
361+
=====================================
363362

364363
You can use the DRF API Logger Model to query some information.
365364

@@ -403,7 +402,7 @@ DRF API Logger Model:
403402
verbose_name_plural = 'API Logs'
404403
405404
Note:
406-
~~~~~
405+
=====
407406

408407
After some time, there will be too much data in the database. Searching
409408
and filtering may get slower. If you want, you can delete or archive the

0 commit comments

Comments
 (0)