Skip to content

feat: modernize structured logging with named payloads and labels#221

Merged
kevmoo merged 6 commits intogoogleapis:mainfrom
kevmoo:payload_fun
Mar 28, 2026
Merged

feat: modernize structured logging with named payloads and labels#221
kevmoo merged 6 commits intogoogleapis:mainfrom
kevmoo:payload_fun

Conversation

@kevmoo
Copy link
Copy Markdown
Contributor

@kevmoo kevmoo commented Mar 27, 2026

Renamed RequestLogger to CloudLogger (breaking)

Refactor structuredLogEntry and CloudLogger to use named payload parameters instead of positional ones. It also adds native support for inserting custom labels in the JSON output.
Also added the optional stackTrace

Additionally, the JSON serialization pipeline has been hardened to gracefully fallback to toString if jsonEncode encounters unencodable custom objects or cyclical references, avoiding process crashes during complex payload writes.

Renamed RequestLogger to CloudLogger (breaking)

Refactor `structuredLogEntry` and `CloudLogger` to use named `payload` parameters instead of positional ones. It also adds native support for inserting custom `labels` in the JSON output.
Also added the optional stackTrace

Additionally, the JSON serialization pipeline has been hardened to gracefully fallback to `toString` if `jsonEncode` encounters unencodable custom objects or cyclical references, avoiding process crashes during complex payload writes.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces version 0.4.0 of the google_cloud package, featuring a breaking change that renames RequestLogger to CloudLogger and moves it to a more general location. The new CloudLogger implementation is no longer abstract and supports additional parameters for payload, labels, and stackTrace. Furthermore, structured log serialization has been hardened with fallback mechanisms to handle circular references and custom toJson implementations. Feedback was provided regarding the default logger implementation to ensure empty payloads are handled consistently with labels to avoid unnecessary empty brackets in the output.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@kevmoo
Copy link
Copy Markdown
Contributor Author

kevmoo commented Mar 27, 2026

/gcbrun

@kevmoo
Copy link
Copy Markdown
Contributor Author

kevmoo commented Mar 27, 2026

Yay! Green!

@brianquinlan brianquinlan self-requested a review March 27, 2026 17:54
@kevmoo
Copy link
Copy Markdown
Contributor Author

kevmoo commented Mar 27, 2026

/gemini review

@kevmoo
Copy link
Copy Markdown
Contributor Author

kevmoo commented Mar 27, 2026

@brianquinlan PTAL!

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the google_cloud package to version 0.4.0, introducing breaking changes such as renaming RequestLogger to CloudLogger and refactoring the logging implementation. Key enhancements include a default console logger, support for additional metadata like labels and payloads, and improved JSON serialization for structured logs. Feedback was provided regarding the dependency range for google_cloud in the google_cloud_storage package; it is recommended to use a more specific version constraint to prevent potential breakage from the new breaking changes.

@kevmoo kevmoo merged commit 462075d into googleapis:main Mar 28, 2026
22 checks passed
@kevmoo kevmoo deleted the payload_fun branch March 28, 2026 03:47
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.

2 participants