Skip to content

logging-winston and logging-bunyan should deal with circular objects #1987

Description

@ofrobots

Originally raised here: #1977 (comment)

Related: #1983, #1354

Activity

  1. ofrobots commented on Feb 13, 2017

    @ofrobots
    ContributorAuthor

    @stephenplusplus I don't have the power to self-assign this.

  2. ofrobots commented on Feb 13, 2017

    @ofrobots
    ContributorAuthor

    To be clear, unlike @google-cloud/logging, the higher level layers for winston and bunyan should erase circularity.

  3. ofrobots commented on Feb 14, 2017

    @ofrobots
    ContributorAuthor

    I have been thinking of a way to do this that wouldn't be highly inefficient. As things stand today, Entry.prototype.toJSON already does two walks of the full object graph:

    1. Upfront check forisCircular, and throw if it is.
    2. The serialization via Service.objToStruct_.

    Doing another object walk in the higher level winston and bunyan layers 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:

    1. Add a new property to entry that encodes behaviour (throw vs. erase) upon encountering a circular reference, which is later passed by toJSON to objToStruct_.
    2. Given me a mechanism where I can hand you a pre-serialized Entry object with a jsonPayload.

    Thoughts?

  4. added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    api: loggingIssues related to the Cloud Logging API.
    on Feb 27, 2017
  5. zbjornson commented on Feb 28, 2017

    @zbjornson
    Contributor

    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.

  6. ofrobots commented on Feb 28, 2017

    @ofrobots
    ContributorAuthor
  7. stephenplusplus commented on Feb 28, 2017

    @stephenplusplus
    Contributor

    Option 1 works for me. options.removeCircular, default false. (better options name welcome, especially if there is prior art)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions