feat: modernize structured logging with named payloads and labels#221
feat: modernize structured logging with named payloads and labels#221kevmoo merged 6 commits intogoogleapis:mainfrom
Conversation
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.
There was a problem hiding this comment.
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>
|
/gcbrun |
|
Yay! Green! |
|
/gemini review |
|
@brianquinlan PTAL! |
There was a problem hiding this comment.
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.
Renamed RequestLogger to CloudLogger (breaking)
Refactor
structuredLogEntryandCloudLoggerto use namedpayloadparameters instead of positional ones. It also adds native support for inserting customlabelsin the JSON output.Also added the optional stackTrace
Additionally, the JSON serialization pipeline has been hardened to gracefully fallback to
toStringifjsonEncodeencounters unencodable custom objects or cyclical references, avoiding process crashes during complex payload writes.