Closed fgm closed 7 years ago
In the suggested change, the serializer now is injectable and provides JSON as a default, now handling non-JSON-serializable data with a fallback to an error format including the util.inspect() blob. There is even a second-level safety fallback for unforeseen cases where util.inspect would fail too.
Changed wording and added server hostname per @yched review.
Looks good on our test app :-)
Merged #34
Was it merged ? I see nothing in the master history
On dirait que je n'aurais pas du utiliser l'UI de github 😥
Le mar. 11 avr. 2017 13:46, Yves Chedemois notifications@github.com a écrit :
Was it merged ? I see nothing in the master history
— You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub https://github.com/FGM/filog/issues/33#issuecomment-293232463, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIvz90b9xcT28KwUDrgBKZIMu4mowajks5ru2gigaJpZM4MuIaV .
Created a new PR with my local copy of the code from the deleted branch : #35
Currently, the syslog messages being sent are just v8 inspection strings, as the result of
util.inspect(doc)
.See SyslogSender::send():
The reason for this is to ensure data can actually be serialized, and a more common format like JSON does not ensure serializability.
The envisioned strategy is to replace this by an exception-handling JSON stringifying in
SyslogSender::send()
:JSON.stringify
succeeds, then log the resulting JSONutil.inspect()
blob, as currently doneAllternative would be to have a user-space serialization library. Some of the envisioned ones are, in more or less decreasing relevance order:
JSON.stringify()
with a custom replacer, as documented at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify is just the underlying logic for these packagesIn the longer run, this could mean using the Strategy pattern just like we did at the top level of the logging chain: the initial suggested solution is just a degenerate case of it.