netconf-client
Version:
57 lines • 1.52 kB
JavaScript
import { red, dim, styleFormat } from "./output-colors.js";
export class Output {
static set verbosity(verbosity) {
this._verbosity = verbosity;
if (this._verbosity > 0) {
this.debug = this._debug;
}
else {
this.debug = () => { };
}
}
static get verbosity() {
return this._verbosity;
}
static debug = () => { };
static error(message) {
process.stderr.write(red(`${message}\n`));
}
static printStackTrace(error) {
if (this.verbosity > 0) {
if (!error) {
error = new Error();
}
const stack = error.stack;
if (stack) {
process.stderr.write(dim(`${stack}\n`));
}
}
}
static info(message, textFormat) {
if (textFormat) {
process.stderr.write(`${styleFormat(message, textFormat)}\n`);
}
else {
process.stderr.write(`${message}\n`);
}
}
static _verbosity = 0;
/**
* Debug function
*
* @param message - Message to debug
* @param source - Source/tag of the message
*/
static _debug(message, source, level) {
if (level && level > this._verbosity) {
return;
}
if (source) {
process.stderr.write(dim(`${source}: ${message}\n`));
}
else {
process.stderr.write(dim(`${message}\n`));
}
}
}
//# sourceMappingURL=output.js.map