Skip to content

Commit

Permalink
Fix #45: Document extra log fields (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem authored Mar 28, 2024
1 parent 4c5ae34 commit 540563a
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 8 deletions.
21 changes: 19 additions & 2 deletions docs/django.rst
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,26 @@ In order to include querystrings in the request summary log, set this flag in se
DOCKERFLOW_SUMMARY_LOG_QUERYSTRING = True
A unique request ID is read from the `X-Request-ID` request header, and a UUID4 value is generated if unset.
MozLog App-Specific Fields
~~~~~~~~~~~~~~~~~~~~~~~~~~

Leveraging the `RequestIdFilter` in logging configuration as shown above will add a ``rid`` attribute to all log messages.
The *MozLog* formatter will output ``Fields`` application-specific fields. It can be populated through the ``extra`` parameter:

.. code-block:: python
logger.info(
"Subsystem %s running at %s:%s",
name, host, port,
extra={"phase": "started", "host": host, "port": port}
)
Requests Correlation ID
~~~~~~~~~~~~~~~~~~~~~~~

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

Leveraging the ``RequestIdFilter`` in logging configuration as shown above will add a ``rid`` field into the ``Fields`` entry of all log messages.

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

Expand Down
22 changes: 20 additions & 2 deletions docs/fastapi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,27 @@ In order to include querystrings in the request summary log, set this flag in th
app.state.DOCKERFLOW_SUMMARY_LOG_QUERYSTRING = True
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.
Leveraging the `RequestIdFilter` in logging configuration as shown above will add a ``rid`` attribute to all log messages.
MozLog App-Specific Fields
~~~~~~~~~~~~~~~~~~~~~~~~~~

The *MozLog* formatter will output ``Fields`` application-specific fields. It can be populated through the ``extra`` parameter:

.. code-block:: python
logger.info(
"Subsystem %s running at %s:%s",
name, host, port,
extra={"phase": "started", "host": host, "port": port}
)
Requests Correlation ID
~~~~~~~~~~~~~~~~~~~~~~~

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

Leveraging the ``RequestIdFilter`` in logging configuration as shown above will add a ``rid`` field into the ``Fields`` entry of all log messages.

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

Expand Down
22 changes: 20 additions & 2 deletions docs/flask.rst
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,27 @@ In order to include querystrings in the request summary log, set this flag in :r

DOCKERFLOW_SUMMARY_LOG_QUERYSTRING = True

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

Leveraging the `RequestIdFilter` in logging configuration as shown above will add a ``rid`` attribute to all log messages.
MozLog App-Specific Fields
~~~~~~~~~~~~~~~~~~~~~~~~~~

The *MozLog* formatter will output ``Fields`` application-specific fields. It can be populated through the ``extra`` parameter:

.. code-block:: python
logger.info(
"Subsystem %s running at %s:%s",
name, host, port,
extra={"phase": "started", "host": host, "port": port}
)
Requests Correlation ID
~~~~~~~~~~~~~~~~~~~~~~~

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

Leveraging the ``RequestIdFilter`` in logging configuration as shown above will add a ``rid`` field into the ``Fields`` entry of all log messages.

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

Expand Down
22 changes: 20 additions & 2 deletions docs/sanic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,27 @@ In order to include querystrings in the request summary log, set this flag in :r

DOCKERFLOW_SUMMARY_LOG_QUERYSTRING = True

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

Leveraging the `RequestIdFilter` in logging configuration as shown above will add a ``rid`` attribute to all log messages.
MozLog App-Specific Fields
~~~~~~~~~~~~~~~~~~~~~~~~~~

The *MozLog* formatter will output ``Fields`` application-specific fields. It can be populated through the ``extra`` parameter:

.. code-block:: python
logger.info(
"Subsystem %s running at %s:%s",
name, host, port,
extra={"phase": "started", "host": host, "port": port}
)
Requests Correlation ID
~~~~~~~~~~~~~~~~~~~~~~~

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

Leveraging the ``RequestIdFilter`` in logging configuration as shown above will add a ``rid`` field into the ``Fields`` entry of all log messages.

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

Expand Down

0 comments on commit 540563a

Please sign in to comment.