Repository navigation
logging-winston and logging-bunyan should deal with circular objects #1987
Description
Activity
@stephenplusplus I don't have the power to self-assign this.
To be clear, unlike @google-cloud/logging, the higher level layers for winston and bunyan should erase circularity.
Reacted by StephenI have been thinking of a way to do this that wouldn't be highly inefficient. As things stand today,
Entry.prototype.toJSONalready does two walks of the full object graph:- Upfront check for
isCircular, and throw if it is. - The serialization via
Service.objToStruct_.
Doing another object walk in the higher level
winstonandbunyanlayers seems highly suboptimal.What would be nicer, would be if I could customize the
objToStruct_walk when the Entry has been constructed through the higher level layers.There are two ways I can see for doing this:
- Add a new property to entry that encodes behaviour (throw vs. erase) upon encountering a circular reference, which is later passed by
toJSONtoobjToStruct_. - Given me a mechanism where I can hand you a pre-serialized Entry object with a
jsonPayload.
Thoughts?
- Upfront check for
- addedpriority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.api: loggingIssues related to the Cloud Logging API.Issues related to the Cloud Logging API.
on Feb 27, 2017 I feel like it's common for users to want logging to "just work" even if it's on a best-effort basis; I don't think many people want to add try/catch and error handling for logging. So, from a general perspective, option 1 sounds nice.
@stephenplusplus thoughts?
Option 1 works for me.
options.removeCircular, default false. (better options name welcome, especially if there is prior art)- added a commit that references this issue
on Mar 16, 2017 - added 2 commits that reference this issue
on Feb 24, 2026 - added a commit that references this issue
on Mar 11, 2026 - added a commit that references this issue
on Mar 18, 2026 - added a commit that references this issue
on Mar 27, 2026
Originally raised here: #1977 (comment)
Related: #1983, #1354