Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ py-multihash = "~=2.0.1"
django-prometheus = "~=2.3.1"
django-admin-autocomplete-filter = "~=0.7.1"
django-pgtrigger = "~=4.11.1"
logging-utilities = "~=4.4.1"
logging-utilities = "~=4.5.0"
django-environ = "*"

[requires]
Expand Down
8 changes: 4 additions & 4 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions app/config/logging-cfg-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ filters:
(): logging_utilities.filters.TimeAttribute
isotime: False
utc_isotime: True
add_request:
(): logging_utilities.filters.add_thread_context_filter.AddThreadContextFilter
contexts:
- logger_key: request
context_key: request
django:
(): logging_utilities.filters.django_request.JsonDjangoRequest
attr_name: request
Expand Down Expand Up @@ -133,6 +138,7 @@ handlers:
# handler, they will affect every handler
- type_filter
- isotime
- add_request
- django
# This filter only applies to the current handler (It does not modify the record in-place, but
# instead selects which logs to display)
Expand Down
3 changes: 3 additions & 0 deletions app/config/settings_prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
# last, put everything else in between
MIDDLEWARE = [
'django_prometheus.middleware.PrometheusBeforeMiddleware',
# Middleware to add request to thread variables, this should be far up in the chain so request
# information can be added to as many logs as possible.
'logging_utilities.django_middlewares.add_request_context.AddToThreadContextMiddleware',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be wise to add a comment why this middleware should be on top.

'middleware.logging.RequestResponseLoggingMiddleware',
'django.middleware.security.SecurityMiddleware',
'middleware.cors.CORSHeadersMiddleware',
Expand Down