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
16 changes: 8 additions & 8 deletions docs/installation/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ Logging
* ``LOG_LEVEL``: control the verbosity of logging output. Available values are ``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO`` and ``DEBUG``. Defaults to: ``INFO``.
* ``LOG_QUERIES``: enable (query) logging at the database backend level. Note that you must also set ``DEBUG=1``, which should be done very sparingly!. Defaults to: ``False``.
* ``LOG_REQUESTS``: enable logging of the outgoing requests. This must be enabled along with `LOG_OUTGOING_REQUESTS_DB_SAVE` to save outgoing request logs in the database. Defaults to: ``False``.
* ``LOG_FORMAT_CONSOLE``: The format for the console logging handler, possible options: ``json``, ``plain_console``. Defaults to: ``json``.
* ``ENABLE_STRUCTLOG_REQUESTS``: enable structured logging of requests. Defaults to: ``True``.
* ``LOG_OUTGOING_REQUESTS_EMIT_BODY``: Whether or not outgoing request bodies should be logged. Defaults to: ``True``.
* ``LOG_OUTGOING_REQUESTS_DB_SAVE``: Whether or not outgoing request logs should be saved to the database. Defaults to: ``False``.
* ``LOG_OUTGOING_REQUESTS_DB_SAVE_BODY``: Whether or not outgoing request bodies should be saved to the database. Defaults to: ``True``.
* ``LOG_OUTGOING_REQUESTS_MAX_AGE``: The amount of time after which request logs should be deleted from the database. Defaults to: ``7``.
* ``ENABLE_STRUCTLOG_REQUESTS``: enable structured logging of requests. Defaults to: ``True``.
* ``LOG_FORMAT_CONSOLE``: The format for the console logging handler, possible options: ``json``, ``plain_console``. Defaults to: ``json``.


Celery
Expand Down Expand Up @@ -90,12 +90,12 @@ Content Security Policy
-----------------------

* ``CSP_EXTRA_DEFAULT_SRC``: Extra default source URLs for CSP other than ``self``. Used for ``img-src``, ``style-src`` and ``script-src``. Defaults to: ``[]``.
* ``CSP_REPORT_URI``: URI of the``report-uri`` directive. Defaults to: ``None``.
* ``CSP_REPORT_PERCENTAGE``: Percentage of requests that get the ``report-uri`` directive. Defaults to: ``0``.
* ``CSP_EXTRA_FORM_ACTION``: Add additional ``form-action`` source to the default . Defaults to: ``[]``.
* ``CSP_FORM_ACTION``: Override the default ``form-action`` source. Defaults to: ``['"\'self\'"']``.
* ``CSP_EXTRA_IMG_SRC``: Extra ``img-src`` sources for CSP other than ``CSP_DEFAULT_SRC``. Defaults to: ``[]``.
* ``CSP_OBJECT_SRC``: ``object-src`` urls. Defaults to: ``['"\'none\'"']``.
* ``CSP_EXTRA_FORM_ACTION``: Additional `form-action` sources. Defaults to: ``[]``.
* ``CSP_FORM_ACTION``: Override the default `form-action` sources. Defaults to: ``['"\'self\'"']``.
* ``CSP_EXTRA_IMG_SRC``: Extra `img-src` sources. Defaults to: ``[]``.
* ``CSP_OBJECT_SRC``: `object-src` sources. Defaults to: ``['"\'none\'"']``.
* ``CSP_REPORT_URI``: URI for CSP report-uri directive. Defaults to: ``None``.
* ``CSP_REPORT_PERCENTAGE``: Fraction (between 0 and 1) of requests to include report-uri directive. Defaults to: ``0.0``.


Cache
Expand Down
5 changes: 1 addition & 4 deletions requirements/base.in
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
open-api-framework[celery,cors,markup,geo,csp,commonground,inclusions,sanitization,server,redis]
open-api-framework[celery,cors,markup,geo,csp,commonground,inclusions,sanitization,server,redis, structlog-celery]

# Core python libraries
glom # data represenation based on spec
jsonschema
furl

# Django libraries
django-structlog[celery]

# Common ground libraries
django-setup-configuration>=0.5.0
notifications-api-common[setup-configuration]
Expand Down
18 changes: 11 additions & 7 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ click-plugins==1.1.1
# via celery
click-repl==0.3.0
# via celery
commonground-api-common==2.9.0
commonground-api-common==2.10.0
# via
# -r requirements/base.in
# open-api-framework
Expand Down Expand Up @@ -117,7 +117,7 @@ django-axes==6.5.1
# via open-api-framework
django-cors-headers==4.4.0
# via open-api-framework
django-csp==3.8
django-csp==4.0
# via open-api-framework
django-filter==24.2
# via
Expand Down Expand Up @@ -170,7 +170,7 @@ django-solo==2.2.0
# notifications-api-common
# zgw-consumers
django-structlog==9.1.1
# via -r requirements/base.in
# via open-api-framework
django-two-factor-auth==1.17.0
# via maykin-2fa
django-upgrade-check==1.1.0
Expand Down Expand Up @@ -249,14 +249,16 @@ notifications-api-common==0.7.3
# via
# -r requirements/base.in
# commonground-api-common
open-api-framework==0.12.0
open-api-framework==0.13.0
# via -r requirements/base.in
orderedmultidict==1.0.1
# via furl
oyaml==1.0
# via commonground-api-common
packaging==25.0
# via kombu
# via
# django-csp
# kombu
phonenumberslite==8.13.30
# via django-two-factor-auth
prometheus-client==0.20.0
Expand Down Expand Up @@ -343,8 +345,10 @@ six==1.16.0
# qrcode
sqlparse==0.5.0
# via django
structlog==25.3.0
# via django-structlog
structlog==25.4.0
# via
# django-structlog
# open-api-framework
tornado==6.5
# via flower
typing-extensions==4.9.0
Expand Down
9 changes: 5 additions & 4 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ click-repl==0.3.0
# celery
codecov==2.1.13
# via -r requirements/test-tools.in
commonground-api-common==2.9.0
commonground-api-common==2.10.0
# via
# -c requirements/base.txt
# -r requirements/base.txt
Expand Down Expand Up @@ -191,7 +191,7 @@ django-cors-headers==4.4.0
# via
# -c requirements/base.txt
# -r requirements/base.txt
django-csp==3.8
django-csp==4.0
# via
# -c requirements/base.txt
# -r requirements/base.txt
Expand Down Expand Up @@ -460,7 +460,7 @@ notifications-api-common==0.7.3
# -c requirements/base.txt
# -r requirements/base.txt
# commonground-api-common
open-api-framework==0.12.0
open-api-framework==0.13.0
# via
# -c requirements/base.txt
# -r requirements/base.txt
Expand All @@ -478,6 +478,7 @@ packaging==25.0
# via
# -c requirements/base.txt
# -r requirements/base.txt
# django-csp
# kombu
# pytest
# sphinx
Expand Down Expand Up @@ -699,7 +700,7 @@ sqlparse==0.5.0
# -c requirements/base.txt
# -r requirements/base.txt
# django
structlog==25.3.0
structlog==25.4.0
# via
# -c requirements/base.txt
# -r requirements/base.txt
Expand Down
9 changes: 5 additions & 4 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ codecov==2.1.13
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
commonground-api-common==2.9.0
commonground-api-common==2.10.0
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
Expand Down Expand Up @@ -231,7 +231,7 @@ django-cors-headers==4.4.0
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
django-csp==3.8
django-csp==4.0
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
Expand Down Expand Up @@ -556,7 +556,7 @@ notifications-api-common==0.7.3
# -c requirements/ci.txt
# -r requirements/ci.txt
# commonground-api-common
open-api-framework==0.12.0
open-api-framework==0.13.0
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
Expand All @@ -575,6 +575,7 @@ packaging==25.0
# -c requirements/ci.txt
# -r requirements/ci.txt
# build
# django-csp
# kombu
# pytest
# sphinx
Expand Down Expand Up @@ -885,7 +886,7 @@ sqlparse==0.5.0
# django
# django-debug-toolbar
# django-silk
structlog==25.3.0
structlog==25.4.0
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
Expand Down
8 changes: 4 additions & 4 deletions src/objects/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from celery import Celery, bootsteps
from celery.signals import setup_logging, worker_ready, worker_shutdown
from django_structlog.celery.steps import DjangoStructLogInitStep
from open_api_framework.conf.utils import config

from .setup import setup_env

Expand Down Expand Up @@ -37,7 +36,6 @@
def receiver_setup_logging(
loglevel, logfile, format, colorize, **kwargs
): # pragma: no cover
formatter = config("LOG_FORMAT_CONSOLE", default="json")
logging.config.dictConfig(
{
"version": 1,
Expand Down Expand Up @@ -69,7 +67,7 @@ def receiver_setup_logging(
"handlers": {
"console": {
"class": "logging.StreamHandler",
"formatter": formatter,
"formatter": settings.LOG_FORMAT_CONSOLE,
},
},
"loggers": {
Expand All @@ -90,7 +88,9 @@ def receiver_setup_logging(
)

exception_processors = (
[structlog.processors.format_exc_info] if formatter == "json" else []
[structlog.processors.format_exc_info]
if settings.LOG_FORMAT_CONSOLE == "json"
else []
)
structlog.configure(
processors=[
Expand Down
Loading