Skip to content

feat: write debug logs as JSON lines - #1593

Merged
chuckwondo merged 1 commit into
mainfrom
feat/json-logging
Dec 2, 2026
Merged

chuckwondo merged 1 commit into
mainfrom
feat/json-logging

Conversation

@chuckwondo

Copy link
Copy Markdown
Contributor

Technical Context

Description

This PR adds JSONFormatter to titiler.core.middleware and uses it in the debug logging config of titiler.application and titiler.xarray. It writes each record as one JSON line with all of its extra fields, including the trace IDs that LoggingInstrumentor adds when telemetry is on.

It differs from the proposal in two ways:

  • The formatter is in titiler.core, because titiler.xarray has the same debug config and does not depend on titiler.application.
  • Its keys are LogRecord attribute names (e.g., levelname rather than level), so an extra field cannot overwrite them.

Checklist

  • Linting: Code is formatted and linted (uv run pre-commit run --all-files)
  • Tests: Tests pass. I have included new tests for these changes where applicable.
  • Edge Cases: I have manually verified "unhappy paths" and edge cases beyond the basic success criteria (e.g., database connection timeouts, malformed input, strict mapping rejections).
  • Documentation: I have updated README.md to reflect any new environment variables, configuration changes, or breaking updates. (Not applicable: README.md does not list settings. The DEBUG docs entry is updated.)
  • Accountability: I can explain the implementation logic for every line of code submitted.

AI tool usage

  • AI (Copilot or something similar) supported my development of this PR. Use of AI tools HAVE TO be indicated.

JSONFormatter lives in titiler.core.middleware, so titiler.application
and titiler.xarray share it. Its own keys are LogRecord attribute names,
so an extra field cannot overwrite them. Its timestamp is ISO 8601 UTC.
A field that JSON cannot encode is written as a string, and numpy bools
and numbers keep their types.

Closes #1190

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'TiTiler performance Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.30.

Benchmark suite Current: 9f06a10 Previous: 9eb344f Ratio
WGS1984Quad response_time 0.03 s 0.02 s 1.50

This comment was automatically generated by workflow using github-action-benchmark.

@chuckwondo
chuckwondo merged commit 4d34c8d into main Dec 2, 2026
11 checks passed
@chuckwondo
chuckwondo deleted the feat/json-logging branch December 2, 2026 06:33
@ds-release-bot ds-release-bot Bot mentioned this pull request Nov 30, 2026

This branch was previously deployed

1 inactive deployment
ci — 9f06a103 Deployed Dec 1, 2026 by chuckwondo via tests (3.11) #234
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

switch to structured logging

2 participants