Open glenjamin opened 7 years ago
Thanks for the PR, I'll give it a look!
Hi @glenjamin, I've imported the PR in the devel mainline and added some basic configuration for the default flattening function you implemented. Can you give it a look? It should preserve what you did and add some very basic protection against reference cycles (which caused a stack boom due to recursion). Thanks!
LGTM, the repetition for the recursive function was bugging me too, so good to see you removed that!
It's worth noting that winston's built-in JSON mode has no cycle protection, but what you've done here looks sensible and low-cost.
This is helpful and has a related issue on the AI Node SDK: https://github.com/Microsoft/ApplicationInsights-node.js/issues/371
Switched base branch to 1.1 for better merge visualisation.
Thanks for making this module, it was really easy to get our logs into app insights from our existing winston logs.
One thing we discovered was that our log metadata sometimes contained nested objects, and this isn't supported by app insights - all properties get toStringed with this helper function https://github.com/Microsoft/ApplicationInsights-node.js/blob/develop/Library/Util.ts#L134-L160
This PR adds the ability to pre-format all messages before they go to azure, and provides a built-in "flat" formatter which attempts to do something sensible for nested objects. The default is left unchanged so as not to break backwards compatibility.
I tried to follow the existing code style, hope this makes sense!