UNPKG

@securecall/client-component

Version:

SecureCall Core Web Component

44 lines (40 loc) 1.5 kB
'use strict'; const CLIENT_COMP_VERSION = "1.1.0"; // Global logger interface - can be overridden let globalLogger = console; // Function to override the global logger function setGlobalLogger(logger) { globalLogger = logger; } class Logger { debug; info; warn; error; constructor(klass, instanceId) { const timestamp = function () { }; timestamp.toString = function () { return new Date().toISOString(); }; let s = `${klass}(${CLIENT_COMP_VERSION}`; s += (instanceId) ? `/${instanceId})` : ')'; // Use the global logger instance if (globalLogger === console) { this.debug = globalLogger.debug.bind(globalLogger, '%s', timestamp, s); this.info = globalLogger.info.bind(globalLogger, '%s', timestamp, s); this.warn = globalLogger.warn.bind(globalLogger, '%s', timestamp, s); this.error = globalLogger.error.bind(globalLogger, '%s', timestamp, s); } else { this.debug = globalLogger.debug.bind(globalLogger, s); this.info = globalLogger.info.bind(globalLogger, s); this.warn = globalLogger.warn.bind(globalLogger, s); this.error = globalLogger.error.bind(globalLogger, s); } } } exports.CLIENT_COMP_VERSION = CLIENT_COMP_VERSION; exports.Logger = Logger; exports.setGlobalLogger = setGlobalLogger; //# sourceMappingURL=logger-MkCqSOk_.js.map //# sourceMappingURL=logger-MkCqSOk_.js.map