UNPKG

mindee

Version:

Mindee Client Library for Node.js

33 lines (32 loc) 787 B
export const LOG_LEVELS = { debug: 0, info: 1, warn: 2, error: 3, }; class Logger { constructor(levelToSet = "warn") { this.levelToSet = levelToSet; if (!(levelToSet in LOG_LEVELS)) { this.level = LOG_LEVELS["debug"]; } this.level = LOG_LEVELS[levelToSet]; } debug(...args) { if (this.level <= LOG_LEVELS["debug"]) console.debug(args); } info(...args) { if (this.level <= LOG_LEVELS["info"]) console.info(args); } warn(...args) { if (this.level <= LOG_LEVELS["warn"]) console.warn(args); } error(...args) { if (this.level <= LOG_LEVELS["error"]) console.error(args); } } export const logger = new Logger();