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

add compatibltiy with console log #3

Open
walidbou6 opened this issue Jul 27, 2022 · 5 comments
Open

add compatibltiy with console log #3

walidbou6 opened this issue Jul 27, 2022 · 5 comments

Comments

@walidbou6
Copy link

hi, first thank you for making my life easier 😁❤️,
second this is just a small request if it's possible to add a compatibility with console log messages so that the progress bar be at the bottom all the time and messages being displayed above of it,
because that doesn't look good at all:
tmp

@agracio
Copy link
Owner

agracio commented Jul 27, 2022

I have not touched this project for a long time, could you provide code sample so i can work with it.

@walidbou6
Copy link
Author

thank you for fast replay; here you can test it with this script:

var Progress = require("ts-progress");

var total = 10;

var progress = Progress.create({ total: total });

function sleep(millis) {
  return new Promise((resolve) => setTimeout(resolve, millis));
}

async function test() {
  console.log("hi this is a message");
  await sleep(1000);
}

for (var i = 0; i < 10; i++) {
  test();
  progress.update();
}

@agracio
Copy link
Owner

agracio commented Jul 27, 2022

Thanks, I will take a look but cannot guarantee quick results.

@agracio
Copy link
Owner

agracio commented Aug 2, 2022

Unfortunately it is not possible to make it compatible with console.log. The component uses charm module to delete and then redraw current line because console does not have direct support for updating current line. This means that the same console line is constantly redrawn.

@walidbou6
Copy link
Author

thank you @agracio I got you, there's another way create your own function to log messages like at python when using the tqdm package they have a function tqdm.write to print logs that will be compatible with progress bar.
docs/tqdm/#write

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