npkgz / cli-progress

:hourglass: easy to use progress-bar for command-line/terminal applications
https://www.npmjs.com/package/cli-progress
MIT License
1.09k stars 84 forks source link

Multibar can't show any logs #156

Closed timsu92 closed 5 months ago

timsu92 commented 5 months ago

Here is a short program which I'm trying to use the logging function. In the program, I set a maximum of 50 of the progress bar, and asks it to log when 0, 10, 20, 30, 40. However, what I see is the progress bar only. No any logs shown.

import { MultiBar } from "cli-progress";

const multibar = new MultiBar({
  hideCursor: true,
  clearOnComplete: true,
  stopOnComplete: true,
  forceRedraw: true,
});

const pro = multibar.create(50, 0, undefined, { autopadding: true });

for (let i = 0; i < 50; ++i) {
  pro.increment();
  if (i % 10 === 0) {
    multibar.log(i.toString());
  }
  await new Promise((resolve) => setTimeout(resolve, 50));
}

Environment

OS: Ubuntu-22.04 Runtime: Bun v1.1.3

saikatmitra91 commented 5 months ago

Replacing multibar.log(i.toString()); with multibar.log(i.toString() + "\n"); should work

timsu92 commented 5 months ago

Thank you! Sorry for overlooking that comment in the example code.