-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bunyan outputs {}
for Map objects even when they are fully populated
#461
Comments
Thanks.
With
Bunyan doesn't currently inspect the type of each field of Even if that were done, if the Map instance were deeper (say, The basic issue here is that Bunyan currently basically relies on the JavaScript's languages "JSON.stringify" to serialize types. JSON is specified, but new types are coming that don't have a specified representation in JSON. Also (I could be wrong), I think node.js sometimes defines toJSON methods for some objects? To illustrate:
So, possibilities here:
|
I think we should:
|
For example,
I believe this is because there is no
toJSON
method on Map. Monkey patching a toJSON method on to Map results in correct output.Example monkey patch:
Ideally Bunyan would output the full contents of a Map when logged, but that may be rather problematic given the diversity of types that can be in a map as keys and values. That said, Bunyan should at least output something that lets log readers understand that it can't actually output the contents of a Map so that they aren't mislead into thinking that a Map object with contents is empty.
Something like
[Map (contents suppressed)]
would work for me.The text was updated successfully, but these errors were encountered: