Fully implement the logs and bars switch

This commit is contained in:
2023-11-27 11:45:18 +01:00
parent a0b4e51695
commit fc66f568ea
3 changed files with 55 additions and 38 deletions

View File

@@ -2,23 +2,28 @@ const cliProgress = require("cli-progress");
const { Metric } = require("./metrics");
class MetricManager {
constructor() {
this.metricBufferSize = 1000;
this.multibar = new cliProgress.MultiBar(
{
clearOnComplete: false,
barCompleteChar: "\u2588",
barIncompleteChar: "\u2591",
format: " {bar} | {name} | {value}/{total}",
},
cliProgress.Presets.shades_grey
);
setInterval(() => this.multibar.update(), 100);
constructor(options) {
this.options = options;
if (options.bars) {
this.metricBufferSize = 1000;
this.multibar = new cliProgress.MultiBar(
{
clearOnComplete: false,
barCompleteChar: "\u2588",
barIncompleteChar: "\u2591",
format: " {bar} | {name} | {value}/{total}",
},
cliProgress.Presets.shades_grey
);
setInterval(() => this.multibar.update(), 100);
}
}
AddMetrics(name, refresh = true) {
const metric = new Metric(name, this.multibar, this.metricBufferSize, refresh);
return metric;
if (this.options.bars) {
const metric = new Metric(name, this.multibar, this.metricBufferSize, refresh);
return metric;
}
}
}