@webex/plugin-logger 3.12.0-next.6 → 3.12.0-next.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.repo-context.json +389 -0
- package/.sdd/manifest.json +334 -0
- package/AGENTS.md +175 -0
- package/dist/logger.js +37 -4
- package/dist/logger.js.map +1 -1
- package/docs/adr/0001-retain-product-readme.md +76 -0
- package/docs/adr/index.md +18 -0
- package/docs/architecture.md +252 -0
- package/docs/getting-started.md +88 -0
- package/docs/index.md +42 -0
- package/docs/specs/README.md +65 -0
- package/package.json +10 -10
- package/schemas/repo-context.schema.json +796 -0
- package/src/docs/README.md +320 -0
- package/src/logger.js +36 -0
- package/test/unit/spec/logger.js +318 -54
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_common","require","_webexCore","_lodash","precedence","silent","group","groupEnd","error","warn","log","info","debug","trace","levels","exports","_keys","default","filter","level","fallbacks","LOG_TYPES","SDK","CLIENT","SDK_LOG_TYPE_NAME","authTokenKeyPattern","walkAndFilter","object","visited","arguments","length","undefined","includes","push","isArray","map","o","isObject","isString","patterns","containsEmails","test","replace","containsMTID","_i","_Object$entries","_entries","_Object$entries$_i","_slicedToArray2","key","value","_deleteProperty","Logger","WebexPlugin","extend","namespace","derived","cache","fn","getCurrentLevel","client_level","getCurrentClientLevel","session","buffer","type","nextIndex","groupLevel","sdkBuffer","clientBuffer","_len","args","Array","_key2","arg","Error","process","env","NODE_ENV","inBrowser","ret","toString","stack","cloneDeep","shouldPrint","shouldBuffer","config","bufferLogLevel","WEBEX_LOG_LEVEL","webex","internal","device","features","developer","get","clientLevel","formatLogs","options","getDate","_options$diff","diff","clientIndex","sdkIndex","separateLogBuffers","Date","slice","join","version","makeLoggerMethod","impl","neverPrint","alwaysBuffer","wrappedConsoleMethod","logType","clientName","bufferRef","historyLength","clientHistoryLength","filtered","concat","_toConsumableArray2","apply","stringified","item","_typeof2","returnItem","_stringify","_key","e","_console","toPrint","has","unshift","url","console","logDate","toISOString","repeat","deleteCount","splice","reason","forEach","impls","pop","prototype","client_logToBuffer","logToBuffer","_default2"],"sources":["logger.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {inBrowser, patterns} from '@webex/common';\nimport {WebexPlugin} from '@webex/webex-core';\nimport {cloneDeep, has, isArray, isObject, isString} from 'lodash';\n\nconst precedence = {\n silent: 0,\n group: 1,\n groupEnd: 2,\n error: 3,\n warn: 4,\n log: 5,\n info: 6,\n debug: 7,\n trace: 8,\n};\n\nexport const levels = Object.keys(precedence).filter((level) => level !== 'silent');\n\nconst fallbacks = {\n error: ['log'],\n warn: ['error', 'log'],\n info: ['log'],\n debug: ['info', 'log'],\n trace: ['debug', 'info', 'log'],\n};\n\nconst LOG_TYPES = {\n SDK: 'sdk',\n CLIENT: 'client',\n};\n\nconst SDK_LOG_TYPE_NAME = 'wx-js-sdk';\n\nconst authTokenKeyPattern = /[Aa]uthorization/;\n\n/**\n * Recursively strips \"authorization\" fields from the specified object\n * @param {Object} object\n * @param {Array<mixed>} [visited]\n * @private\n * @returns {Object}\n */\nfunction walkAndFilter(object, visited = []) {\n if (visited.includes(object)) {\n // Prevent circular references\n return object;\n }\n\n visited.push(object);\n\n if (isArray(object)) {\n return object.map((o) => walkAndFilter(o, visited));\n }\n if (!isObject(object)) {\n if (isString(object)) {\n if (patterns.containsEmails.test(object)) {\n return object.replace(patterns.containsEmails, '[REDACTED]');\n }\n if (patterns.containsMTID.test(object)) {\n return object.replace(patterns.containsMTID, '$1[REDACTED]');\n }\n }\n\n return object;\n }\n\n for (const [key, value] of Object.entries(object)) {\n if (authTokenKeyPattern.test(key)) {\n Reflect.deleteProperty(object, key);\n } else {\n object[key] = walkAndFilter(value, visited);\n }\n }\n\n return object;\n}\n\n/**\n * @class\n */\nconst Logger = WebexPlugin.extend({\n namespace: 'Logger',\n\n derived: {\n level: {\n cache: false,\n fn() {\n return this.getCurrentLevel();\n },\n },\n client_level: {\n cache: false,\n fn() {\n return this.getCurrentClientLevel();\n },\n },\n },\n session: {\n // for when configured to use single buffer\n buffer: {\n type: 'object',\n default() {\n return {\n buffer: [],\n nextIndex: 0,\n };\n },\n },\n groupLevel: {\n type: 'number',\n default() {\n return 0;\n },\n },\n // for when configured to use separate buffers\n sdkBuffer: {\n type: 'object',\n default() {\n return {\n buffer: [],\n nextIndex: 0,\n };\n },\n },\n clientBuffer: {\n type: 'object',\n default() {\n return {\n buffer: [],\n nextIndex: 0,\n };\n },\n },\n },\n\n /**\n * Ensures auth headers don't get printed in logs\n * @param {Array<mixed>} args\n * @private\n * @memberof Logger\n * @returns {Array<mixed>}\n */\n filter(...args) {\n return args.map((arg) => {\n // WebexHttpError already ensures auth tokens don't get printed, so, no\n // need to alter it here.\n if (arg instanceof Error) {\n // karma logs won't print subclassed errors correctly, so we need\n // explicitly call their tostring methods.\n if (process.env.NODE_ENV === 'test' && inBrowser) {\n let ret = arg.toString();\n\n ret += 'BEGIN STACK';\n ret += arg.stack;\n ret += 'END STACK';\n\n return ret;\n }\n\n return arg;\n }\n\n arg = cloneDeep(arg);\n\n return walkAndFilter(arg);\n });\n },\n\n /**\n * Determines if the current level allows logs at the specified level to be\n * printed\n * @param {string} level\n * @param {string} type type of log, SDK or client\n * @private\n * @memberof Logger\n * @returns {boolean}\n */\n shouldPrint(level, type = LOG_TYPES.SDK) {\n return (\n precedence[level] <=\n precedence[type === LOG_TYPES.SDK ? this.getCurrentLevel() : this.getCurrentClientLevel()]\n );\n },\n\n /**\n * Determines if the current level allows logs at the specified level to be\n * put into the log buffer. We're configuring it omit trace and debug logs\n * because there are *a lot* of debug logs that really don't provide value at\n * runtime (they're helpful for debugging locally, but really just pollute the\n * uploaded logs and push useful info out).\n * @param {string} level\n * @param {string} type type of log, SDK or client\n * @private\n * @memberof Logger\n * @returns {boolean}\n */\n shouldBuffer(level) {\n return (\n precedence[level] <=\n (this.config.bufferLogLevel ? precedence[this.config.bufferLogLevel] : precedence.info)\n );\n },\n\n /**\n * Indicates the current SDK log level based on env vars, feature toggles, and\n * user type.\n * @instance\n * @memberof Logger\n * @private\n * @memberof Logger\n * @returns {string}\n */\n // eslint-disable-next-line complexity\n getCurrentLevel() {\n // If a level has been explicitly set via config, alway use it.\n if (this.config.level) {\n return this.config.level;\n }\n\n if (levels.includes(process.env.WEBEX_LOG_LEVEL)) {\n return process.env.WEBEX_LOG_LEVEL;\n }\n\n // Always use debug-level logging in test mode;\n if (process.env.NODE_ENV === 'test') {\n return 'trace';\n }\n\n // Use server-side-feature toggles to configure log levels\n const level =\n this.webex.internal.device && this.webex.internal.device.features.developer.get('log-level');\n\n if (level) {\n if (levels.includes(level)) {\n return level;\n }\n }\n\n return 'error';\n },\n\n /**\n * Indicates the current client log level based on config, defaults to SDK level\n * @instance\n * @memberof Logger\n * @private\n * @memberof Logger\n * @returns {string}\n */\n getCurrentClientLevel() {\n // If a client log level has been explicitly set via config, alway use it.\n if (this.config.clientLevel) {\n return this.config.clientLevel;\n }\n\n // otherwise default to SDK level\n return this.getCurrentLevel();\n },\n\n /**\n * Format logs (for upload)\n *\n * If separate client, SDK buffers is configured, merge the buffers, if configured\n *\n * @instance\n * @memberof Logger\n * @public\n * @memberof Logger\n * @param {Object} options\n * @param {boolean} options.diff whether to only format the diff from last call to formatLogs(), false by default\n * @returns {string} formatted buffer\n */\n formatLogs(options = {}) {\n function getDate(log) {\n return log[1];\n }\n const {diff = false} = options;\n let buffer = [];\n let clientIndex = diff ? this.clientBuffer.nextIndex : 0;\n let sdkIndex = diff ? this.sdkBuffer.nextIndex : 0;\n\n if (this.config.separateLogBuffers) {\n // merge the client and sdk buffers\n // while we have entries in either buffer\n while (\n clientIndex < this.clientBuffer.buffer.length ||\n sdkIndex < this.sdkBuffer.buffer.length\n ) {\n // if we have remaining entries in the SDK buffer\n if (\n sdkIndex < this.sdkBuffer.buffer.length &&\n // and we haven't exhausted all the client buffer entries, or SDK date is before client date\n (clientIndex >= this.clientBuffer.buffer.length ||\n new Date(getDate(this.sdkBuffer.buffer[sdkIndex])) <=\n new Date(getDate(this.clientBuffer.buffer[clientIndex])))\n ) {\n // then add to the SDK buffer\n buffer.push(this.sdkBuffer.buffer[sdkIndex]);\n sdkIndex += 1;\n }\n // otherwise if we haven't exhausted all the client buffer entries, add client entry, whether it was because\n // it was the only remaining entries or date was later (the above if)\n else if (clientIndex < this.clientBuffer.buffer.length) {\n buffer.push(this.clientBuffer.buffer[clientIndex]);\n clientIndex += 1;\n }\n }\n if (diff) {\n this.clientBuffer.nextIndex = clientIndex;\n this.sdkBuffer.nextIndex = sdkIndex;\n }\n } else if (diff) {\n buffer = this.buffer.buffer.slice(this.buffer.nextIndex);\n this.buffer.nextIndex = this.buffer.buffer.length;\n } else {\n buffer = this.buffer.buffer;\n }\n\n return buffer.join('\\n');\n },\n});\n\n/**\n * Creates a logger method\n *\n *\n * @param {string} level level to create (info, error, warn, etc.)\n * @param {string} impl the level to use when writing to console\n * @param {string} type type of log, SDK or client\n * @param {bool} neverPrint function never prints to console\n * @param {bool} alwaysBuffer function always logs to log buffer\n * @instance\n * @memberof Logger\n * @private\n * @memberof Logger\n * @returns {function} logger method with specified params\n */\nfunction makeLoggerMethod(level, impl, type, neverPrint = false, alwaysBuffer = false) {\n // Much of the complexity in the following function is due to a test-mode-only\n // helper\n return function wrappedConsoleMethod(...args) {\n // it would be easier to just pass in the name and buffer here, but the config isn't completely initialized\n // in Ampersand, even if the initialize method is used to set this up. so we keep the type to achieve\n // a sort of late binding to allow retrieving a name from config.\n const logType = type;\n const clientName =\n logType === LOG_TYPES.SDK ? SDK_LOG_TYPE_NAME : this.config.clientName || logType;\n\n let bufferRef;\n let historyLength;\n\n if (this.config.separateLogBuffers) {\n historyLength = this.config.clientHistoryLength\n ? this.config.clientHistoryLength\n : this.config.historyLength;\n bufferRef = logType === LOG_TYPES.SDK ? this.sdkBuffer : this.clientBuffer;\n } else {\n bufferRef = this.buffer;\n historyLength = this.config.historyLength;\n }\n\n try {\n const shouldPrint = !neverPrint && this.shouldPrint(level, logType);\n const shouldBuffer = alwaysBuffer || this.shouldBuffer(level);\n\n if (!shouldBuffer && !shouldPrint) {\n return;\n }\n\n const filtered = [clientName, ...this.filter(...args)];\n const stringified = filtered.map((item) => {\n if (item instanceof Error) {\n return item.toString();\n }\n if (typeof item === 'object') {\n let cache = [];\n let returnItem;\n try {\n returnItem = JSON.stringify(item, (_key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (cache.includes(value)) {\n // Circular reference found, discard key\n return undefined;\n }\n // Store value in our collection\n cache.push(value);\n }\n\n return value;\n });\n } catch (e) {\n returnItem = `Failed to stringify: ${item}`;\n }\n cache = null;\n\n return returnItem;\n }\n\n return item;\n });\n\n if (shouldPrint) {\n // when logging an object in browsers, we tend to get a dynamic\n // reference, thus going back to look at the logged value doesn't\n // necessarily show the state at log time, thus we print the stringified\n // value.\n const toPrint = inBrowser ? stringified : filtered;\n\n /* istanbul ignore if */\n if (process.env.NODE_ENV === 'test' && has(this, 'webex.internal.device.url')) {\n toPrint.unshift(this.webex.internal.device.url.slice(-3));\n }\n // eslint-disable-next-line no-console\n console[impl](...toPrint);\n }\n\n if (shouldBuffer) {\n const logDate = new Date();\n\n stringified.unshift(logDate.toISOString());\n stringified.unshift('| '.repeat(this.groupLevel));\n bufferRef.buffer.push(stringified);\n if (bufferRef.buffer.length > historyLength) {\n // we've gone over the buffer limit, trim it down\n const deleteCount = bufferRef.buffer.length - historyLength;\n\n bufferRef.buffer.splice(0, deleteCount);\n\n // and adjust the corresponding buffer index used for log diff uploads\n bufferRef.nextIndex -= deleteCount;\n if (bufferRef.nextIndex < 0) {\n bufferRef.nextIndex = 0;\n }\n }\n if (level === 'group') this.groupLevel += 1;\n if (level === 'groupEnd' && this.groupLevel > 0) this.groupLevel -= 1;\n }\n } catch (reason) {\n if (!neverPrint) {\n /* istanbul ignore next */\n // eslint-disable-next-line no-console\n console.warn(`failed to execute Logger#${level}`, reason);\n }\n }\n };\n}\n\nlevels.forEach((level) => {\n let impls = fallbacks[level];\n let impl = level;\n\n if (impls) {\n impls = impls.slice();\n // eslint-disable-next-line no-console\n while (!console[impl]) {\n impl = impls.pop();\n }\n }\n\n // eslint-disable-next-line complexity\n Logger.prototype[`client_${level}`] = makeLoggerMethod(level, impl, LOG_TYPES.CLIENT);\n Logger.prototype[level] = makeLoggerMethod(level, impl, LOG_TYPES.SDK);\n});\n\nLogger.prototype.client_logToBuffer = makeLoggerMethod(\n levels.info,\n levels.info,\n LOG_TYPES.CLIENT,\n true,\n true\n);\nLogger.prototype.logToBuffer = makeLoggerMethod(\n levels.info,\n levels.info,\n LOG_TYPES.SDK,\n true,\n true\n);\n\nexport default Logger;\n"],"mappings":";;;;;;;;;;;;;;;AAIA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AANA;AACA;AACA;;AAMA,IAAMG,UAAU,GAAG;EACjBC,MAAM,EAAE,CAAC;EACTC,KAAK,EAAE,CAAC;EACRC,QAAQ,EAAE,CAAC;EACXC,KAAK,EAAE,CAAC;EACRC,IAAI,EAAE,CAAC;EACPC,GAAG,EAAE,CAAC;EACNC,IAAI,EAAE,CAAC;EACPC,KAAK,EAAE,CAAC;EACRC,KAAK,EAAE;AACT,CAAC;AAEM,IAAMC,MAAM,GAAAC,OAAA,CAAAD,MAAA,GAAG,IAAAE,KAAA,CAAAC,OAAA,EAAYb,UAAU,CAAC,CAACc,MAAM,CAAC,UAACC,KAAK;EAAA,OAAKA,KAAK,KAAK,QAAQ;AAAA,EAAC;AAEnF,IAAMC,SAAS,GAAG;EAChBZ,KAAK,EAAE,CAAC,KAAK,CAAC;EACdC,IAAI,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC;EACtBE,IAAI,EAAE,CAAC,KAAK,CAAC;EACbC,KAAK,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;EACtB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ACF,CAAC;AACH;AAEA7H,MAAM,CAAC8H,OAAO,CAAC,UAACzH,KAAK,EAAK;EACxB,IAAI0H,KAAK,GAAGzH,SAAS,CAACD,KAAK,CAAC;EAC5B,IAAIyF,IAAI,GAAGzF,KAAK;EAEhB,IAAI0H,KAAK,EAAE;IACTA,KAAK,GAAGA,KAAK,CAACrC,KAAK,CAAC,CAAC;IACrB;IACA,OAAO,CAAC6B,OAAO,CAACzB,IAAI,CAAC,EAAE;MACrBA,IAAI,GAAGiC,KAAK,CAACC,GAAG,CAAC,CAAC;IACpB;EACF;;EAEA;EACA1F,MAAM,CAAC2F,SAAS,WAAAzB,MAAA,CAAWnG,KAAK,EAAG,GAAGwF,gBAAgB,CAACxF,KAAK,EAAEyF,IAAI,EAAEvF,SAAS,CAACE,MAAM,CAAC;EACrF6B,MAAM,CAAC2F,SAAS,CAAC5H,KAAK,CAAC,GAAGwF,gBAAgB,CAACxF,KAAK,EAAEyF,IAAI,EAAEvF,SAAS,CAACC,GAAG,CAAC;AACxE,CAAC,CAAC;AAEF8B,MAAM,CAAC2F,SAAS,CAACC,kBAAkB,GAAGrC,gBAAgB,CACpD7F,MAAM,CAACH,IAAI,EACXG,MAAM,CAACH,IAAI,EACXU,SAAS,CAACE,MAAM,EAChB,IAAI,EACJ,IACF,CAAC;AACD6B,MAAM,CAAC2F,SAAS,CAACE,WAAW,GAAGtC,gBAAgB,CAC7C7F,MAAM,CAACH,IAAI,EACXG,MAAM,CAACH,IAAI,EACXU,SAAS,CAACC,GAAG,EACb,IAAI,EACJ,IACF,CAAC;AAAC,IAAA4H,SAAA,GAAAnI,OAAA,CAAAE,OAAA,GAEamC,MAAM","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_common","require","_webexCore","_lodash","precedence","silent","group","groupEnd","error","warn","log","info","debug","trace","levels","exports","_keys","default","filter","level","fallbacks","LOG_TYPES","SDK","CLIENT","SDK_LOG_TYPE_NAME","authTokenKeyPattern","walkAndFilter","object","visited","arguments","length","undefined","includes","push","isArray","map","o","isObject","isString","patterns","containsEmails","test","replace","containsMTID","_i","_Object$entries","_entries","_Object$entries$_i","_slicedToArray2","key","value","_deleteProperty","Logger","WebexPlugin","extend","namespace","derived","cache","fn","getCurrentLevel","client_level","getCurrentClientLevel","session","buffer","type","nextIndex","lastSubmitted","groupLevel","sdkBuffer","clientBuffer","_len","args","Array","_key2","arg","Error","process","env","NODE_ENV","inBrowser","ret","toString","stack","cloneDeep","shouldPrint","shouldBuffer","config","bufferLogLevel","WEBEX_LOG_LEVEL","webex","internal","device","features","developer","get","clientLevel","formatLogs","options","getDate","_options$diff","diff","clientIndex","sdkIndex","separateLogBuffers","Date","slice","join","updateLastSubmittedIndex","resetBufferToLastSuccessfulUpload","version","makeLoggerMethod","impl","neverPrint","alwaysBuffer","wrappedConsoleMethod","logType","clientName","bufferRef","historyLength","clientHistoryLength","filtered","concat","_toConsumableArray2","apply","stringified","item","_typeof2","returnItem","_stringify","_key","e","_console","toPrint","has","unshift","url","console","logDate","toISOString","repeat","deleteCount","splice","reason","forEach","impls","pop","prototype","client_logToBuffer","logToBuffer","_default2"],"sources":["logger.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {inBrowser, patterns} from '@webex/common';\nimport {WebexPlugin} from '@webex/webex-core';\nimport {cloneDeep, has, isArray, isObject, isString} from 'lodash';\n\nconst precedence = {\n silent: 0,\n group: 1,\n groupEnd: 2,\n error: 3,\n warn: 4,\n log: 5,\n info: 6,\n debug: 7,\n trace: 8,\n};\n\nexport const levels = Object.keys(precedence).filter((level) => level !== 'silent');\n\nconst fallbacks = {\n error: ['log'],\n warn: ['error', 'log'],\n info: ['log'],\n debug: ['info', 'log'],\n trace: ['debug', 'info', 'log'],\n};\n\nconst LOG_TYPES = {\n SDK: 'sdk',\n CLIENT: 'client',\n};\n\nconst SDK_LOG_TYPE_NAME = 'wx-js-sdk';\n\nconst authTokenKeyPattern = /[Aa]uthorization/;\n\n/**\n * Recursively strips \"authorization\" fields from the specified object\n * @param {Object} object\n * @param {Array<mixed>} [visited]\n * @private\n * @returns {Object}\n */\nfunction walkAndFilter(object, visited = []) {\n if (visited.includes(object)) {\n // Prevent circular references\n return object;\n }\n\n visited.push(object);\n\n if (isArray(object)) {\n return object.map((o) => walkAndFilter(o, visited));\n }\n if (!isObject(object)) {\n if (isString(object)) {\n if (patterns.containsEmails.test(object)) {\n return object.replace(patterns.containsEmails, '[REDACTED]');\n }\n if (patterns.containsMTID.test(object)) {\n return object.replace(patterns.containsMTID, '$1[REDACTED]');\n }\n }\n\n return object;\n }\n\n for (const [key, value] of Object.entries(object)) {\n if (authTokenKeyPattern.test(key)) {\n Reflect.deleteProperty(object, key);\n } else {\n object[key] = walkAndFilter(value, visited);\n }\n }\n\n return object;\n}\n\n/**\n * @class\n */\nconst Logger = WebexPlugin.extend({\n namespace: 'Logger',\n\n derived: {\n level: {\n cache: false,\n fn() {\n return this.getCurrentLevel();\n },\n },\n client_level: {\n cache: false,\n fn() {\n return this.getCurrentClientLevel();\n },\n },\n },\n session: {\n // for when configured to use single buffer\n buffer: {\n type: 'object',\n default() {\n return {\n buffer: [],\n nextIndex: 0,\n lastSubmitted: 0,\n };\n },\n },\n groupLevel: {\n type: 'number',\n default() {\n return 0;\n },\n },\n // for when configured to use separate buffers\n sdkBuffer: {\n type: 'object',\n default() {\n return {\n buffer: [],\n nextIndex: 0,\n lastSubmitted: 0,\n };\n },\n },\n clientBuffer: {\n type: 'object',\n default() {\n return {\n buffer: [],\n nextIndex: 0,\n lastSubmitted: 0,\n };\n },\n },\n },\n\n /**\n * Ensures auth headers don't get printed in logs\n * @param {Array<mixed>} args\n * @private\n * @memberof Logger\n * @returns {Array<mixed>}\n */\n filter(...args) {\n return args.map((arg) => {\n // WebexHttpError already ensures auth tokens don't get printed, so, no\n // need to alter it here.\n if (arg instanceof Error) {\n // karma logs won't print subclassed errors correctly, so we need\n // explicitly call their tostring methods.\n if (process.env.NODE_ENV === 'test' && inBrowser) {\n let ret = arg.toString();\n\n ret += 'BEGIN STACK';\n ret += arg.stack;\n ret += 'END STACK';\n\n return ret;\n }\n\n return arg;\n }\n\n arg = cloneDeep(arg);\n\n return walkAndFilter(arg);\n });\n },\n\n /**\n * Determines if the current level allows logs at the specified level to be\n * printed\n * @param {string} level\n * @param {string} type type of log, SDK or client\n * @private\n * @memberof Logger\n * @returns {boolean}\n */\n shouldPrint(level, type = LOG_TYPES.SDK) {\n return (\n precedence[level] <=\n precedence[type === LOG_TYPES.SDK ? this.getCurrentLevel() : this.getCurrentClientLevel()]\n );\n },\n\n /**\n * Determines if the current level allows logs at the specified level to be\n * put into the log buffer. We're configuring it omit trace and debug logs\n * because there are *a lot* of debug logs that really don't provide value at\n * runtime (they're helpful for debugging locally, but really just pollute the\n * uploaded logs and push useful info out).\n * @param {string} level\n * @param {string} type type of log, SDK or client\n * @private\n * @memberof Logger\n * @returns {boolean}\n */\n shouldBuffer(level) {\n return (\n precedence[level] <=\n (this.config.bufferLogLevel ? precedence[this.config.bufferLogLevel] : precedence.info)\n );\n },\n\n /**\n * Indicates the current SDK log level based on env vars, feature toggles, and\n * user type.\n * @instance\n * @memberof Logger\n * @private\n * @memberof Logger\n * @returns {string}\n */\n // eslint-disable-next-line complexity\n getCurrentLevel() {\n // If a level has been explicitly set via config, alway use it.\n if (this.config.level) {\n return this.config.level;\n }\n\n if (levels.includes(process.env.WEBEX_LOG_LEVEL)) {\n return process.env.WEBEX_LOG_LEVEL;\n }\n\n // Always use debug-level logging in test mode;\n if (process.env.NODE_ENV === 'test') {\n return 'trace';\n }\n\n // Use server-side-feature toggles to configure log levels\n const level =\n this.webex.internal.device && this.webex.internal.device.features.developer.get('log-level');\n\n if (level) {\n if (levels.includes(level)) {\n return level;\n }\n }\n\n return 'error';\n },\n\n /**\n * Indicates the current client log level based on config, defaults to SDK level\n * @instance\n * @memberof Logger\n * @private\n * @memberof Logger\n * @returns {string}\n */\n getCurrentClientLevel() {\n // If a client log level has been explicitly set via config, alway use it.\n if (this.config.clientLevel) {\n return this.config.clientLevel;\n }\n\n // otherwise default to SDK level\n return this.getCurrentLevel();\n },\n\n /**\n * Format logs (for upload)\n *\n * If separate client, SDK buffers is configured, merge the buffers, if configured\n *\n * @instance\n * @memberof Logger\n * @public\n * @memberof Logger\n * @param {Object} options\n * @param {boolean} options.diff whether to only format the diff from last call to formatLogs(), false by default\n * @returns {string} formatted buffer\n */\n formatLogs(options = {}) {\n function getDate(log) {\n return log[1];\n }\n const {diff = false} = options;\n let buffer = [];\n let clientIndex = diff ? this.clientBuffer.nextIndex : 0;\n let sdkIndex = diff ? this.sdkBuffer.nextIndex : 0;\n\n if (this.config.separateLogBuffers) {\n // merge the client and sdk buffers\n // while we have entries in either buffer\n while (\n clientIndex < this.clientBuffer.buffer.length ||\n sdkIndex < this.sdkBuffer.buffer.length\n ) {\n // if we have remaining entries in the SDK buffer\n if (\n sdkIndex < this.sdkBuffer.buffer.length &&\n // and we haven't exhausted all the client buffer entries, or SDK date is before client date\n (clientIndex >= this.clientBuffer.buffer.length ||\n new Date(getDate(this.sdkBuffer.buffer[sdkIndex])) <=\n new Date(getDate(this.clientBuffer.buffer[clientIndex])))\n ) {\n // then add to the SDK buffer\n buffer.push(this.sdkBuffer.buffer[sdkIndex]);\n sdkIndex += 1;\n }\n // otherwise if we haven't exhausted all the client buffer entries, add client entry, whether it was because\n // it was the only remaining entries or date was later (the above if)\n else if (clientIndex < this.clientBuffer.buffer.length) {\n buffer.push(this.clientBuffer.buffer[clientIndex]);\n clientIndex += 1;\n }\n }\n if (diff) {\n this.clientBuffer.nextIndex = clientIndex;\n this.sdkBuffer.nextIndex = sdkIndex;\n }\n } else if (diff) {\n buffer = this.buffer.buffer.slice(this.buffer.nextIndex);\n this.buffer.nextIndex = this.buffer.buffer.length;\n } else {\n buffer = this.buffer.buffer;\n }\n\n return buffer.join('\\n');\n },\n\n /**\n * Update the last submitted index in the buffers to the current nextIndex\n *\n * @returns {void}\n */\n updateLastSubmittedIndex() {\n if (this.config.separateLogBuffers) {\n this.clientBuffer.lastSubmitted = this.clientBuffer.nextIndex;\n this.sdkBuffer.lastSubmitted = this.sdkBuffer.nextIndex;\n } else {\n this.buffer.lastSubmitted = this.buffer.nextIndex;\n }\n },\n\n /**\n * Reset the nextIndex in the buffers to the last successful upload index, effectively including any logs since the last successful upload in the next upload\n *\n * @returns {void}\n */\n resetBufferToLastSuccessfulUpload() {\n if (this.config.separateLogBuffers) {\n this.clientBuffer.nextIndex = this.clientBuffer.lastSubmitted;\n this.sdkBuffer.nextIndex = this.sdkBuffer.lastSubmitted;\n } else {\n this.buffer.nextIndex = this.buffer.lastSubmitted;\n }\n },\n});\n\n/**\n * Creates a logger method\n *\n *\n * @param {string} level level to create (info, error, warn, etc.)\n * @param {string} impl the level to use when writing to console\n * @param {string} type type of log, SDK or client\n * @param {bool} neverPrint function never prints to console\n * @param {bool} alwaysBuffer function always logs to log buffer\n * @instance\n * @memberof Logger\n * @private\n * @memberof Logger\n * @returns {function} logger method with specified params\n */\nfunction makeLoggerMethod(level, impl, type, neverPrint = false, alwaysBuffer = false) {\n // Much of the complexity in the following function is due to a test-mode-only\n // helper\n return function wrappedConsoleMethod(...args) {\n // it would be easier to just pass in the name and buffer here, but the config isn't completely initialized\n // in Ampersand, even if the initialize method is used to set this up. so we keep the type to achieve\n // a sort of late binding to allow retrieving a name from config.\n const logType = type;\n const clientName =\n logType === LOG_TYPES.SDK ? SDK_LOG_TYPE_NAME : this.config.clientName || logType;\n\n let bufferRef;\n let historyLength;\n\n if (this.config.separateLogBuffers) {\n historyLength = this.config.clientHistoryLength\n ? this.config.clientHistoryLength\n : this.config.historyLength;\n bufferRef = logType === LOG_TYPES.SDK ? this.sdkBuffer : this.clientBuffer;\n } else {\n bufferRef = this.buffer;\n historyLength = this.config.historyLength;\n }\n\n try {\n const shouldPrint = !neverPrint && this.shouldPrint(level, logType);\n const shouldBuffer = alwaysBuffer || this.shouldBuffer(level);\n\n if (!shouldBuffer && !shouldPrint) {\n return;\n }\n\n const filtered = [clientName, ...this.filter(...args)];\n const stringified = filtered.map((item) => {\n if (item instanceof Error) {\n return item.toString();\n }\n if (typeof item === 'object') {\n let cache = [];\n let returnItem;\n try {\n returnItem = JSON.stringify(item, (_key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (cache.includes(value)) {\n // Circular reference found, discard key\n return undefined;\n }\n // Store value in our collection\n cache.push(value);\n }\n\n return value;\n });\n } catch (e) {\n returnItem = `Failed to stringify: ${item}`;\n }\n cache = null;\n\n return returnItem;\n }\n\n return item;\n });\n\n if (shouldPrint) {\n // when logging an object in browsers, we tend to get a dynamic\n // reference, thus going back to look at the logged value doesn't\n // necessarily show the state at log time, thus we print the stringified\n // value.\n const toPrint = inBrowser ? stringified : filtered;\n\n /* istanbul ignore if */\n if (process.env.NODE_ENV === 'test' && has(this, 'webex.internal.device.url')) {\n toPrint.unshift(this.webex.internal.device.url.slice(-3));\n }\n // eslint-disable-next-line no-console\n console[impl](...toPrint);\n }\n\n if (shouldBuffer) {\n const logDate = new Date();\n\n stringified.unshift(logDate.toISOString());\n stringified.unshift('| '.repeat(this.groupLevel));\n bufferRef.buffer.push(stringified);\n if (bufferRef.buffer.length > historyLength) {\n // we've gone over the buffer limit, trim it down\n const deleteCount = bufferRef.buffer.length - historyLength;\n\n bufferRef.buffer.splice(0, deleteCount);\n\n // and adjust the corresponding buffer index used for log diff uploads\n bufferRef.nextIndex -= deleteCount;\n if (bufferRef.nextIndex < 0) {\n bufferRef.nextIndex = 0;\n }\n\n bufferRef.lastSubmitted -= deleteCount;\n if (bufferRef.lastSubmitted < 0) {\n bufferRef.lastSubmitted = 0;\n }\n }\n if (level === 'group') this.groupLevel += 1;\n if (level === 'groupEnd' && this.groupLevel > 0) this.groupLevel -= 1;\n }\n } catch (reason) {\n if (!neverPrint) {\n /* istanbul ignore next */\n // eslint-disable-next-line no-console\n console.warn(`failed to execute Logger#${level}`, reason);\n }\n }\n };\n}\n\nlevels.forEach((level) => {\n let impls = fallbacks[level];\n let impl = level;\n\n if (impls) {\n impls = impls.slice();\n // eslint-disable-next-line no-console\n while (!console[impl]) {\n impl = impls.pop();\n }\n }\n\n // eslint-disable-next-line complexity\n Logger.prototype[`client_${level}`] = makeLoggerMethod(level, impl, LOG_TYPES.CLIENT);\n Logger.prototype[level] = makeLoggerMethod(level, impl, LOG_TYPES.SDK);\n});\n\nLogger.prototype.client_logToBuffer = makeLoggerMethod(\n levels.info,\n levels.info,\n LOG_TYPES.CLIENT,\n true,\n true\n);\nLogger.prototype.logToBuffer = makeLoggerMethod(\n levels.info,\n levels.info,\n LOG_TYPES.SDK,\n true,\n true\n);\n\nexport default Logger;\n"],"mappings":";;;;;;;;;;;;;;;AAIA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AANA;AACA;AACA;;AAMA,IAAMG,UAAU,GAAG;EACjBC,MAAM,EAAE,CAAC;EACTC,KAAK,EAAE,CAAC;EACRC,QAAQ,EAAE,CAAC;EACXC,KAAK,EAAE,CAAC;EACRC,IAAI,EAAE,CAAC;EACPC,GAAG,EAAE,CAAC;EACNC,IAAI,EAAE,CAAC;EACPC,KAAK,EAAE,CAAC;EACRC,KAAK,EAAE;AACT,CAAC;AAEM,IAAMC,MAAM,GAAAC,OAAA,CAAAD,MAAA,GAAG,IAAAE,KAAA,CAAAC,OAAA,EAAYb,UAAU,CAAC,CAACc,MAAM,CAAC,UAACC,KAAK;EAAA,OAAKA,KAAK,KAAK,QAAQ;AAAA,EAAC;AAEnF,IAAMC,SAAS,GAAG;EAChBZ,KAAK,EAAE,CAAC,KAAK,CAAC;EACdC,IAAI,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC;EACtBE,IAAI,EAAE,CAAC,KAAK,CAAC;EACbC,KAAK,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;EACtBC,KAAK,EAAE,CAAC,OAAO,EAAE,MA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AGiC,KAAK,CAACC,GAAG,CAAC,CAAC;IACpB;EACF;;EAEA;EACA7F,MAAM,CAAC8F,SAAS,WAAAzB,MAAA,CAAWtG,KAAK,EAAG,GAAG2F,gBAAgB,CAAC3F,KAAK,EAAE4F,IAAI,EAAE1F,SAAS,CAACE,MAAM,CAAC;EACrF6B,MAAM,CAAC8F,SAAS,CAAC/H,KAAK,CAAC,GAAG2F,gBAAgB,CAAC3F,KAAK,EAAE4F,IAAI,EAAE1F,SAAS,CAACC,GAAG,CAAC;AACxE,CAAC,CAAC;AAEF8B,MAAM,CAAC8F,SAAS,CAACC,kBAAkB,GAAGrC,gBAAgB,CACpDhG,MAAM,CAACH,IAAI,EACXG,MAAM,CAACH,IAAI,EACXU,SAAS,CAACE,MAAM,EAChB,IAAI,EACJ,IACF,CAAC;AACD6B,MAAM,CAAC8F,SAAS,CAACE,WAAW,GAAGtC,gBAAgB,CAC7ChG,MAAM,CAACH,IAAI,EACXG,MAAM,CAACH,IAAI,EACXU,SAAS,CAACC,GAAG,EACb,IAAI,EACJ,IACF,CAAC;AAAC,IAAA+H,SAAA,GAAAtI,OAAA,CAAAE,OAAA,GAEamC,MAAM","ignoreList":[]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: ADR
|
|
3
|
+
title: ADR-0001 - Retain the product README
|
|
4
|
+
description: Stage 0 keeps README.md as product documentation and does not route it as a spec source.
|
|
5
|
+
tags: [adr]
|
|
6
|
+
timestamp: 2026-10-06T00:00:00Z
|
|
7
|
+
status: accepted
|
|
8
|
+
---
|
|
9
|
+
<!-- sdd-generated-metadata
|
|
10
|
+
doc_kind: standing-doc
|
|
11
|
+
generated_from: adr@0.3.0
|
|
12
|
+
generated_by: claude-cowork
|
|
13
|
+
approved_by: akulakum@cisco.com
|
|
14
|
+
updated_at: 2026-10-08T08:51:39Z
|
|
15
|
+
validation_status: pass-with-warnings
|
|
16
|
+
-->
|
|
17
|
+
|
|
18
|
+
# ADR-0001 - Retain the product README
|
|
19
|
+
|
|
20
|
+
| Field | Value |
|
|
21
|
+
| ------------- | ----- |
|
|
22
|
+
| Status | Accepted |
|
|
23
|
+
| Decision date | 2026-10-06 |
|
|
24
|
+
| Deciders | akulakum@cisco.com (bootstrap questionnaire) |
|
|
25
|
+
| Supersedes | N/A |
|
|
26
|
+
| Superseded by | N/A |
|
|
27
|
+
|
|
28
|
+
## Context
|
|
29
|
+
|
|
30
|
+
Stage 0 found one existing document, `README.md`. It is a product usage page. It lists the levels `silent`, `error`, `warn`, `log`, `info`, `debug`, and `trace`, names `error` as the default, and shows `WEBEX_LOG_LEVEL` as the control.
|
|
31
|
+
|
|
32
|
+
The implementation in `src/logger.js` also exposes `group` and `groupEnd`, `client_` variants of every level, `logToBuffer`, buffers, `formatLogs`, and seven `config.logger` keys. The README does not describe them. `silent` is a precedence value in `src/logger.js` but is not part of the exported `levels` array.
|
|
33
|
+
|
|
34
|
+
No other intent spec, design spec, or AI-authored spec exists in this package.
|
|
35
|
+
|
|
36
|
+
## Decision
|
|
37
|
+
|
|
38
|
+
Keep `README.md` unchanged. Do not migrate it into `src/docs/README.md`. Record `spec_source_policy.mode` as `keep-separate` with `migrated_source_disposition` `retain` and an empty `spec_sources` list.
|
|
39
|
+
|
|
40
|
+
The canonical behavior is `src/` plus `test/unit/spec/logger.js`. Where the product README is incomplete, code wins. That gap is not a defect in the retained product page.
|
|
41
|
+
|
|
42
|
+
## Why
|
|
43
|
+
|
|
44
|
+
The README is the npm-facing usage page. Rewriting it is a product-doc change, not a requirement of making the package SDD-ready. Its statements that are present agree with the code, so routing it as a spec source would add little.
|
|
45
|
+
|
|
46
|
+
## Alternatives considered
|
|
47
|
+
|
|
48
|
+
- Migrate the README into the module spec and delete it. Rejected because the page is a retained product document, and deletion was not requested.
|
|
49
|
+
- Expand the README during Stage 0. Rejected because Stage 0 is documentation for the SDD tree and does not edit `README.md`.
|
|
50
|
+
|
|
51
|
+
## Consequences
|
|
52
|
+
|
|
53
|
+
- Agents must not treat `README.md` as the full list of levels, methods, or config keys.
|
|
54
|
+
- Future README improvements are a separate product-doc change.
|
|
55
|
+
- `src/docs/README.md` is the protected canonical spec.
|
|
56
|
+
|
|
57
|
+
## Constraint on future changes
|
|
58
|
+
|
|
59
|
+
Do not delete `README.md` as part of spec maintenance. If its usage text is extended, keep the change in that file and leave the module spec aligned with code.
|
|
60
|
+
|
|
61
|
+
## Follow-up
|
|
62
|
+
|
|
63
|
+
None required for Stage 0.
|
|
64
|
+
|
|
65
|
+
## Revisit when
|
|
66
|
+
|
|
67
|
+
A maintainer chooses to document client logging, buffers, or upload formatting on the npm usage page.
|
|
68
|
+
|
|
69
|
+
## References
|
|
70
|
+
|
|
71
|
+
- `README.md`
|
|
72
|
+
- `src/index.js`
|
|
73
|
+
- `src/logger.js`
|
|
74
|
+
- `src/config.js`
|
|
75
|
+
- `test/unit/spec/logger.js`
|
|
76
|
+
- `.sdd/manifest.json` `spec_source_policy`
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!-- sdd-generated-metadata
|
|
2
|
+
doc_kind: standing-doc
|
|
3
|
+
generated_from: adr-index@0.3.0
|
|
4
|
+
generated_by: claude-cowork
|
|
5
|
+
approved_by: akulakum@cisco.com
|
|
6
|
+
updated_at: 2026-10-08T08:51:39Z
|
|
7
|
+
validation_status: pass-with-warnings
|
|
8
|
+
-->
|
|
9
|
+
|
|
10
|
+
# Architectural decision records
|
|
11
|
+
|
|
12
|
+
Durable decisions for this package. The module specification owns current behavior. An ADR owns why a documentation or structural choice was made.
|
|
13
|
+
|
|
14
|
+
## Index
|
|
15
|
+
|
|
16
|
+
| ADR | Title | Status |
|
|
17
|
+
| --- | ----- | ------ |
|
|
18
|
+
| [0001](0001-retain-product-readme.md) | Retain the product README and treat code as the behavioral authority | Accepted |
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: Architecture
|
|
3
|
+
title: '@webex/plugin-logger architecture'
|
|
4
|
+
description: Package-wide boundaries, resources, interactions, dependencies, and cross-cutting architecture.
|
|
5
|
+
tags: [architecture]
|
|
6
|
+
---
|
|
7
|
+
<!-- sdd-generated-metadata
|
|
8
|
+
doc_kind: standing-doc
|
|
9
|
+
generated_from: architecture@0.3.0
|
|
10
|
+
generated_by: claude-cowork
|
|
11
|
+
approved_by: akulakum@cisco.com
|
|
12
|
+
updated_at: 2026-10-08T08:51:39Z
|
|
13
|
+
validation_status: pass-with-warnings
|
|
14
|
+
-->
|
|
15
|
+
|
|
16
|
+
# @webex/plugin-logger architecture
|
|
17
|
+
|
|
18
|
+
Canonical architecture for this package. Logger behavior lives in the [module specification](../src/docs/README.md). This page owns package boundaries, the plugin registration, the published contract, and how logs leave the package.
|
|
19
|
+
|
|
20
|
+
Related context: [specification registry](specs/README.md) · [package agent instructions](../AGENTS.md)
|
|
21
|
+
|
|
22
|
+
## Applicability
|
|
23
|
+
|
|
24
|
+
| Condition ID | Status | Evidence or reason | Owned section |
|
|
25
|
+
| ------------ | ------ | ------------------ | ------------- |
|
|
26
|
+
| `repo.owns_datastore` | N/A | No database, file store, or migration in `src/` | Repository data and schema |
|
|
27
|
+
| `repo.holds_client_state` | Applicable | `Logger` keeps three in-memory buffers and a group counter as session state | Client state model |
|
|
28
|
+
| `repo.components_interact` | Applicable | `src/index.js` registers `src/logger.js` with `src/config.js` through `@webex/webex-core` | Dependency and interaction topology |
|
|
29
|
+
| `repo.domain_data_across_components` | N/A | One plugin owns the buffers. No shared domain record. | Object and data ownership |
|
|
30
|
+
| `repo.caches_data` | N/A | Buffers are bounded history, not a cache of fetched data | Caching catalog |
|
|
31
|
+
| `repo.observability_convention` | Applicable | This package is the SDK logging convention: levels, names, redaction, and buffered upload | Observability patterns |
|
|
32
|
+
| `repo.deploys_to_infra` | N/A | Library published to npm. No service runtime. | Runtime and infrastructure |
|
|
33
|
+
| `repo.shared_base_libs` | Applicable | `@webex/webex-core`, `@webex/common`, and `lodash` are runtime dependencies | Shared and base libraries |
|
|
34
|
+
| `repo.is_monorepo` | N/A | This SDD root is one package. The workspace around it is out of scope. | Package map and inter-package dependencies |
|
|
35
|
+
| `repo.multi_platform` | Applicable | `inBrowser` switches console output; tests run under jest (Node) and karma (browser) | Platform matrix |
|
|
36
|
+
| `repo.published_package` | Applicable | `package.json` `name` is `@webex/plugin-logger` and `deploy:npm` publishes it | Release and versioning |
|
|
37
|
+
| `repo.embedded_in_host` | N/A | No host theme or embed API | Host integration and theming |
|
|
38
|
+
| `repo.exposes_commands_or_artifacts` | Applicable | `build:src` writes `dist/`; `formatLogs` produces the upload text | Commands and generated artifacts |
|
|
39
|
+
| `repo.cross_repo_deps_material` | Applicable | Behavior depends on sibling workspace packages outside this SDD root | Cross-repository topology |
|
|
40
|
+
| `repo.security_arch_warranted` | Applicable | Redaction keeps tokens and personal data out of console and uploaded logs | Security architecture |
|
|
41
|
+
|
|
42
|
+
## Design overview
|
|
43
|
+
|
|
44
|
+
`@webex/plugin-logger` is a published library with one module. Importing it registers `Logger` as the `logger` child of every webex instance, replacing the minimal logger that `@webex/webex-core` registers in `src/plugins/logger.js`. Callers use `webex.logger.<level>()` for SDK logs and `webex.logger.client_<level>()` for client logs.
|
|
45
|
+
|
|
46
|
+
Each call decides printing and buffering separately, redacts a deep clone of the arguments, prints through `console`, and appends to a bounded buffer. `@webex/internal-plugin-support` later reads the buffer through `formatLogs` and uploads it.
|
|
47
|
+
|
|
48
|
+
The package does not start a server, open a network connection, or persist data.
|
|
49
|
+
|
|
50
|
+
## Resource inventory and responsibilities
|
|
51
|
+
|
|
52
|
+
| Resource | Kind | Responsibility | Owner | Source | Detailed specification |
|
|
53
|
+
| -------- | ---- | -------------- | ----- | ------ | ---------------------- |
|
|
54
|
+
| Logger plugin module | module | Levels, redaction, buffers, formatting | @webex/web-client, @webex/web-sdk | `src/` | `src/docs/README.md` |
|
|
55
|
+
| Published package | package | npm entry points and registration side effect | @webex/web-client, @webex/web-sdk | `package.json` | `docs/architecture.md` |
|
|
56
|
+
|
|
57
|
+
## Interaction and execution flows
|
|
58
|
+
|
|
59
|
+
```mermaid
|
|
60
|
+
flowchart LR
|
|
61
|
+
importer[Package importer]
|
|
62
|
+
index[src_index_js]
|
|
63
|
+
core[webex_core_registerPlugin]
|
|
64
|
+
logger[src_logger_js]
|
|
65
|
+
config[src_config_js]
|
|
66
|
+
plugins[SDK plugins]
|
|
67
|
+
support[internal_plugin_support]
|
|
68
|
+
consoleOut[console]
|
|
69
|
+
importer --> index
|
|
70
|
+
index --> core
|
|
71
|
+
index --> logger
|
|
72
|
+
index --> config
|
|
73
|
+
plugins --> logger
|
|
74
|
+
logger --> consoleOut
|
|
75
|
+
support --> logger
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
| From | To | Interaction or transport | Purpose | Failure or compatibility behavior |
|
|
79
|
+
| ---- | -- | ------------------------ | ------- | --------------------------------- |
|
|
80
|
+
| Importer | `src/index.js` | package import | Side-effect registration | Without the import, `webex.logger` stays the webex-core fallback |
|
|
81
|
+
| `src/index.js` | `@webex/webex-core` `registerPlugin` | in-process call with `replace: true` and `config` | Install `Logger` and merge defaults | Without `replace`, registration is skipped |
|
|
82
|
+
| SDK plugins | `webex.logger` | synchronous method call | Write logs | Methods never throw |
|
|
83
|
+
| `webex.logger` | `console` | synchronous call with fallbacks | Developer output | Missing console methods fall back |
|
|
84
|
+
| `@webex/internal-plugin-support` | `webex.logger` | `formatLogs`, `updateLastSubmittedIndex`, `resetBufferToLastSuccessfulUpload` | Upload logs | A failed diff upload rewinds `nextIndex` when retry is configured |
|
|
85
|
+
|
|
86
|
+
## Dependency topology
|
|
87
|
+
|
|
88
|
+
Runtime dependencies declared in `package.json` and imported from `src/`:
|
|
89
|
+
|
|
90
|
+
| Dependency | Role |
|
|
91
|
+
| ---------- | ---- |
|
|
92
|
+
| `@webex/webex-core` | `WebexPlugin` base class and `registerPlugin` |
|
|
93
|
+
| `@webex/common` | `inBrowser` and `patterns` |
|
|
94
|
+
| `lodash@^4.17.21` | `cloneDeep`, `has`, `isArray`, `isObject`, `isString` |
|
|
95
|
+
|
|
96
|
+
`@webex/test-helper-chai`, `@webex/test-helper-mocha`, and `@webex/test-helper-mock-webex` are also listed under `dependencies`, but only `test/` imports them.
|
|
97
|
+
|
|
98
|
+
## Public and consumer surfaces
|
|
99
|
+
|
|
100
|
+
| Contract id | Publication | Kind | Canonical source | Owning spec |
|
|
101
|
+
| ----------- | ----------- | ---- | ---------------- | ----------- |
|
|
102
|
+
| `plugin-logger-sdk` | published | sdk | `package.json` | `src/docs/README.md` |
|
|
103
|
+
| `log-buffer-format` | internal | file | `src/logger.js` | `src/docs/README.md` |
|
|
104
|
+
| `webex-core-plugin-host` | internal | rpc | `@webex/webex-core` | external |
|
|
105
|
+
| `webex-common-js-api` | published | sdk | `@webex/common` | `packages/@webex/common/src/docs/README.md` |
|
|
106
|
+
| `lodash` | published | sdk | npm package `lodash` | external |
|
|
107
|
+
|
|
108
|
+
`plugin-logger-sdk` entry points:
|
|
109
|
+
|
|
110
|
+
- `main`: `dist/index.js`
|
|
111
|
+
- `devMain`: `src/index.js`
|
|
112
|
+
- exports: default `Logger` and named `levels`
|
|
113
|
+
|
|
114
|
+
No HTTP surface exists, so `api-specs/openapi.yaml` is omitted.
|
|
115
|
+
|
|
116
|
+
Known in-repo consumers: `packages/@webex/internal-plugin-support/src/support.js` uses `formatLogs` and both cursor methods. `packages/webex/src/webex.js`, `packages/webex-node/src/webex-node.js`, and `packages/@webex/contact-center/src/webex.js` import the package for registration.
|
|
117
|
+
|
|
118
|
+
## Client state model
|
|
119
|
+
|
|
120
|
+
| State or slice | Owner | Transition triggers | Persistence or reset boundary |
|
|
121
|
+
| -------------- | ----- | ------------------- | ----------------------------- |
|
|
122
|
+
| Log buffers (`buffer`, `sdkBuffer`, `clientBuffer`) | `Logger` | Buffered log calls; trimming at history length | In memory per webex instance. Lost on reload. |
|
|
123
|
+
| Upload cursors (`nextIndex`, `lastSubmitted`) | `Logger`, driven by `@webex/internal-plugin-support` | `formatLogs({diff: true})`, `updateLastSubmittedIndex`, `resetBufferToLastSuccessfulUpload` | In memory. Clamped at `0` when entries are trimmed. |
|
|
124
|
+
| `groupLevel` | `Logger` | Buffered `group` and `groupEnd` | In memory |
|
|
125
|
+
|
|
126
|
+
Details are in the module spec.
|
|
127
|
+
|
|
128
|
+
## Cross-cutting architecture
|
|
129
|
+
|
|
130
|
+
### Security
|
|
131
|
+
|
|
132
|
+
The trust boundary is the point where caller-supplied values leave the process: the console and the upload buffer. Every log method crosses it only through `Logger#filter`. The controls and their gaps are listed under Security architecture.
|
|
133
|
+
|
|
134
|
+
The package does not authenticate users, store secrets, or verify certificates.
|
|
135
|
+
|
|
136
|
+
### Observability and operations
|
|
137
|
+
|
|
138
|
+
This package is the SDK's logging layer; its signal conventions are under Observability patterns. Operationally, it has no runtime to deploy or monitor. A failure inside a log method is reported through `console.warn` with `failed to execute Logger#<level>` and does not reach the caller.
|
|
139
|
+
|
|
140
|
+
### Quality attributes
|
|
141
|
+
|
|
142
|
+
- Compatibility: level method names, `formatLogs`, the cursor methods, and the `config.logger` keys are relied on by workspace packages.
|
|
143
|
+
- Bounded memory: each buffer is trimmed to its history length on write.
|
|
144
|
+
- Non-throwing: log methods catch internal errors.
|
|
145
|
+
|
|
146
|
+
## Dependency and interaction topology
|
|
147
|
+
|
|
148
|
+
One module. Files inside it:
|
|
149
|
+
|
|
150
|
+
```mermaid
|
|
151
|
+
flowchart TD
|
|
152
|
+
indexJs[src_index_js]
|
|
153
|
+
loggerJs[src_logger_js]
|
|
154
|
+
configJs[src_config_js]
|
|
155
|
+
indexJs --> loggerJs
|
|
156
|
+
indexJs --> configJs
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`src/config.js` is not imported by `src/logger.js`. It reaches the logger as `this.config` after `registerPlugin` merges it.
|
|
160
|
+
|
|
161
|
+
## Observability patterns
|
|
162
|
+
|
|
163
|
+
| Signal | Convention or required fields | Propagation or naming rule | Primary evidence |
|
|
164
|
+
| ------ | ----------------------------- | -------------------------- | ---------------- |
|
|
165
|
+
| Logs | Buffer entry `[indent, isoTimestamp, name, ...values]`, redacted before output | SDK name `wx-js-sdk`; client name from `config.logger.clientName`, default `client` | `src/logger.js` |
|
|
166
|
+
| Metrics | N/A — none emitted | — | `src/logger.js` |
|
|
167
|
+
| Traces | N/A — `trace` is a log level, not a span | — | `src/logger.js` |
|
|
168
|
+
| Audit | N/A — no audited actions | — | `src/logger.js` |
|
|
169
|
+
|
|
170
|
+
## Shared and base libraries
|
|
171
|
+
|
|
172
|
+
| Inherited stack | What this package inherits | Source |
|
|
173
|
+
| --------------- | -------------------------- | ------ |
|
|
174
|
+
| `WebexPlugin` base class | Ampersand session state, `this.config` bound to `config.logger`, and the `this.webex` reference | `src/logger.js` |
|
|
175
|
+
| Legacy build and lint configs | `@webex/babel-config-legacy`, `@webex/eslint-config-legacy`, `@webex/jest-config-legacy` | `babel.config.js`, `.eslintrc.js`, `jest.config.js` |
|
|
176
|
+
| Legacy tooling | `webex-legacy-tools` build and test runners | `package.json` scripts |
|
|
177
|
+
|
|
178
|
+
## Platform matrix
|
|
179
|
+
|
|
180
|
+
| Platform | Console output | Test runner |
|
|
181
|
+
| -------- | -------------- | ----------- |
|
|
182
|
+
| Node | Filtered arguments, objects as objects | jest via `test:unit` |
|
|
183
|
+
| Browser | Stringified arguments, objects as JSON strings | karma via `test:browser` |
|
|
184
|
+
|
|
185
|
+
`inBrowser` comes from `@webex/common` and is resolved by the bundler through that package's `browser` field.
|
|
186
|
+
|
|
187
|
+
## Release and versioning
|
|
188
|
+
|
|
189
|
+
The package is published with `yarn workspace @webex/plugin-logger deploy:npm`. That script wraps Yarn's npm publish; the wrapped call is a script internal, not a separate manifest command. The license field is `MIT`. There is no package-local changelog; workspace release tooling owns changelog generation.
|
|
190
|
+
|
|
191
|
+
Export stability is described in the module spec.
|
|
192
|
+
|
|
193
|
+
## Commands and generated artifacts
|
|
194
|
+
|
|
195
|
+
| Command | Produces |
|
|
196
|
+
| ------- | -------- |
|
|
197
|
+
| `yarn workspace @webex/plugin-logger build` | `dist/` from `src/` via `build:src` |
|
|
198
|
+
| `yarn workspace @webex/plugin-logger build:src` | `dist/` with source maps |
|
|
199
|
+
| `yarn workspace @webex/plugin-logger test:unit` | jest result; no committed artifact |
|
|
200
|
+
| `yarn workspace @webex/plugin-logger test:browser` | karma result; no committed artifact |
|
|
201
|
+
| `yarn workspace @webex/plugin-logger test:style` | eslint result; no committed artifact |
|
|
202
|
+
| `yarn install` | workspace `node_modules` |
|
|
203
|
+
| `yarn workspace @webex/plugin-logger deploy:npm` | npm publish |
|
|
204
|
+
|
|
205
|
+
At runtime, `formatLogs()` produces the log text described under Protocol and wire format in the module spec. `dist/` is generated. Do not edit it by hand.
|
|
206
|
+
|
|
207
|
+
## Cross-repository topology
|
|
208
|
+
|
|
209
|
+
| Repository or external system | Relationship | Exchanged contract or artifact | Owner | Sequencing constraint |
|
|
210
|
+
| ----------------------------- | ------------ | ------------------------------ | ----- | --------------------- |
|
|
211
|
+
| `packages/@webex/webex-core` | Consumes | `webex-core-plugin-host` | @webex/web-client, @webex/web-sdk | webex-core must register its fallback logger first so `replace: true` can override it |
|
|
212
|
+
| `packages/@webex/common` | Consumes | `webex-common-js-api` | @webex/web-client, @webex/web-sdk | Changes to `patterns.containsEmails` or `containsMTID` change redaction here |
|
|
213
|
+
| `packages/@webex/internal-plugin-support` | Provides | `log-buffer-format` and cursor methods | @webex/web-client, @webex/web-sdk | Buffer or format changes must ship with support changes |
|
|
214
|
+
|
|
215
|
+
These are sibling workspace packages outside this package-scoped SDD root.
|
|
216
|
+
|
|
217
|
+
## Security architecture
|
|
218
|
+
|
|
219
|
+
Threat addressed: tokens and personal data written to the console or included in uploaded logs.
|
|
220
|
+
|
|
221
|
+
Controls in `src/logger.js`:
|
|
222
|
+
|
|
223
|
+
- Deep clone before redaction, so caller objects are not mutated.
|
|
224
|
+
- Removal of keys matching `/[Aa]uthorization/` at any depth.
|
|
225
|
+
- Replacement of email addresses with `[REDACTED]`.
|
|
226
|
+
- Replacement of `MTID=<value>` with `MTID=[REDACTED]`.
|
|
227
|
+
- Circular-reference guard during redaction and stringify.
|
|
228
|
+
|
|
229
|
+
Controls that are absent:
|
|
230
|
+
|
|
231
|
+
- `Error` arguments are passed through without redaction.
|
|
232
|
+
- Uppercase `AUTHORIZATION` keys are not removed.
|
|
233
|
+
- Repeated identical strings within one call are redacted only at their first occurrence.
|
|
234
|
+
|
|
235
|
+
## Domain language
|
|
236
|
+
|
|
237
|
+
| Term | Meaning |
|
|
238
|
+
| ---- | ------- |
|
|
239
|
+
| SDK log | Entry written by `<level>()`; named `wx-js-sdk` |
|
|
240
|
+
| Client log | Entry written by `client_<level>()`; named by `config.logger.clientName` or `client` |
|
|
241
|
+
| Buffer | In-memory array of entries kept for upload |
|
|
242
|
+
| Diff | Entries added since the last `formatLogs({diff: true})` |
|
|
243
|
+
| `nextIndex` | Position where the next diff starts |
|
|
244
|
+
| `lastSubmitted` | `nextIndex` at the last successful upload |
|
|
245
|
+
| Redaction | Removing or masking sensitive values before output |
|
|
246
|
+
|
|
247
|
+
## References and maintenance
|
|
248
|
+
|
|
249
|
+
- Module spec: `src/docs/README.md`
|
|
250
|
+
- Product readme decision: `docs/adr/0001-retain-product-readme.md`
|
|
251
|
+
- Owner: `@webex/web-client @webex/web-sdk` in the monorepo `.github/CODEOWNERS`
|
|
252
|
+
- Manifest: `.sdd/manifest.json`
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: Getting Started
|
|
3
|
+
title: Getting started
|
|
4
|
+
description: Local setup, build, run, and test routing for @webex/plugin-logger.
|
|
5
|
+
tags: [onboarding]
|
|
6
|
+
---
|
|
7
|
+
<!-- sdd-generated-metadata
|
|
8
|
+
doc_kind: standing-doc
|
|
9
|
+
generated_from: getting-started@0.3.0
|
|
10
|
+
generated_by: claude-cowork
|
|
11
|
+
approved_by: akulakum@cisco.com
|
|
12
|
+
updated_at: 2026-10-08T08:51:39Z
|
|
13
|
+
validation_status: pass-with-warnings
|
|
14
|
+
-->
|
|
15
|
+
|
|
16
|
+
# Getting started
|
|
17
|
+
|
|
18
|
+
Onboarding for **@webex/plugin-logger**.
|
|
19
|
+
|
|
20
|
+
The unit spec is `test/unit/spec/logger.js`. `test:unit` runs it under jest in Node, and `test:browser` runs it under karma.
|
|
21
|
+
|
|
22
|
+
## Prerequisites
|
|
23
|
+
|
|
24
|
+
| Tool or access | Version or requirement |
|
|
25
|
+
| -------------- | ---------------------- |
|
|
26
|
+
| Node.js | `>=18`, declared in `package.json` `engines` |
|
|
27
|
+
| Yarn | Workspaces are used, so install from the workspace root rather than this directory |
|
|
28
|
+
| Browser for `test:browser` | A local browser for the karma runner that `test:browser` starts through `@webex/legacy-tools` |
|
|
29
|
+
| Container, registry, VPN, or account | N/A — no external account is required to build, lint, or unit-test this package |
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
Dependencies are resolved for the whole workspace, not per package:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
yarn install
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Run it from the workspace root.
|
|
40
|
+
|
|
41
|
+
## Build
|
|
42
|
+
|
|
43
|
+
Compile sources to `dist/`:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
yarn workspace @webex/plugin-logger build
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`scripts.build` runs `build:src`, which uses the `@webex/legacy-tools` builder to compile `src/` into `dist/` with source maps. That builder call is a script internal. The manifest records `build:src` as the compile role and `build` as the package role.
|
|
50
|
+
|
|
51
|
+
## Run
|
|
52
|
+
|
|
53
|
+
N/A — library package with no start script.
|
|
54
|
+
|
|
55
|
+
Import the package from a consumer. `webex` and `webex-node` import it so that `webex.logger` is this plugin.
|
|
56
|
+
|
|
57
|
+
## Tests
|
|
58
|
+
|
|
59
|
+
| Tier | Command | What it covers |
|
|
60
|
+
| ---- | ------- | -------------- |
|
|
61
|
+
| Unit (Node) | `yarn workspace @webex/plugin-logger test:unit` | `test/unit/spec/logger.js` under jest, including `nodeOnly` cases |
|
|
62
|
+
| Unit (browser) | `yarn workspace @webex/plugin-logger test:browser` | The same spec under karma, including `browserOnly` cases. Recorded as manifest `commands.browser-test` (role `other`) because the SDD manifest `tests` schema has no browser tier (`unit`, `integration`, `e2e`, `qa` only). |
|
|
63
|
+
| Lint | `yarn workspace @webex/plugin-logger test:style` | eslint over `src/` |
|
|
64
|
+
| Integration | N/A — `package.json` does not define `test:integration` | — |
|
|
65
|
+
|
|
66
|
+
Do not use `package.json` `scripts.test` as a verification command. It chains `test:integration`, which is not defined.
|
|
67
|
+
|
|
68
|
+
## Configuration and secrets
|
|
69
|
+
|
|
70
|
+
| Item | Where it lives |
|
|
71
|
+
| ---- | -------------- |
|
|
72
|
+
| `WEBEX_LOG_LEVEL` | Environment variable. Read once into `config.logger.level` by `src/config.js` and again on each call by `getCurrentLevel` in `src/logger.js`. |
|
|
73
|
+
| `NODE_ENV` | `test` forces level `trace` when no level is configured and enables test-only output tweaks |
|
|
74
|
+
| `config.logger.*` | `level`, `clientLevel`, `bufferLogLevel`, `historyLength`, `clientHistoryLength`, `separateLogBuffers`, `clientName`. Defaults for `level` and `historyLength` are in `src/config.js`. |
|
|
75
|
+
| Secrets | N/A — this package reads no credentials. It removes `authorization` keys from logged values. |
|
|
76
|
+
|
|
77
|
+
## First-run verification
|
|
78
|
+
|
|
79
|
+
1. `yarn install` from the workspace root.
|
|
80
|
+
2. `yarn workspace @webex/plugin-logger build`
|
|
81
|
+
3. `yarn workspace @webex/plugin-logger test:style`
|
|
82
|
+
4. `yarn workspace @webex/plugin-logger test:unit`
|
|
83
|
+
|
|
84
|
+
## Next steps
|
|
85
|
+
|
|
86
|
+
- [Architecture](architecture.md)
|
|
87
|
+
- [Module specification](../src/docs/README.md)
|
|
88
|
+
- [Specification registry](specs/README.md)
|
package/docs/index.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
okf_version: "0.1"
|
|
3
|
+
---
|
|
4
|
+
<!-- sdd-generated-metadata
|
|
5
|
+
doc_kind: standing-doc
|
|
6
|
+
generated_from: docs-index@0.3.0
|
|
7
|
+
generated_by: claude-cowork
|
|
8
|
+
approved_by: akulakum@cisco.com
|
|
9
|
+
updated_at: 2026-10-08T08:51:39Z
|
|
10
|
+
validation_status: pass-with-warnings
|
|
11
|
+
-->
|
|
12
|
+
|
|
13
|
+
# @webex/plugin-logger documentation
|
|
14
|
+
|
|
15
|
+
Doc map for developers and agents.
|
|
16
|
+
|
|
17
|
+
This package publishes the Webex SDK logger plugin. It prints leveled output to `console`, redacts authorization keys, email addresses, and MTID values, and keeps bounded in-memory buffers that `@webex/internal-plugin-support` formats and uploads.
|
|
18
|
+
|
|
19
|
+
## Start here
|
|
20
|
+
|
|
21
|
+
- [Getting started](getting-started.md)
|
|
22
|
+
- [Package architecture](architecture.md)
|
|
23
|
+
- [Module specification](../src/docs/README.md) — behavior of `src/`
|
|
24
|
+
|
|
25
|
+
## Decisions
|
|
26
|
+
|
|
27
|
+
- [adr/](adr/) — architectural decision records
|
|
28
|
+
|
|
29
|
+
## Specifications and contracts
|
|
30
|
+
|
|
31
|
+
- [architecture.md](architecture.md) — canonical package-wide architecture
|
|
32
|
+
- [specs/README.md](specs/README.md) — manifest-backed module and contract registry
|
|
33
|
+
- `src/docs/README.md` — the owning specification beside the module's code
|
|
34
|
+
- [adr/](adr/) — concrete architectural decisions
|
|
35
|
+
|
|
36
|
+
No deployable service exists in this package, so no service specification is generated. The published contract is an npm/SDK surface whose authoritative source is `package.json` together with `src/index.js`, not an OpenAPI document.
|
|
37
|
+
|
|
38
|
+
## Related repository resources
|
|
39
|
+
|
|
40
|
+
- `README.md` — the package's npm-facing usage document, retained separately from this generated documentation set. See [ADR 0001](adr/0001-retain-product-readme.md).
|
|
41
|
+
|
|
42
|
+
No `ci/`, `operate/`, `diagrams/`, or runbook directories exist in this package.
|