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

What about a bar.clear()? #96

Closed
stheine opened this issue Mar 23, 2021 · 4 comments
Closed

What about a bar.clear()? #96

stheine opened this issue Mar 23, 2021 · 4 comments

Comments

@stheine
Copy link

stheine commented Mar 23, 2021

Hi,

on long-running jobs with a progress bar, I often have the need to print some extra log information in special situations.
as this interferes with the bar, I'd like the ability to completely clean out the bar, then print my log message, and then print the bar again in the next line.
currently, my workaround is:

bar.stop();
process.stdout.write('\x1b[1A \r'); // add enough blanks to clear out the bar
console.log('my log message');
bar.start(total, num);

I would rather hope for

bar.clear();
console.log('my log message');
...
bar.update(num); // this automatically draws the bar again on the next update

Regards
stheine

@AndiDittrich
Copy link
Member

there are some events available to print your messages, just take a look into the docs

@stheine
Copy link
Author

stheine commented Mar 23, 2021

not sure what you're referring to. I find many options to tweak the format of the bar itself, but when I'm logging extra data, that can be multi-line/ JSON.stringify/ colored, so I don't know how I could put that into the bar, that's why I'm rather completely removing the bar, then print my log data, then redraw the bar below my log output.

@AndiDittrich
Copy link
Member

see #85 #57
but this method is intended for simple logging, not for fancy formatting. and as you might see by reading the previous issues regarding this feature request...it's quite complicated for multibars...

@stheine
Copy link
Author

stheine commented Mar 23, 2021

ok, get your point. of course, my workaround only works for the single bar mode - and that's fine for me, as that's all I use here - but you'd also have to cover the multi bar mode (unless you'd only offer that for single bar).
thanks for the pointers.

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

2 participants