Skip to content

Commit 540563a

Browse files
authored
Fix #45: Document extra log fields (#105)
1 parent 4c5ae34 commit 540563a

File tree

4 files changed

+79
-8
lines changed

4 files changed

+79
-8
lines changed

docs/django.rst

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,26 @@ In order to include querystrings in the request summary log, set this flag in se
414414
DOCKERFLOW_SUMMARY_LOG_QUERYSTRING = True
415415
416416
417-
A unique request ID is read from the `X-Request-ID` request header, and a UUID4 value is generated if unset.
417+
MozLog App-Specific Fields
418+
~~~~~~~~~~~~~~~~~~~~~~~~~~
418419

419-
Leveraging the `RequestIdFilter` in logging configuration as shown above will add a ``rid`` attribute to all log messages.
420+
The *MozLog* formatter will output ``Fields`` application-specific fields. It can be populated through the ``extra`` parameter:
421+
422+
.. code-block:: python
423+
424+
logger.info(
425+
"Subsystem %s running at %s:%s",
426+
name, host, port,
427+
extra={"phase": "started", "host": host, "port": port}
428+
)
429+
430+
431+
Requests Correlation ID
432+
~~~~~~~~~~~~~~~~~~~~~~~
433+
434+
A unique request ID is read from the ``X-Request-ID`` request header, and a UUID4 value is generated if unset.
435+
436+
Leveraging the ``RequestIdFilter`` in logging configuration as shown above will add a ``rid`` field into the ``Fields`` entry of all log messages.
420437

421438
The header name to obtain the request ID can be customized in settings:
422439

docs/fastapi.rst

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,27 @@ In order to include querystrings in the request summary log, set this flag in th
326326
327327
app.state.DOCKERFLOW_SUMMARY_LOG_QUERYSTRING = True
328328
329-
A unique request ID is read from the `X-Request-ID` request header using the `RequestIdMiddleware` middleware (see :ref:`fastapi-setup`), and a UUID4 value is generated if unset.
330329
331-
Leveraging the `RequestIdFilter` in logging configuration as shown above will add a ``rid`` attribute to all log messages.
330+
MozLog App-Specific Fields
331+
~~~~~~~~~~~~~~~~~~~~~~~~~~
332+
333+
The *MozLog* formatter will output ``Fields`` application-specific fields. It can be populated through the ``extra`` parameter:
334+
335+
.. code-block:: python
336+
337+
logger.info(
338+
"Subsystem %s running at %s:%s",
339+
name, host, port,
340+
extra={"phase": "started", "host": host, "port": port}
341+
)
342+
343+
344+
Requests Correlation ID
345+
~~~~~~~~~~~~~~~~~~~~~~~
346+
347+
A unique request ID is read from the ``X-Request-ID`` request header, and a UUID4 value is generated if unset.
348+
349+
Leveraging the ``RequestIdFilter`` in logging configuration as shown above will add a ``rid`` field into the ``Fields`` entry of all log messages.
332350

333351
The header name to obtain the request ID can be customized in settings:
334352

docs/flask.rst

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,27 @@ In order to include querystrings in the request summary log, set this flag in :r
466466

467467
DOCKERFLOW_SUMMARY_LOG_QUERYSTRING = True
468468

469-
A unique request ID is read from the `X-Request-ID` request header, and a UUID4 value is generated if unset.
470469

471-
Leveraging the `RequestIdFilter` in logging configuration as shown above will add a ``rid`` attribute to all log messages.
470+
MozLog App-Specific Fields
471+
~~~~~~~~~~~~~~~~~~~~~~~~~~
472+
473+
The *MozLog* formatter will output ``Fields`` application-specific fields. It can be populated through the ``extra`` parameter:
474+
475+
.. code-block:: python
476+
477+
logger.info(
478+
"Subsystem %s running at %s:%s",
479+
name, host, port,
480+
extra={"phase": "started", "host": host, "port": port}
481+
)
482+
483+
484+
Requests Correlation ID
485+
~~~~~~~~~~~~~~~~~~~~~~~
486+
487+
A unique request ID is read from the ``X-Request-ID`` request header, and a UUID4 value is generated if unset.
488+
489+
Leveraging the ``RequestIdFilter`` in logging configuration as shown above will add a ``rid`` field into the ``Fields`` entry of all log messages.
472490

473491
The header name to obtain the request ID can be customized in settings:
474492

docs/sanic.rst

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,27 @@ In order to include querystrings in the request summary log, set this flag in :r
465465

466466
DOCKERFLOW_SUMMARY_LOG_QUERYSTRING = True
467467

468-
A unique request ID is read from the `X-Request-ID` request header, and a UUID4 value is generated if unset.
469468

470-
Leveraging the `RequestIdFilter` in logging configuration as shown above will add a ``rid`` attribute to all log messages.
469+
MozLog App-Specific Fields
470+
~~~~~~~~~~~~~~~~~~~~~~~~~~
471+
472+
The *MozLog* formatter will output ``Fields`` application-specific fields. It can be populated through the ``extra`` parameter:
473+
474+
.. code-block:: python
475+
476+
logger.info(
477+
"Subsystem %s running at %s:%s",
478+
name, host, port,
479+
extra={"phase": "started", "host": host, "port": port}
480+
)
481+
482+
483+
Requests Correlation ID
484+
~~~~~~~~~~~~~~~~~~~~~~~
485+
486+
A unique request ID is read from the ``X-Request-ID`` request header, and a UUID4 value is generated if unset.
487+
488+
Leveraging the ``RequestIdFilter`` in logging configuration as shown above will add a ``rid`` field into the ``Fields`` entry of all log messages.
471489

472490
The header name to obtain the request ID can be customized in settings:
473491

0 commit comments

Comments
 (0)