UNPKG

rxpoweredup

Version:

A Typescript RxJS-based library for controlling LEGO Powered UP hubs & peripherals.

36 lines (35 loc) 858 B
import { LogLevel } from '../constants'; export class ConsoleLogger { configuredLogLevel; constructor(configuredLogLevel) { this.configuredLogLevel = configuredLogLevel; } debug(...debug) { if (this.canWrite(LogLevel.Debug)) { console.debug(...debug); } } log(...args) { if (this.canWrite(LogLevel.Debug)) { console.log(...args); } } info(...info) { if (this.canWrite(LogLevel.Info)) { console.info(...info); } } warn(...warning) { if (this.canWrite(LogLevel.Warning)) { console.warn(...warning); } } error(error) { if (this.canWrite(LogLevel.Error)) { console.error(error); } } canWrite(level) { return level >= this.configuredLogLevel; } }