Open shanehughes3 opened 7 years ago
My bad i misunderstood the problem, if i understand correctly, the normal behavior should be to output even empty lines if both the logs and the streaming ?
Noticed the same issue just now. I used a \n
to separate blocks of logs, but the output didn't work as expected. +1 for retaining blank lines.
@vmarchaud Correct, expected behavior is to print an empty line on both logs and streaming if one exists, i.e. if a chunk of log data contains \n\n
. Currently this does happen in the trailing logs, but in streaming, the newline is omitted - any extra \n
s beyond the first are removed.
Is there any update on this? I also want to see the blank lines in my app's beautifully crafted logs.
What's going wrong?
Currently, if any process tries to log a blank line (i.e.
\n\n
), the line is removed in streaming logs yet retained in the log file and in the tail function.The Log.*stream methods in lib/API/Log.js are checking for general falsiness of each element after splitting a chunk on
\n
, presumably to remove the resulting last element that will be an empty string (since the methods print a newline at the end of input anyway). Unfortunately, since the chunk is split on\n
, any two newlines in a row will result in an element that is an empty string. The log methods then will skip over the element - not printing anything - thereby missing the extra newline.I submitted #3193 to fix this issue, but it was closed in lieu of 4f5566e. Unfortunately, that commit only reinforces the problem - any element with a length of zero (any empty string) would be passed over. In fact, any element with a length of 0 would also return false on the first test (
!line
), thereby making it redundant.How could we reproduce this issue?
In any instance, try logging a blank line (
console.log('foo\n\nbar')
). If tailed, the log will produce the correct output:... but when streaming, the newline will be eliminated:
Supporting information