UNPKG

gamesocket.io

Version:
73 lines (72 loc) 1.63 kB
'use strict' Object.defineProperty(exports, '__esModule', { value: true }) class Logger { static _logger = { info: console.info, debug: console.debug, trace: console.trace, warn: console.warn, error: console.error, fatal: (error) => { throw new Error(error) }, } static get info() { return this._logger.info } static get debug() { return this._logger.debug } static get trace() { return this._logger.trace } static get warn() { return this._logger.warn } static get error() { return this._logger.error } static get fatal() { return this._logger.fatal } static set info(fn) { this._logger.info = fn } static set debug(fn) { this._logger.debug = fn } static set trace(fn) { this._logger.trace = fn } static set warn(fn) { this._logger.warn = fn } static set error(fn) { this._logger.error = fn } static set fatal(fn) { this._logger.fatal = fn } static set(newLogger, newLoggerContextNeeded = false) { if (newLoggerContextNeeded) { this.info = newLogger.info.bind(newLogger) this.debug = newLogger.debug.bind(newLogger) this.trace = newLogger.trace.bind(newLogger) this.warn = newLogger.warn.bind(newLogger) this.error = newLogger.error.bind(newLogger) } else { this.info = newLogger.info this.debug = newLogger.debug this.trace = newLogger.trace this.warn = newLogger.warn this.error = newLogger.error } } static flags = { info: false, debug: false, trace: true, warn: true, } } exports.default = Logger