Skip to content

Conversation

@joehan
Copy link
Contributor

@joehan joehan commented Jun 28, 2021

Description

Some complex objects that overwrote toJSON were breaking the structured logger. Specifically, calling removeCircular on some complex objects (for example, #907 ) could cause JSON.stringify to throw null pointer errors when called on those objects. This fix should ensure that any object can be safely logged.

Testing

I tested out the case in #907, and I was able to successfully log moment() without errors:
{"structuredData":"2021-06-28T22:31:17.125Z","severity":"INFO","message":"Hello logs!"}

@google-cla google-cla bot added the cla: yes label Jun 28, 2021
@joehan joehan requested review from mbleigh and taeold June 28, 2021 22:56
@joehan
Copy link
Contributor Author

joehan commented Jun 28, 2021

Seems like this broke some unit tests too, taking a look now.

@joehan joehan removed request for mbleigh and taeold June 28, 2021 23:05
@joehan
Copy link
Contributor Author

joehan commented Jun 28, 2021

Welp, this approach won't work... For simple circular objects, JSON.stringify throws an error, so we need to do something a bit more nuanced to handle both simple circular objects and objects that implement toJSON

@joehan joehan closed this Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 participant