node-logfmt
node-logfmt copied to clipboard
Escape new lines
I'm not sure, but I think it might be a good idea to escape new line characters. This way new lines in messages don't break the output formatting in console.
This would be similar to how JSON.stringify handles new lines.
// Current behavior
logfmt.stringify({'key':'hello\nworld'}) == "key=hello\nworld"
// New behavior
logfmt.stringify({'key':'hello\nworld'}) == "key=hello\\nworld"
I haven't written up a post in https://github.com/kr/logfmt/issues/9 explaining why it is absolutely necessary to escape newlines.
TL;DR: Unescaped newlines introduce parsing ambiguities.