Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not play well with logging #54

Open
eiredrake opened this issue Nov 30, 2019 · 4 comments
Open

Does not play well with logging #54

eiredrake opened this issue Nov 30, 2019 · 4 comments

Comments

@eiredrake
Copy link

I've got a console app that I'm looking to have a displayed progress (two layers deep) but also have log output to the console.

Unfortunately the logger (Serilog in my case) and ShellProgressBar don't play well with each other and are constantly overwriting each other which leaves the console an incomprehensible mess. Is there any way to prevent this or do I need to research how to make a custom Serilog console sink? Like maybe somehow force it to stick to certain lines or percentage of the screen or something?

thanks,
E

@Mpdreamz
Copy link
Owner

I briefly investigated this to submit a PR to Serilog.Sinks.Console to inject a custom TextWriter for standard out and error.

That could possibly work but the sink also actively changes Console.ForegroundColor expecting the sink to write in real time.

That said you can now write persist message above the console using pbar.WriteLine() and I've opened #59 so you can also write to standard error above the console. A custom sink link Serilog.Sinks.Console.ShellProgressBar could work but it won't be able to reuse much of the infrastructure of Serilog.Sinks.Console since most is private/internal.

Will leave this open as I think this project should also build a Serilog.Sinks.ShellProgressBar to validate its design and interopability with logging frameworks. It won't be anywhere near as fully featured.

That said the progressbar pbar.WriteLine() is only to persist and preserve important messages above the progress bar. It's inherently slow as it needs to buffer and flush in sync with the progressbar draw loop. So it would make a poor logger for anything with high volume logging.

@jerone
Copy link

jerone commented Apr 14, 2020

I'm having the same issue with Microsoft's default logging extension, using the ILogger from Microsoft.Extensions.Logging.

The implementation currently contains multiple ProgressBar, separated with _logger.LogInformation("msg"); from Microsoft.Extensions.Logging. The logger lines are being immediately overwritten by the next ProgressBar.

@Mart-Bogdan
Copy link

I've seen nodejs libs for pogressbar that allows console outut, just pogressbar renders on bottom of a screen

@Mart-Bogdan
Copy link

It's seems we can use _pbar. WriteLine but id don't display all lines correctly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants