Skip to content

feat(logging): Add structured JSON logging support for console#1265

Merged
tomchop merged 5 commits intomainfrom
structured-logging-fix-6267569848034666326
Feb 12, 2026
Merged

feat(logging): Add structured JSON logging support for console#1265
tomchop merged 5 commits intomainfrom
structured-logging-fix-6267569848034666326

Conversation

@tomchop
Copy link
Collaborator

@tomchop tomchop commented Feb 12, 2026

This PR updates the logging configuration to support structured JSON logging on the console, which is crucial for correct interpretation of logs by cloud services like Google Cloud Logging (stackdriver).

Changes:

  • Enhanced JsonFormatter to include severity, timestamp (UTC ISO 8601), and logger fields.
  • Conditional usage of JsonFormatter for console_handler based on system.structured_log configuration.
  • Robust JSON parsing for request bodies in audit logs.

PR created automatically by Jules for task 6267569848034666326 started by @tomchop

- Update `JsonFormatter` in `core/logger.py` to include standard fields for cloud logging (severity, timestamp, logger).
- Add robust handling for request body parsing in logs.
- Configure `console_handler` to use `JsonFormatter` when `system.structured_log` config is enabled (via `YETI_SYSTEM_STRUCTURED_LOG` env var).
- Defaults to text logging for backward compatibility.

Fixes #1264

Co-authored-by: tomchop <1257972+tomchop@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

- Update `JsonFormatter` in `core/logger.py` to include standard fields for cloud logging (severity, timestamp, logger).
- Add robust handling for request body parsing in logs.
- Configure `console_handler` to use `JsonFormatter` when `system.structured_log` config is enabled (via `YETI_SYSTEM_STRUCTURED_LOG` env var).
- Fix import sorting in `contrib/` files to satisfy Ruff linter.
- Defaults to text logging for backward compatibility.

Fixes #1264

Co-authored-by: tomchop <1257972+tomchop@users.noreply.github.com>
@tomchop
Copy link
Collaborator Author

tomchop commented Feb 12, 2026

Instead of reading a value from the config file, can you base it on a K8S_RUNTIME env variable being set?

@google-labs-jules
Copy link
Contributor

Instead of reading a value from the config file, can you base it on a K8S_RUNTIME env variable being set?

I've updated the code to use the K8S_RUNTIME environment variable as requested, instead of the configuration setting.

- Update `JsonFormatter` in `core/logger.py` to include standard fields for cloud logging (severity, timestamp, logger).
- Add robust handling for request body parsing in logs.
- Configure `console_handler` to use `JsonFormatter` when `K8S_RUNTIME` environment variable is set to "true".
- Fix import sorting in `contrib/` files to satisfy Ruff linter.
- Defaults to text logging for backward compatibility.

Fixes #1264

Co-authored-by: tomchop <1257972+tomchop@users.noreply.github.com>
tomchop and others added 2 commits February 12, 2026 13:03
- Update `JsonFormatter` in `core/logger.py` to include standard fields for cloud logging (severity, timestamp, logger).
- Add robust handling for request body parsing in logs.
- Configure `console_handler` to use `JsonFormatter` when `YETI_K8S_RUNTIME` environment variable is set to "true".
- Fix import sorting in `contrib/` files to satisfy Ruff linter.
- Defaults to text logging for backward compatibility.

Fixes #1264

Co-authored-by: tomchop <1257972+tomchop@users.noreply.github.com>
@tomchop tomchop merged commit 2d13999 into main Feb 12, 2026
2 checks passed
@tomchop tomchop deleted the structured-logging-fix-6267569848034666326 branch February 12, 2026 12:15
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.

1 participant