Description
I have a problem with the ConsoleLogger that doesn't do what I'm actually looking for in terms of SingleLine experience.
Basically, I would like to have the log happening on a single line if the message doesn't have new lines, but otherwise it would keep the new lines around:
Today we have the following two modes:
builder.AddSimpleConsole();
info: lunet[0]
Site build started
With a long new lines
But we want to preserve the messages lines
info: lunet[1]
This is another simple line but the message doesn't have new lines
info: lunet[2]
Site build finished in 1194.4774ms. 71 files processed. 2073934 bytes written.
.AddSimpleConsole(options => { options.SingleLine = true; });
info: lunet[0] Site build started With a long new lines But we want to preserve the messages lines
info: lunet[1] This is another simple line but the message doesn't have new lines
info: lunet[2] Site build finished in 1216.9315ms. 71 files processed. 2073934 bytes written.
While I would like to that this mode:
info: lunet[0] Site build started
With a long new lines
But we want to preserve the messages lines
info: lunet[1] This is another simple line but the message doesn't have new lines
info: lunet[2] Site build finished in 1211.6869ms. 71 files processed. 2073934 bytes written.
Note also that the code in SimpleConsoleFormatter.WriteReplacing is a bit brittle also, because if you are on Windows with \r\n
and your message is using \n
, you will still see new lines in the output even if you ask for single line.
So in my project, I had to copy/paste SimpleConsoleFormatter here with two changes:
1st change: keep new lines in a message in single line mode
2nd change: Fix the issue with messages having \n
on Windows (note, this might be related to #40315)
So I would like to know if it would be possible to maybe add a new SimpleConsoleFormatterOptions
that would be:
public bool KeepNewLinesInMessage {get;set;}
Or something replacing the SingleLine
option with a tree state enum?
What do you think?
cc: @maryamariyan