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

Allow custom progressbar consumers #54

Merged
merged 4 commits into from
Dec 23, 2019
Merged

Conversation

alexpeelman
Copy link

Hi, I extended this incredible useful tool a bit to allow any kind of consumer to print the progress bar. I need this to write the progress to an SLF4J log.

@ctongfei
Copy link
Owner

Hi Alex, thanks for this! Compatibility with SLF4J is of utmost importance -- I haven't got time to do it myself. Could you shed some light on how this extension would make it work with SLF4J, so that I could gain a better understanding of the underlying issue? You can paste a snippet here, or you could add a test that depends on SLF4J.

@alexpeelman
Copy link
Author

Yes, you are completely right. I added a new DelegatingProgressBarConsumer and changed one of the tests so that it uses a SLF4J logger to print the progress bar.

The idea is that for each progress bar update the state is printed to the logger, without the carriage return.This logs the progress over time.

As an example

[me.tongfei.progressbar.ProgressBar] INFO Test - log.test   1% │▏                      │   1/100 (0:00:00 / 0:00:00) ?/s
[me.tongfei.progressbar.ProgressBar] INFO Test - log.test   8% │█▊                     │   8/100 (0:00:00 / 0:00:01) ?/s
[me.tongfei.progressbar.ProgressBar] INFO Test - log.test  15% │███▍                   │  15/100 (0:00:00 / 0:00:01) ?/s
[me.tongfei.progressbar.ProgressBar] INFO Test - log.test  22% │█████                  │  22/100 (0:00:00 / 0:00:01) ?/s
[me.tongfei.progressbar.ProgressBar] INFO Test - log.test  28% │██████▍                │  28/100 (0:00:00 / 0:00:01) ?/s
[me.tongfei.progressbar.ProgressBar] INFO Test - log.test  35% │████████               │  35/100 (0:00:00 / 0:00:00) ?/s
[me.tongfei.progressbar.ProgressBar] INFO Test - log.test  42% │█████████▋             │  42/100 (0:00:00 / 0:00:00) ?/s
[me.tongfei.progressbar.ProgressBar] INFO Test - log.test  48% │███████████            │  48/100 (0:00:00 / 0:00:00) ?/s
[me.tongfei.progressbar.ProgressBar] INFO Test - log.test  55% │████████████▋          │  55/100 (0:00:00 / 0:00:00) ?/s
[me.tongfei.progressbar.ProgressBar] INFO Test - log.test  62% │██████████████▎        │  62/100 (0:00:00 / 0:00:00) ?/s
[me.tongfei.progressbar.ProgressBar] INFO Test - log.test  68% │███████████████▏      │  69/100 (0:00:01 / 0:00:00) 68/s
[me.tongfei.progressbar.ProgressBar] INFO Test - log.test  75% │████████████████▌     │  75/100 (0:00:01 / 0:00:00) 75/s
[me.tongfei.progressbar.ProgressBar] INFO Test - log.test  82% │██████████████████    │  82/100 (0:00:01 / 0:00:00) 82/s
[me.tongfei.progressbar.ProgressBar] INFO Test - log.test  89% │███████████████████▌  │  89/100 (0:00:01 / 0:00:00) 89/s
[me.tongfei.progressbar.ProgressBar] INFO Test - log.test  95% │████████████████████▉ │  95/100 (0:00:01 / 0:00:00) 95/s
[me.tongfei.progressbar.ProgressBar] INFO Test - log.test 100% │█████████████████████│ 100/100 (0:00:01 / 0:00:00) 100/s

@ctongfei
Copy link
Owner

Thanks a lot @alexpeelman -- I'll review this when I got some time (hopefully this weekend).

@alexpeelman
Copy link
Author

Hi just a small check if you are planning to review this any time soon ? No pressure just asking for an update here :)

@ctongfei ctongfei merged commit b695048 into ctongfei:master Dec 23, 2019
@ctongfei
Copy link
Owner

Hooray! I merged this after some modifications to your code. See documentation at https://tongfei.me/progressbar/loggers/. Thanks @alexpeelman !

@alexpeelman
Copy link
Author

Awesome ! Nice idea to introduce the renderer 👍

@ctongfei
Copy link
Owner

Now deployed as version 0.8.0. You'll see this on maven central in a few hours.

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

Successfully merging this pull request may close these issues.

2 participants