Closed JanisE closed 7 years ago
Thanks for your comment. I found that JSON.decycle is not supported by browsers, but sits in a separate library. So to give yourself and others the option to use this without complicating the library for those who don't need it, I created the option to set your own method for serializing objects.
This is now live (version 2.21.0)
A worked out example that calls decycle is at: http://jsnlog.com/Documentation/HowTo/CyclicReferences
If an object is being logged that contains cyclic references (to itself or to one of its (sub-)properties), you get "TypeError: cyclic object value" (see http://stackoverflow.com/a/9382383/99904).
I would suggest replacing
return new StringifiedLogObject(null, actualLogObject, JSON.stringify(actualLogObject));
withreturn new StringifiedLogObject(null, actualLogObject, JSON.stringify(JSON.decycle(actualLogObject)));
to avoid the JS error and actually log something.