UNPKG

@securecall/client-component

Version:

SecureCall Core Web Component

40 lines (37 loc) 1.43 kB
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); } } } export { CLIENT_COMP_VERSION as C, Logger as L, setGlobalLogger as s }; //# sourceMappingURL=p-By6Qn8nU.js.map //# sourceMappingURL=p-By6Qn8nU.js.map