diff --git a/.github/workflows/_container.yml b/.github/workflows/_container.yml index e3693ef..666425b 100644 --- a/.github/workflows/_container.yml +++ b/.github/workflows/_container.yml @@ -42,7 +42,9 @@ jobs: run: | docker run -d --name smoke -p 8000:8000 \ -v ${{ github.workspace }}/tests/container:/deploy/config:ro \ - tag_for_testing + tag_for_testing \ + tiled serve config --host 0.0.0.0 --port 8000 --scalable \ + --log-config /deploy/log_config.yml for i in $(seq 60); do curl -sf localhost:8000/healthz && break; sleep 1; done # 422 (unknown scan) proves the visr router is mounted; 404 would mean it is not status=$(curl -s -o /dev/null -w '%{http_code}' localhost:8000/api/v1/binned/none || true) diff --git a/Dockerfile b/Dockerfile index 563e1ac..3d87a46 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,10 @@ RUN --mount=from=ghcr.io/astral-sh/uv:0.10,source=/uv,target=/bin/uv \ && chown -R app:app /app USER app +# Logging config that also shows the plugin loggers: use with +# tiled serve config ... --log-config /deploy/log_config.yml +COPY log_config.yml /deploy/log_config.yml + # Check the plugins import and that upstream tiled was left at its release RUN python -c "import dls_tiled.visr, tiled; \ assert tiled.__version__ == '${TILED_VERSION}', tiled.__version__" diff --git a/README.md b/README.md index eaf2713..4e6f0d2 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,18 @@ routers: Ported from Hiran Wijesinghe's [visr-tiled](https://github.com/hyperrealist/visr-tiled). +## Logging + +tiled's default logging config has no handler for the plugin loggers, so their +INFO messages are dropped. The image includes `/deploy/log_config.yml`, which is +tiled's default plus the `dls_tiled` loggers. Select it by overriding the +container command, e.g. with the tiled helm chart: + +```yaml +args: [tiled, serve, config, --host, 0.0.0.0, --port, "8000", --scalable, + --log-config, /deploy/log_config.yml] +``` + ## Tiled version `TILED_VERSION` at the top of the `Dockerfile` selects the upstream release. diff --git a/log_config.yml b/log_config.yml new file mode 100644 index 0000000..3ee2a80 --- /dev/null +++ b/log_config.yml @@ -0,0 +1,51 @@ +# tiled's default logging (tiled.server.logging_config.LOGGING_CONFIG) plus the +# dls_tiled plugin loggers, which otherwise have no handler and drop INFO. +# Use with: tiled serve config ... --log-config /deploy/log_config.yml +version: 1 +disable_existing_loggers: false +filters: + principal: + "()": tiled.server.principal_log_filter.PrincipalFilter + correlation_id: + "()": asgi_correlation_id.CorrelationIdFilter + default_value: "-" + uuid_length: 16 +formatters: + access: + "()": tiled.server.logging_config.AccessFormatter + datefmt: "%Y-%m-%dT%H:%M:%S" + format: '[%(correlation_id)s] %(client_addr)s (%(principal)s) - "%(request_line)s" %(status_code)s' + use_colors: true + default: + "()": uvicorn.logging.DefaultFormatter + datefmt: "%Y-%m-%dT%H:%M:%S" + format: "[%(correlation_id)s] %(levelprefix)s %(name)s: %(message)s" + use_colors: true +handlers: + access: + class: logging.StreamHandler + filters: [principal, correlation_id] + formatter: access + stream: ext://sys.stdout + default: + class: logging.StreamHandler + filters: [correlation_id] + formatter: default + stream: ext://sys.stderr +loggers: + tiled: + handlers: [default] + level: INFO + propagate: false + dls_tiled: + handlers: [default] + level: INFO + propagate: false + uvicorn.access: + handlers: [access] + level: INFO + propagate: false + uvicorn.error: + handlers: [default] + level: INFO + propagate: false