UNPKG

homebridge-config-ui-x

Version:

A web based management, configuration and control platform for Homebridge.

36 lines 1.14 kB
import process from 'node:process'; import { ConsoleLogger } from '@nestjs/common'; import { cyan, green, red, white, yellow } from 'bash-color'; export class Logger extends ConsoleLogger { pluginName = ('Homebridge UI'); useTimestamps = (process.env.UIX_LOG_NO_TIMESTAMPS !== '1'); get prefix() { if (this.useTimestamps) { return white(`[${new Date().toLocaleString()}] `) + cyan(`[${this.pluginName}]`); } else { return cyan(`[${this.pluginName}]`); } } log(...args) { console.log(this.prefix, ...args); } success(...args) { console.log(this.prefix, ...args.map(x => green(x))); } error(...args) { console.error(this.prefix, ...args.map(x => red(x))); } warn(...args) { console.warn(this.prefix, ...args.map(x => yellow(x))); } debug(...args) { if (process.env.UIX_DEBUG_LOGGING === '1') { console.debug(this.prefix, ...args.map(x => green(x))); } } verbose(...args) { console.debug(this.prefix, ...args); } } //# sourceMappingURL=logger.service.js.map