Description
In the UI and the file system application logs we should strive for parity with node.js as far as logging is concerned.
When printing strings should expand \t and \n into an tab and a newline while when printing objects no expansion should be done.
Consider the Eventing function (send it one mutation)
function OnUpdate(doc, meta) {
|
var d = Date.now();
|
|
// tabs
|
log(d + " [INFO] ", "a\tb");
|
log(d + " [INFO] ", "a\t\t\t\tb");
|
|
// new lines
|
log(d + " [INFO] ", "a\n");
|
log(d + " [INFO] ", "a\n\n\n\n");
|
|
// objects
|
log(d + " [INFO] ", { "a": "a\tb" });
|
log(d + " [INFO] ", { "a": "a\t\t\t\tb" });
|
log(d + " [INFO] ", { "a": "a\nb" });
|
log(d + " [INFO] ", { "a": "a\n\n\n\nb" });
|
}
|
It has the following output
2021-01-14T22:13:12.088-08:00 [INFO] "1610691192088 [INFO] " "a\tb"
|
2021-01-14T22:13:12.088-08:00 [INFO] "1610691192088 [INFO] " "a\t\t\t\tb"
|
2021-01-14T22:13:12.088-08:00 [INFO] "1610691192088 [INFO] " "a\n"
|
2021-01-14T22:13:12.088-08:00 [INFO] "1610691192088 [INFO] " "a\n\n\n\n"
|
2021-01-14T22:13:12.088-08:00 [INFO] "1610691192088 [INFO] " {"a":"a\tb"}
|
2021-01-14T22:13:12.088-08:00 [INFO] "1610691192088 [INFO] " {"a":"a\t\t\t\tb"}
|
2021-01-14T22:13:12.088-08:00 [INFO] "1610691192088 [INFO] " {"a":"a\nb"}
|
2021-01-14T22:13:12.088-08:00 [INFO] "1610691192088 [INFO] " {"a":"a\n\n\n\nb"}
|
Now consider the equivalent node script
var d = Date.now();
|
|
// tabs
|
console.log(d+" [INFO] ","a\tb");
|
console.log(d+" [INFO] ","a\t\t\t\tb");
|
|
// new lines
|
console.log(d+" [INFO] ","a\n");
|
console.log(d+" [INFO] ","a\n\n\n\n");
|
|
// objects
|
console.log(d+" [INFO] ",{"a": "a\tb"});
|
console.log(d+" [INFO] ",{"a": "a\t\t\t\tb"});
|
console.log(d+" [INFO] ",{"a": "a\nb"});
|
console.log(d+" [INFO] ",{"a": "a\n\n\n\nb"});
|
it has an output where both tabs \t and newlines \n are expanded
1610690651546 [INFO] a b
|
1610690651546 [INFO] a b
|
1610690651546 [INFO] a
|
|
|
1610690651546 [INFO] a
|
|
|
|
|
|
|
|
|
1610690651546 [INFO] { a: 'a\tb' }
|
1610690651546 [INFO] { a: 'a\t\t\t\tb' }
|
1610690651546 [INFO] { a: 'a\nb' }
|
1610690651546 [INFO] { a: 'a\n\n\n\nb' }
|