@webex/plugin-logger 3.7.0 → 3.8.0

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/dist/logger.js CHANGED
@@ -113,9 +113,12 @@ var Logger = _webexCore.WebexPlugin.extend({
113
113
  session: {
114
114
  // for when configured to use single buffer
115
115
  buffer: {
116
- type: 'array',
116
+ type: 'object',
117
117
  default: function _default() {
118
- return [];
118
+ return {
119
+ buffer: [],
120
+ nextIndex: 0
121
+ };
119
122
  }
120
123
  },
121
124
  groupLevel: {
@@ -126,15 +129,21 @@ var Logger = _webexCore.WebexPlugin.extend({
126
129
  },
127
130
  // for when configured to use separate buffers
128
131
  sdkBuffer: {
129
- type: 'array',
132
+ type: 'object',
130
133
  default: function _default() {
131
- return [];
134
+ return {
135
+ buffer: [],
136
+ nextIndex: 0
137
+ };
132
138
  }
133
139
  },
134
140
  clientBuffer: {
135
- type: 'array',
141
+ type: 'object',
136
142
  default: function _default() {
137
- return [];
143
+ return {
144
+ buffer: [],
145
+ nextIndex: 0
146
+ };
138
147
  }
139
148
  }
140
149
  },
@@ -255,40 +264,52 @@ var Logger = _webexCore.WebexPlugin.extend({
255
264
  * @memberof Logger
256
265
  * @public
257
266
  * @memberof Logger
267
+ * @param {Object} options
268
+ * @param {boolean} options.diff whether to only format the diff from last call to formatLogs(), false by default
258
269
  * @returns {string} formatted buffer
259
270
  */
260
271
  formatLogs: function formatLogs() {
272
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
261
273
  function getDate(log) {
262
274
  return log[1];
263
275
  }
276
+ var _options$diff = options.diff,
277
+ diff = _options$diff === void 0 ? false : _options$diff;
264
278
  var buffer = [];
265
- var clientIndex = 0;
266
- var sdkIndex = 0;
279
+ var clientIndex = diff ? this.clientBuffer.nextIndex : 0;
280
+ var sdkIndex = diff ? this.sdkBuffer.nextIndex : 0;
267
281
  if (this.config.separateLogBuffers) {
268
282
  // merge the client and sdk buffers
269
283
  // while we have entries in either buffer
270
- while (clientIndex < this.clientBuffer.length || sdkIndex < this.sdkBuffer.length) {
284
+ while (clientIndex < this.clientBuffer.buffer.length || sdkIndex < this.sdkBuffer.buffer.length) {
271
285
  // if we have remaining entries in the SDK buffer
272
- if (sdkIndex < this.sdkBuffer.length && (
286
+ if (sdkIndex < this.sdkBuffer.buffer.length && (
273
287
  // and we haven't exhausted all the client buffer entries, or SDK date is before client date
274
- clientIndex >= this.clientBuffer.length || new Date(getDate(this.sdkBuffer[sdkIndex])) <= new Date(getDate(this.clientBuffer[clientIndex])))) {
288
+ clientIndex >= this.clientBuffer.buffer.length || new Date(getDate(this.sdkBuffer.buffer[sdkIndex])) <= new Date(getDate(this.clientBuffer.buffer[clientIndex])))) {
275
289
  // then add to the SDK buffer
276
- buffer.push(this.sdkBuffer[sdkIndex]);
290
+ buffer.push(this.sdkBuffer.buffer[sdkIndex]);
277
291
  sdkIndex += 1;
278
292
  }
279
293
  // otherwise if we haven't exhausted all the client buffer entries, add client entry, whether it was because
280
294
  // it was the only remaining entries or date was later (the above if)
281
- else if (clientIndex < this.clientBuffer.length) {
282
- buffer.push(this.clientBuffer[clientIndex]);
295
+ else if (clientIndex < this.clientBuffer.buffer.length) {
296
+ buffer.push(this.clientBuffer.buffer[clientIndex]);
283
297
  clientIndex += 1;
284
298
  }
285
299
  }
300
+ if (diff) {
301
+ this.clientBuffer.nextIndex = clientIndex;
302
+ this.sdkBuffer.nextIndex = sdkIndex;
303
+ }
304
+ } else if (diff) {
305
+ buffer = this.buffer.buffer.slice(this.buffer.nextIndex);
306
+ this.buffer.nextIndex = this.buffer.buffer.length;
286
307
  } else {
287
- buffer = this.buffer;
308
+ buffer = this.buffer.buffer;
288
309
  }
289
310
  return buffer.join('\n');
290
311
  },
291
- version: "3.7.0"
312
+ version: "3.8.0"
292
313
  });
293
314
 
294
315
  /**
@@ -317,13 +338,13 @@ function makeLoggerMethod(level, impl, type) {
317
338
  // a sort of late binding to allow retrieving a name from config.
318
339
  var logType = type;
319
340
  var clientName = logType === LOG_TYPES.SDK ? SDK_LOG_TYPE_NAME : this.config.clientName || logType;
320
- var buffer;
341
+ var bufferRef;
321
342
  var historyLength;
322
343
  if (this.config.separateLogBuffers) {
323
344
  historyLength = this.config.clientHistoryLength ? this.config.clientHistoryLength : this.config.historyLength;
324
- buffer = logType === LOG_TYPES.SDK ? this.sdkBuffer : this.clientBuffer;
345
+ bufferRef = logType === LOG_TYPES.SDK ? this.sdkBuffer : this.clientBuffer;
325
346
  } else {
326
- buffer = this.buffer;
347
+ bufferRef = this.buffer;
327
348
  historyLength = this.config.historyLength;
328
349
  }
329
350
  try {
@@ -379,9 +400,17 @@ function makeLoggerMethod(level, impl, type) {
379
400
  var logDate = new Date();
380
401
  stringified.unshift(logDate.toISOString());
381
402
  stringified.unshift('| '.repeat(this.groupLevel));
382
- buffer.push(stringified);
383
- if (buffer.length > historyLength) {
384
- buffer.splice(0, buffer.length - historyLength);
403
+ bufferRef.buffer.push(stringified);
404
+ if (bufferRef.buffer.length > historyLength) {
405
+ // we've gone over the buffer limit, trim it down
406
+ var deleteCount = bufferRef.buffer.length - historyLength;
407
+ bufferRef.buffer.splice(0, deleteCount);
408
+
409
+ // and adjust the corresponding buffer index used for log diff uploads
410
+ bufferRef.nextIndex -= deleteCount;
411
+ if (bufferRef.nextIndex < 0) {
412
+ bufferRef.nextIndex = 0;
413
+ }
385
414
  }
386
415
  if (level === 'group') this.groupLevel += 1;
387
416
  if (level === 'groupEnd' && this.groupLevel > 0) this.groupLevel -= 1;
@@ -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","_default","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","getDate","clientIndex","sdkIndex","separateLogBuffers","Date","join","version","makeLoggerMethod","impl","neverPrint","alwaysBuffer","wrappedConsoleMethod","logType","clientName","historyLength","clientHistoryLength","filtered","concat","_toConsumableArray2","apply","stringified","item","_typeof2","returnItem","_stringify","_key","e","_console","toPrint","has","unshift","url","slice","console","logDate","toISOString","repeat","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: 'array',\n default() {\n return [];\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: 'array',\n default() {\n return [];\n },\n },\n clientBuffer: {\n type: 'array',\n default() {\n return [];\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 * @returns {string} formatted buffer\n */\n formatLogs() {\n function getDate(log) {\n return log[1];\n }\n let buffer = [];\n let clientIndex = 0;\n let sdkIndex = 0;\n\n if (this.config.separateLogBuffers) {\n // merge the client and sdk buffers\n // while we have entries in either buffer\n while (clientIndex < this.clientBuffer.length || sdkIndex < this.sdkBuffer.length) {\n // if we have remaining entries in the SDK buffer\n if (\n sdkIndex < this.sdkBuffer.length &&\n // and we haven't exhausted all the client buffer entries, or SDK date is before client date\n (clientIndex >= this.clientBuffer.length ||\n new Date(getDate(this.sdkBuffer[sdkIndex])) <=\n new Date(getDate(this.clientBuffer[clientIndex])))\n ) {\n // then add to the SDK buffer\n buffer.push(this.sdkBuffer[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.length) {\n buffer.push(this.clientBuffer[clientIndex]);\n clientIndex += 1;\n }\n }\n } else {\n buffer = this.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 buffer;\n let historyLength;\n\n if (this.config.separateLogBuffers) {\n historyLength = this.config.clientHistoryLength\n ? this.config.clientHistoryLength\n : this.config.historyLength;\n buffer = logType === LOG_TYPES.SDK ? this.sdkBuffer : this.clientBuffer;\n } else {\n buffer = 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 buffer.push(stringified);\n if (buffer.length > historyLength) {\n buffer.splice(0, buffer.length - historyLength);\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,MAAM,EAAE,KAAK;AAChC,CAAC;AAED,IAAMQ,SAAS,GAAG;EAChBC,GAAG,EAAE,KAAK;EACVC,MAAM,EAAE;AACV,CAAC;AAED,IAAMC,iBAAiB,GAAG,WAA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CAAC;IACrB;IACA,OAAO,CAACC,OAAO,CAACzB,IAAI,CAAC,EAAE;MACrBA,IAAI,GAAGgC,KAAK,CAACC,GAAG,CAAC,CAAC;IACpB;EACF;;EAEA;EACArF,MAAM,CAACsF,SAAS,WAAAzB,MAAA,CAAW9F,KAAK,EAAG,GAAGoF,gBAAgB,CAACpF,KAAK,EAAEqF,IAAI,EAAEnF,SAAS,CAACE,MAAM,CAAC;EACrF6B,MAAM,CAACsF,SAAS,CAACvH,KAAK,CAAC,GAAGoF,gBAAgB,CAACpF,KAAK,EAAEqF,IAAI,EAAEnF,SAAS,CAACC,GAAG,CAAC;AACxE,CAAC,CAAC;AAEF8B,MAAM,CAACsF,SAAS,CAACC,kBAAkB,GAAGpC,gBAAgB,CACpDzF,MAAM,CAACH,IAAI,EACXG,MAAM,CAACH,IAAI,EACXU,SAAS,CAACE,MAAM,EAChB,IAAI,EACJ,IACF,CAAC;AACD6B,MAAM,CAACsF,SAAS,CAACE,WAAW,GAAGrC,gBAAgB,CAC7CzF,MAAM,CAACH,IAAI,EACXG,MAAM,CAACH,IAAI,EACXU,SAAS,CAACC,GAAG,EACb,IAAI,EACJ,IACF,CAAC;AAAC,IAAAuH,SAAA,GAAA9H,OAAA,CAAAE,OAAA,GAEamC,MAAM"}
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","_default","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,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CHANGED
@@ -24,20 +24,20 @@
24
24
  "@webex/eslint-config-legacy": "0.0.0",
25
25
  "@webex/jest-config-legacy": "0.0.0",
26
26
  "@webex/legacy-tools": "0.0.0",
27
- "@webex/test-helper-chai": "3.7.0",
28
- "@webex/test-helper-mocha": "3.7.0",
29
- "@webex/test-helper-mock-webex": "3.7.0",
30
- "@webex/test-helper-test-users": "3.7.0",
27
+ "@webex/test-helper-chai": "3.8.0",
28
+ "@webex/test-helper-mocha": "3.8.0",
29
+ "@webex/test-helper-mock-webex": "3.8.0",
30
+ "@webex/test-helper-test-users": "3.8.0",
31
31
  "eslint": "^8.24.0",
32
32
  "prettier": "^2.7.1",
33
33
  "sinon": "^9.2.4"
34
34
  },
35
35
  "dependencies": {
36
- "@webex/common": "3.7.0",
37
- "@webex/test-helper-chai": "3.7.0",
38
- "@webex/test-helper-mocha": "3.7.0",
39
- "@webex/test-helper-mock-webex": "3.7.0",
40
- "@webex/webex-core": "3.7.0",
36
+ "@webex/common": "3.8.0",
37
+ "@webex/test-helper-chai": "3.8.0",
38
+ "@webex/test-helper-mocha": "3.8.0",
39
+ "@webex/test-helper-mock-webex": "3.8.0",
40
+ "@webex/webex-core": "3.8.0",
41
41
  "lodash": "^4.17.21"
42
42
  },
43
43
  "scripts": {
@@ -49,5 +49,5 @@
49
49
  "test:style": "eslint ./src/**/*.*",
50
50
  "test:unit": "webex-legacy-tools test --unit --runner jest"
51
51
  },
52
- "version": "3.7.0"
52
+ "version": "3.8.0"
53
53
  }
package/src/logger.js CHANGED
@@ -102,9 +102,12 @@ const Logger = WebexPlugin.extend({
102
102
  session: {
103
103
  // for when configured to use single buffer
104
104
  buffer: {
105
- type: 'array',
105
+ type: 'object',
106
106
  default() {
107
- return [];
107
+ return {
108
+ buffer: [],
109
+ nextIndex: 0,
110
+ };
108
111
  },
109
112
  },
110
113
  groupLevel: {
@@ -115,15 +118,21 @@ const Logger = WebexPlugin.extend({
115
118
  },
116
119
  // for when configured to use separate buffers
117
120
  sdkBuffer: {
118
- type: 'array',
121
+ type: 'object',
119
122
  default() {
120
- return [];
123
+ return {
124
+ buffer: [],
125
+ nextIndex: 0,
126
+ };
121
127
  },
122
128
  },
123
129
  clientBuffer: {
124
- type: 'array',
130
+ type: 'object',
125
131
  default() {
126
- return [];
132
+ return {
133
+ buffer: [],
134
+ nextIndex: 0,
135
+ };
127
136
  },
128
137
  },
129
138
  },
@@ -261,41 +270,54 @@ const Logger = WebexPlugin.extend({
261
270
  * @memberof Logger
262
271
  * @public
263
272
  * @memberof Logger
273
+ * @param {Object} options
274
+ * @param {boolean} options.diff whether to only format the diff from last call to formatLogs(), false by default
264
275
  * @returns {string} formatted buffer
265
276
  */
266
- formatLogs() {
277
+ formatLogs(options = {}) {
267
278
  function getDate(log) {
268
279
  return log[1];
269
280
  }
281
+ const {diff = false} = options;
270
282
  let buffer = [];
271
- let clientIndex = 0;
272
- let sdkIndex = 0;
283
+ let clientIndex = diff ? this.clientBuffer.nextIndex : 0;
284
+ let sdkIndex = diff ? this.sdkBuffer.nextIndex : 0;
273
285
 
274
286
  if (this.config.separateLogBuffers) {
275
287
  // merge the client and sdk buffers
276
288
  // while we have entries in either buffer
277
- while (clientIndex < this.clientBuffer.length || sdkIndex < this.sdkBuffer.length) {
289
+ while (
290
+ clientIndex < this.clientBuffer.buffer.length ||
291
+ sdkIndex < this.sdkBuffer.buffer.length
292
+ ) {
278
293
  // if we have remaining entries in the SDK buffer
279
294
  if (
280
- sdkIndex < this.sdkBuffer.length &&
295
+ sdkIndex < this.sdkBuffer.buffer.length &&
281
296
  // and we haven't exhausted all the client buffer entries, or SDK date is before client date
282
- (clientIndex >= this.clientBuffer.length ||
283
- new Date(getDate(this.sdkBuffer[sdkIndex])) <=
284
- new Date(getDate(this.clientBuffer[clientIndex])))
297
+ (clientIndex >= this.clientBuffer.buffer.length ||
298
+ new Date(getDate(this.sdkBuffer.buffer[sdkIndex])) <=
299
+ new Date(getDate(this.clientBuffer.buffer[clientIndex])))
285
300
  ) {
286
301
  // then add to the SDK buffer
287
- buffer.push(this.sdkBuffer[sdkIndex]);
302
+ buffer.push(this.sdkBuffer.buffer[sdkIndex]);
288
303
  sdkIndex += 1;
289
304
  }
290
305
  // otherwise if we haven't exhausted all the client buffer entries, add client entry, whether it was because
291
306
  // it was the only remaining entries or date was later (the above if)
292
- else if (clientIndex < this.clientBuffer.length) {
293
- buffer.push(this.clientBuffer[clientIndex]);
307
+ else if (clientIndex < this.clientBuffer.buffer.length) {
308
+ buffer.push(this.clientBuffer.buffer[clientIndex]);
294
309
  clientIndex += 1;
295
310
  }
296
311
  }
312
+ if (diff) {
313
+ this.clientBuffer.nextIndex = clientIndex;
314
+ this.sdkBuffer.nextIndex = sdkIndex;
315
+ }
316
+ } else if (diff) {
317
+ buffer = this.buffer.buffer.slice(this.buffer.nextIndex);
318
+ this.buffer.nextIndex = this.buffer.buffer.length;
297
319
  } else {
298
- buffer = this.buffer;
320
+ buffer = this.buffer.buffer;
299
321
  }
300
322
 
301
323
  return buffer.join('\n');
@@ -328,16 +350,16 @@ function makeLoggerMethod(level, impl, type, neverPrint = false, alwaysBuffer =
328
350
  const clientName =
329
351
  logType === LOG_TYPES.SDK ? SDK_LOG_TYPE_NAME : this.config.clientName || logType;
330
352
 
331
- let buffer;
353
+ let bufferRef;
332
354
  let historyLength;
333
355
 
334
356
  if (this.config.separateLogBuffers) {
335
357
  historyLength = this.config.clientHistoryLength
336
358
  ? this.config.clientHistoryLength
337
359
  : this.config.historyLength;
338
- buffer = logType === LOG_TYPES.SDK ? this.sdkBuffer : this.clientBuffer;
360
+ bufferRef = logType === LOG_TYPES.SDK ? this.sdkBuffer : this.clientBuffer;
339
361
  } else {
340
- buffer = this.buffer;
362
+ bufferRef = this.buffer;
341
363
  historyLength = this.config.historyLength;
342
364
  }
343
365
 
@@ -401,9 +423,18 @@ function makeLoggerMethod(level, impl, type, neverPrint = false, alwaysBuffer =
401
423
 
402
424
  stringified.unshift(logDate.toISOString());
403
425
  stringified.unshift('| '.repeat(this.groupLevel));
404
- buffer.push(stringified);
405
- if (buffer.length > historyLength) {
406
- buffer.splice(0, buffer.length - historyLength);
426
+ bufferRef.buffer.push(stringified);
427
+ if (bufferRef.buffer.length > historyLength) {
428
+ // we've gone over the buffer limit, trim it down
429
+ const deleteCount = bufferRef.buffer.length - historyLength;
430
+
431
+ bufferRef.buffer.splice(0, deleteCount);
432
+
433
+ // and adjust the corresponding buffer index used for log diff uploads
434
+ bufferRef.nextIndex -= deleteCount;
435
+ if (bufferRef.nextIndex < 0) {
436
+ bufferRef.nextIndex = 0;
437
+ }
407
438
  }
408
439
  if (level === 'group') this.groupLevel += 1;
409
440
  if (level === 'groupEnd' && this.groupLevel > 0) this.groupLevel -= 1;
@@ -82,21 +82,21 @@ describe('plugin-logger', () => {
82
82
 
83
83
  it('stores the specified message in the log buffer', () => {
84
84
  webex.logger.log('test');
85
- assert.lengthOf(webex.logger.buffer, 1);
86
- assert.match(webex.logger.buffer[0][3], /test/);
85
+ assert.lengthOf(webex.logger.buffer.buffer, 1);
86
+ assert.match(webex.logger.buffer.buffer[0][3], /test/);
87
87
  });
88
88
 
89
89
  it('adds the date to the beggining of the buffer entry', () => {
90
90
  webex.logger.log('test date');
91
91
 
92
92
  // Convert string back to date object
93
- const logDate = new Date(webex.logger.buffer[0][1]);
93
+ const logDate = new Date(webex.logger.buffer.buffer[0][1]);
94
94
 
95
95
  // eslint-disable-next-line no-restricted-globals
96
- assert.isTrue(logDate instanceof Date && isNaN(webex.logger.buffer[0][1]));
97
- assert.isString(webex.logger.buffer[0][0]);
98
- assert.isString(webex.logger.buffer[0][1]);
99
- assert.match(webex.logger.buffer[0][3], /test date/);
96
+ assert.isTrue(logDate instanceof Date && isNaN(webex.logger.buffer.buffer[0][1]));
97
+ assert.isString(webex.logger.buffer.buffer[0][0]);
98
+ assert.isString(webex.logger.buffer.buffer[0][1]);
99
+ assert.match(webex.logger.buffer.buffer[0][3], /test date/);
100
100
  });
101
101
 
102
102
  it('stores the specified message in the client and sdk log buffer', () => {
@@ -104,28 +104,28 @@ describe('plugin-logger', () => {
104
104
  webex.config.logger.clientName = 'someclient';
105
105
  webex.logger.log('testsdk');
106
106
  webex.logger.client_log('testclient');
107
- assert.lengthOf(webex.logger.sdkBuffer, 1);
108
- assert.isString(webex.logger.sdkBuffer[0][0]);
109
- assert.isString(webex.logger.sdkBuffer[0][1]);
110
- assert.match(webex.logger.sdkBuffer[0][2], /wx-js-sdk/);
111
- assert.match(webex.logger.sdkBuffer[0][3], /testsdk/);
112
- assert.lengthOf(webex.logger.clientBuffer, 1);
113
- assert.isString(webex.logger.clientBuffer[0][0]);
114
- assert.isString(webex.logger.clientBuffer[0][1]);
115
- assert.match(webex.logger.clientBuffer[0][2], /someclient/);
116
- assert.match(webex.logger.clientBuffer[0][3], /testclient/);
107
+ assert.lengthOf(webex.logger.sdkBuffer.buffer, 1);
108
+ assert.isString(webex.logger.sdkBuffer.buffer[0][0]);
109
+ assert.isString(webex.logger.sdkBuffer.buffer[0][1]);
110
+ assert.match(webex.logger.sdkBuffer.buffer[0][2], /wx-js-sdk/);
111
+ assert.match(webex.logger.sdkBuffer.buffer[0][3], /testsdk/);
112
+ assert.lengthOf(webex.logger.clientBuffer.buffer, 1);
113
+ assert.isString(webex.logger.clientBuffer.buffer[0][0]);
114
+ assert.isString(webex.logger.clientBuffer.buffer[0][1]);
115
+ assert.match(webex.logger.clientBuffer.buffer[0][2], /someclient/);
116
+ assert.match(webex.logger.clientBuffer.buffer[0][3], /testclient/);
117
117
  });
118
118
 
119
119
  it('prevents the buffer from overflowing', () => {
120
120
  webex.config.logger.historyLength = 2;
121
121
  webex.logger.log(1);
122
- assert.lengthOf(webex.logger.buffer, 1);
122
+ assert.lengthOf(webex.logger.buffer.buffer, 1);
123
123
  webex.logger.log(2);
124
- assert.lengthOf(webex.logger.buffer, 2);
124
+ assert.lengthOf(webex.logger.buffer.buffer, 2);
125
125
  webex.logger.log(3);
126
- assert.lengthOf(webex.logger.buffer, 2);
127
- assert.equal(webex.logger.buffer[0][3], 2);
128
- assert.equal(webex.logger.buffer[1][3], 3);
126
+ assert.lengthOf(webex.logger.buffer.buffer, 2);
127
+ assert.equal(webex.logger.buffer.buffer[0][3], 2);
128
+ assert.equal(webex.logger.buffer.buffer[1][3], 3);
129
129
  });
130
130
 
131
131
  it('prevents the client and sdk buffer from overflowing', () => {
@@ -133,20 +133,20 @@ describe('plugin-logger', () => {
133
133
  webex.config.logger.separateLogBuffers = true;
134
134
  webex.logger.log(1);
135
135
  webex.logger.client_log(3);
136
- assert.lengthOf(webex.logger.sdkBuffer, 1);
137
- assert.lengthOf(webex.logger.clientBuffer, 1);
136
+ assert.lengthOf(webex.logger.sdkBuffer.buffer, 1);
137
+ assert.lengthOf(webex.logger.clientBuffer.buffer, 1);
138
138
  webex.logger.log(2);
139
139
  webex.logger.client_log(2);
140
- assert.lengthOf(webex.logger.sdkBuffer, 2);
141
- assert.lengthOf(webex.logger.clientBuffer, 2);
140
+ assert.lengthOf(webex.logger.sdkBuffer.buffer, 2);
141
+ assert.lengthOf(webex.logger.clientBuffer.buffer, 2);
142
142
  webex.logger.log(3);
143
143
  webex.logger.client_log(1);
144
- assert.lengthOf(webex.logger.sdkBuffer, 2);
145
- assert.lengthOf(webex.logger.clientBuffer, 2);
146
- assert.equal(webex.logger.sdkBuffer[0][3], 2);
147
- assert.equal(webex.logger.sdkBuffer[1][3], 3);
148
- assert.equal(webex.logger.sdkBuffer[0][3], 2);
149
- assert.equal(webex.logger.clientBuffer[1][3], 1);
144
+ assert.lengthOf(webex.logger.sdkBuffer.buffer, 2);
145
+ assert.lengthOf(webex.logger.clientBuffer.buffer, 2);
146
+ assert.equal(webex.logger.sdkBuffer.buffer[0][3], 2);
147
+ assert.equal(webex.logger.sdkBuffer.buffer[1][3], 3);
148
+ assert.equal(webex.logger.sdkBuffer.buffer[0][3], 2);
149
+ assert.equal(webex.logger.clientBuffer.buffer[1][3], 1);
150
150
  });
151
151
 
152
152
  // Node handles custom errors correctly, so this test is browser specific
@@ -164,7 +164,7 @@ describe('plugin-logger', () => {
164
164
  });
165
165
 
166
166
  webex.logger.log(error);
167
- assert.lengthOf(webex.logger.buffer, 1);
167
+ assert.lengthOf(webex.logger.buffer.buffer, 1);
168
168
  assert.match(console.log.args[0][1], /WebexHttpError/);
169
169
  });
170
170
 
@@ -182,8 +182,8 @@ describe('plugin-logger', () => {
182
182
  });
183
183
 
184
184
  webex.logger.log(error);
185
- assert.lengthOf(webex.logger.buffer, 1);
186
- assert.match(webex.logger.buffer[0][3], /WebexHttpError/g);
185
+ assert.lengthOf(webex.logger.buffer.buffer, 1);
186
+ assert.match(webex.logger.buffer.buffer[0][3], /WebexHttpError/g);
187
187
  });
188
188
 
189
189
  it('formats objects as strings passed to the logger for readability not [Object object]', async () => {
@@ -200,12 +200,12 @@ describe('plugin-logger', () => {
200
200
  }
201
201
 
202
202
  webex.logger.log('foo', 'bar', obj);
203
- assert.lengthOf(webex.logger.buffer, 1);
204
- assert.lengthOf(webex.logger.buffer[0], 6);
205
- assert.deepEqual(webex.logger.buffer[0][2], 'wx-js-sdk');
206
- assert.deepEqual(webex.logger.buffer[0][3], 'foo');
207
- assert.deepEqual(webex.logger.buffer[0][4], 'bar');
208
- assert.deepEqual(webex.logger.buffer[0][5], '{"headers":{"trackingid":"123"},"test":"object","nested":{"test2":"object2"}}');
203
+ assert.lengthOf(webex.logger.buffer.buffer, 1);
204
+ assert.lengthOf(webex.logger.buffer.buffer[0], 6);
205
+ assert.deepEqual(webex.logger.buffer.buffer[0][2], 'wx-js-sdk');
206
+ assert.deepEqual(webex.logger.buffer.buffer[0][3], 'foo');
207
+ assert.deepEqual(webex.logger.buffer.buffer[0][4], 'bar');
208
+ assert.deepEqual(webex.logger.buffer.buffer[0][5], '{"headers":{"trackingid":"123"},"test":"object","nested":{"test2":"object2"}}');
209
209
  });
210
210
 
211
211
  it('formats objects as strings passed to the logger for readability not [Object object] w/ circular reference', async () => {
@@ -224,12 +224,12 @@ describe('plugin-logger', () => {
224
224
  obj.selfReference = obj;
225
225
 
226
226
  webex.logger.log('foo', 'bar', obj);
227
- assert.lengthOf(webex.logger.buffer, 1);
228
- assert.lengthOf(webex.logger.buffer[0], 6);
229
- assert.deepEqual(webex.logger.buffer[0][2], 'wx-js-sdk');
230
- assert.deepEqual(webex.logger.buffer[0][3], 'foo');
231
- assert.deepEqual(webex.logger.buffer[0][4], 'bar');
232
- assert.deepEqual(webex.logger.buffer[0][5], '{"headers":{"trackingid":"123"},"test":"object","nested":{"test2":"object2"}}');
227
+ assert.lengthOf(webex.logger.buffer.buffer, 1);
228
+ assert.lengthOf(webex.logger.buffer.buffer[0], 6);
229
+ assert.deepEqual(webex.logger.buffer.buffer[0][2], 'wx-js-sdk');
230
+ assert.deepEqual(webex.logger.buffer.buffer[0][3], 'foo');
231
+ assert.deepEqual(webex.logger.buffer.buffer[0][4], 'bar');
232
+ assert.deepEqual(webex.logger.buffer.buffer[0][5], '{"headers":{"trackingid":"123"},"test":"object","nested":{"test2":"object2"}}');
233
233
  });
234
234
 
235
235
  it('formats Errors correctly', async () => {
@@ -237,10 +237,10 @@ describe('plugin-logger', () => {
237
237
  const err = new Error('fake error for testing')
238
238
 
239
239
  webex.logger.log('I got this error:', err);
240
- assert.lengthOf(webex.logger.buffer, 1);
241
- assert.deepEqual(webex.logger.buffer[0][2], 'wx-js-sdk');
242
- assert.deepEqual(webex.logger.buffer[0][3], 'I got this error:');
243
- assert.deepEqual(webex.logger.buffer[0][4], 'Error: fake error for testing');
240
+ assert.lengthOf(webex.logger.buffer.buffer, 1);
241
+ assert.deepEqual(webex.logger.buffer.buffer[0][2], 'wx-js-sdk');
242
+ assert.deepEqual(webex.logger.buffer.buffer[0][3], 'I got this error:');
243
+ assert.deepEqual(webex.logger.buffer.buffer[0][4], 'Error: fake error for testing');
244
244
 
245
245
  });
246
246
  });
@@ -888,6 +888,317 @@ describe('plugin-logger', () => {
888
888
 
889
889
  checkAscending(logs);
890
890
  });
891
+
892
+ describe('diff vs full logs', () => {
893
+ let counter;
894
+ let clock;
895
+
896
+ const doSomeLogs = (count) => {
897
+ // do alternate logs from client and sdk
898
+ for (let i = 0; i < count; i += 1) {
899
+ if (webex.config.logger.separateLogBuffers) {
900
+ webex.logger.client_log(counter);
901
+ clock.tick(1000);
902
+ }
903
+ webex.logger.log(counter);
904
+ clock.tick(1000);
905
+
906
+ counter += 1;
907
+ }
908
+ };
909
+
910
+ beforeEach(() => {
911
+ counter = 0;
912
+ clock = sinon.useFakeTimers();
913
+ });
914
+
915
+ afterEach(() => {
916
+ clock.restore();
917
+ });
918
+
919
+ it('sends diff logs correctly (with separateLogBuffers)', async () => {
920
+ webex.config.logger.separateLogBuffers = true;
921
+ webex.config.logger.clientName = 'someclient';
922
+
923
+ doSomeLogs(5);
924
+
925
+ const logs1 = webex.logger.formatLogs({diff: true});
926
+
927
+ assert.deepEqual(logs1.split('\n'), [
928
+ ',1970-01-01T00:00:00.000Z,someclient,0',
929
+ ',1970-01-01T00:00:01.000Z,wx-js-sdk,0',
930
+ ',1970-01-01T00:00:02.000Z,someclient,1',
931
+ ',1970-01-01T00:00:03.000Z,wx-js-sdk,1',
932
+ ',1970-01-01T00:00:04.000Z,someclient,2',
933
+ ',1970-01-01T00:00:05.000Z,wx-js-sdk,2',
934
+ ',1970-01-01T00:00:06.000Z,someclient,3',
935
+ ',1970-01-01T00:00:07.000Z,wx-js-sdk,3',
936
+ ',1970-01-01T00:00:08.000Z,someclient,4',
937
+ ',1970-01-01T00:00:09.000Z,wx-js-sdk,4',
938
+ ]);
939
+
940
+ // log more lines
941
+ doSomeLogs(2);
942
+
943
+ const logs2 = webex.logger.formatLogs({diff: true});
944
+
945
+ // only the logs added after previous call to formatLogs() should be returned
946
+ assert.deepEqual(logs2.split('\n'), [
947
+ ',1970-01-01T00:00:10.000Z,someclient,5',
948
+ ',1970-01-01T00:00:11.000Z,wx-js-sdk,5',
949
+ ',1970-01-01T00:00:12.000Z,someclient,6',
950
+ ',1970-01-01T00:00:13.000Z,wx-js-sdk,6',
951
+ ]);
952
+
953
+ // now ask for full logs - it should contain all 15 logs
954
+ const fullLogs1 = webex.logger.formatLogs();
955
+
956
+ assert.deepEqual(fullLogs1.split('\n'), [
957
+ ',1970-01-01T00:00:00.000Z,someclient,0',
958
+ ',1970-01-01T00:00:01.000Z,wx-js-sdk,0',
959
+ ',1970-01-01T00:00:02.000Z,someclient,1',
960
+ ',1970-01-01T00:00:03.000Z,wx-js-sdk,1',
961
+ ',1970-01-01T00:00:04.000Z,someclient,2',
962
+ ',1970-01-01T00:00:05.000Z,wx-js-sdk,2',
963
+ ',1970-01-01T00:00:06.000Z,someclient,3',
964
+ ',1970-01-01T00:00:07.000Z,wx-js-sdk,3',
965
+ ',1970-01-01T00:00:08.000Z,someclient,4',
966
+ ',1970-01-01T00:00:09.000Z,wx-js-sdk,4',
967
+ ',1970-01-01T00:00:10.000Z,someclient,5',
968
+ ',1970-01-01T00:00:11.000Z,wx-js-sdk,5',
969
+ ',1970-01-01T00:00:12.000Z,someclient,6',
970
+ ',1970-01-01T00:00:13.000Z,wx-js-sdk,6',
971
+ ]);
972
+
973
+ // asking for full logs should not affect the next diff
974
+ const logs3 = webex.logger.formatLogs({diff: true});
975
+
976
+ // expect empty logs, because we didn't log anything since previous call to formatLogs with diff=true
977
+ assert.deepEqual(logs3.split('\n'), ['']);
978
+
979
+ // add more logs again
980
+ doSomeLogs(1);
981
+
982
+ const logs4 = webex.logger.formatLogs({diff: true});
983
+
984
+ assert.deepEqual(logs4.split('\n'), [
985
+ ',1970-01-01T00:00:14.000Z,someclient,7',
986
+ ',1970-01-01T00:00:15.000Z,wx-js-sdk,7',
987
+ ]);
988
+
989
+ // and check that full log contains everything right from the beginning irrespective of any previous calls to formatLogs()
990
+ const fullLogs2 = webex.logger.formatLogs();
991
+
992
+ assert.deepEqual(fullLogs2.split('\n'), [
993
+ ',1970-01-01T00:00:00.000Z,someclient,0',
994
+ ',1970-01-01T00:00:01.000Z,wx-js-sdk,0',
995
+ ',1970-01-01T00:00:02.000Z,someclient,1',
996
+ ',1970-01-01T00:00:03.000Z,wx-js-sdk,1',
997
+ ',1970-01-01T00:00:04.000Z,someclient,2',
998
+ ',1970-01-01T00:00:05.000Z,wx-js-sdk,2',
999
+ ',1970-01-01T00:00:06.000Z,someclient,3',
1000
+ ',1970-01-01T00:00:07.000Z,wx-js-sdk,3',
1001
+ ',1970-01-01T00:00:08.000Z,someclient,4',
1002
+ ',1970-01-01T00:00:09.000Z,wx-js-sdk,4',
1003
+ ',1970-01-01T00:00:10.000Z,someclient,5',
1004
+ ',1970-01-01T00:00:11.000Z,wx-js-sdk,5',
1005
+ ',1970-01-01T00:00:12.000Z,someclient,6',
1006
+ ',1970-01-01T00:00:13.000Z,wx-js-sdk,6',
1007
+ ',1970-01-01T00:00:14.000Z,someclient,7',
1008
+ ',1970-01-01T00:00:15.000Z,wx-js-sdk,7',
1009
+ ]);
1010
+ });
1011
+
1012
+ it('sends diff logs correctly (without separateLogBuffers)', async () => {
1013
+ webex.config.logger.separateLogBuffers = false;
1014
+
1015
+ doSomeLogs(5);
1016
+
1017
+ const logs1 = webex.logger.formatLogs({diff: true});
1018
+
1019
+ assert.deepEqual(logs1.split('\n'), [
1020
+ ',1970-01-01T00:00:00.000Z,wx-js-sdk,0',
1021
+ ',1970-01-01T00:00:01.000Z,wx-js-sdk,1',
1022
+ ',1970-01-01T00:00:02.000Z,wx-js-sdk,2',
1023
+ ',1970-01-01T00:00:03.000Z,wx-js-sdk,3',
1024
+ ',1970-01-01T00:00:04.000Z,wx-js-sdk,4',
1025
+ ]);
1026
+
1027
+ // log more lines
1028
+ doSomeLogs(2);
1029
+
1030
+ const logs2 = webex.logger.formatLogs({diff: true});
1031
+
1032
+ // only the logs added after previous call to formatLogs() should be returned
1033
+ assert.deepEqual(logs2.split('\n'), [
1034
+ ',1970-01-01T00:00:05.000Z,wx-js-sdk,5',
1035
+ ',1970-01-01T00:00:06.000Z,wx-js-sdk,6',
1036
+ ]);
1037
+
1038
+ // now ask for full logs - it should contain all 7 logs
1039
+ const fullLogs1 = webex.logger.formatLogs();
1040
+
1041
+ assert.deepEqual(fullLogs1.split('\n'), [
1042
+ ',1970-01-01T00:00:00.000Z,wx-js-sdk,0',
1043
+ ',1970-01-01T00:00:01.000Z,wx-js-sdk,1',
1044
+ ',1970-01-01T00:00:02.000Z,wx-js-sdk,2',
1045
+ ',1970-01-01T00:00:03.000Z,wx-js-sdk,3',
1046
+ ',1970-01-01T00:00:04.000Z,wx-js-sdk,4',
1047
+ ',1970-01-01T00:00:05.000Z,wx-js-sdk,5',
1048
+ ',1970-01-01T00:00:06.000Z,wx-js-sdk,6',
1049
+ ]);
1050
+
1051
+ // asking for full logs should not affect the next diff
1052
+ const logs3 = webex.logger.formatLogs({diff: true});
1053
+
1054
+ // expect empty logs, because we didn't log anything since previous call to formatLogs with diff=true
1055
+ assert.deepEqual(logs3.split('\n'), ['']);
1056
+
1057
+ // add more logs again
1058
+ doSomeLogs(1);
1059
+
1060
+ const logs4 = webex.logger.formatLogs({diff: true});
1061
+
1062
+ assert.deepEqual(logs4.split('\n'), [',1970-01-01T00:00:07.000Z,wx-js-sdk,7']);
1063
+
1064
+ // and check that full log contains everything right from the beginning irrespective of any previous calls to formatLogs()
1065
+ const fullLogs2 = webex.logger.formatLogs();
1066
+
1067
+ assert.deepEqual(fullLogs2.split('\n'), [
1068
+ ',1970-01-01T00:00:00.000Z,wx-js-sdk,0',
1069
+ ',1970-01-01T00:00:01.000Z,wx-js-sdk,1',
1070
+ ',1970-01-01T00:00:02.000Z,wx-js-sdk,2',
1071
+ ',1970-01-01T00:00:03.000Z,wx-js-sdk,3',
1072
+ ',1970-01-01T00:00:04.000Z,wx-js-sdk,4',
1073
+ ',1970-01-01T00:00:05.000Z,wx-js-sdk,5',
1074
+ ',1970-01-01T00:00:06.000Z,wx-js-sdk,6',
1075
+ ',1970-01-01T00:00:07.000Z,wx-js-sdk,7',
1076
+ ]);
1077
+ });
1078
+
1079
+ it('works correctly when history limit is reached (with separateLogBuffers)', async () => {
1080
+ webex.config.logger.separateLogBuffers = true;
1081
+ webex.config.logger.clientName = 'someclient';
1082
+ webex.config.logger.historyLength = 5;
1083
+
1084
+ // fill up the history
1085
+ doSomeLogs(5);
1086
+
1087
+ const logsFull1 = webex.logger.formatLogs({diff: false});
1088
+
1089
+ assert.deepEqual(logsFull1.split('\n'), [
1090
+ ',1970-01-01T00:00:00.000Z,someclient,0',
1091
+ ',1970-01-01T00:00:01.000Z,wx-js-sdk,0',
1092
+ ',1970-01-01T00:00:02.000Z,someclient,1',
1093
+ ',1970-01-01T00:00:03.000Z,wx-js-sdk,1',
1094
+ ',1970-01-01T00:00:04.000Z,someclient,2',
1095
+ ',1970-01-01T00:00:05.000Z,wx-js-sdk,2',
1096
+ ',1970-01-01T00:00:06.000Z,someclient,3',
1097
+ ',1970-01-01T00:00:07.000Z,wx-js-sdk,3',
1098
+ ',1970-01-01T00:00:08.000Z,someclient,4',
1099
+ ',1970-01-01T00:00:09.000Z,wx-js-sdk,4',
1100
+ ]);
1101
+
1102
+ // log more lines, this should cause removal of the oldest logs
1103
+ doSomeLogs(2);
1104
+
1105
+ const logsFull2 = webex.logger.formatLogs({diff: false});
1106
+
1107
+ const last5Logs = [
1108
+ ',1970-01-01T00:00:04.000Z,someclient,2',
1109
+ ',1970-01-01T00:00:05.000Z,wx-js-sdk,2',
1110
+ ',1970-01-01T00:00:06.000Z,someclient,3',
1111
+ ',1970-01-01T00:00:07.000Z,wx-js-sdk,3',
1112
+ ',1970-01-01T00:00:08.000Z,someclient,4',
1113
+ ',1970-01-01T00:00:09.000Z,wx-js-sdk,4',
1114
+ ',1970-01-01T00:00:10.000Z,someclient,5',
1115
+ ',1970-01-01T00:00:11.000Z,wx-js-sdk,5',
1116
+ ',1970-01-01T00:00:12.000Z,someclient,6',
1117
+ ',1970-01-01T00:00:13.000Z,wx-js-sdk,6',
1118
+ ];
1119
+ assert.deepEqual(logsFull2.split('\n'), last5Logs);
1120
+
1121
+ // check also the diff logs - they should also have just last 5 logs
1122
+ const logsDiff1 = webex.logger.formatLogs({diff: true});
1123
+ assert.deepEqual(logsDiff1.split('\n'), last5Logs);
1124
+
1125
+ // add more logs again and check full and diff logs
1126
+ doSomeLogs(1);
1127
+
1128
+ const logsFull3 = webex.logger.formatLogs({diff: false});
1129
+
1130
+ assert.deepEqual(logsFull3.split('\n'), [
1131
+ ',1970-01-01T00:00:06.000Z,someclient,3',
1132
+ ',1970-01-01T00:00:07.000Z,wx-js-sdk,3',
1133
+ ',1970-01-01T00:00:08.000Z,someclient,4',
1134
+ ',1970-01-01T00:00:09.000Z,wx-js-sdk,4',
1135
+ ',1970-01-01T00:00:10.000Z,someclient,5',
1136
+ ',1970-01-01T00:00:11.000Z,wx-js-sdk,5',
1137
+ ',1970-01-01T00:00:12.000Z,someclient,6',
1138
+ ',1970-01-01T00:00:13.000Z,wx-js-sdk,6',
1139
+ ',1970-01-01T00:00:14.000Z,someclient,7',
1140
+ ',1970-01-01T00:00:15.000Z,wx-js-sdk,7',
1141
+ ]);
1142
+
1143
+ const logsDiff2 = webex.logger.formatLogs({diff: true});
1144
+ assert.deepEqual(logsDiff2.split('\n'), [
1145
+ ',1970-01-01T00:00:14.000Z,someclient,7',
1146
+ ',1970-01-01T00:00:15.000Z,wx-js-sdk,7',
1147
+ ]);
1148
+ });
1149
+
1150
+ it('works correctly when history limit is reached (without separateLogBuffers)', async () => {
1151
+ webex.config.logger.separateLogBuffers = false;
1152
+ webex.config.logger.historyLength = 5;
1153
+
1154
+ // fill up the history
1155
+ doSomeLogs(5);
1156
+
1157
+ const logsFull1 = webex.logger.formatLogs({diff: false});
1158
+
1159
+ assert.deepEqual(logsFull1.split('\n'), [
1160
+ ',1970-01-01T00:00:00.000Z,wx-js-sdk,0',
1161
+ ',1970-01-01T00:00:01.000Z,wx-js-sdk,1',
1162
+ ',1970-01-01T00:00:02.000Z,wx-js-sdk,2',
1163
+ ',1970-01-01T00:00:03.000Z,wx-js-sdk,3',
1164
+ ',1970-01-01T00:00:04.000Z,wx-js-sdk,4',
1165
+ ]);
1166
+
1167
+ // log more lines, this should cause removal of the oldest logs
1168
+ doSomeLogs(2);
1169
+
1170
+ const logsFull2 = webex.logger.formatLogs({diff: false});
1171
+
1172
+ const last5Logs = [
1173
+ ',1970-01-01T00:00:02.000Z,wx-js-sdk,2',
1174
+ ',1970-01-01T00:00:03.000Z,wx-js-sdk,3',
1175
+ ',1970-01-01T00:00:04.000Z,wx-js-sdk,4',
1176
+ ',1970-01-01T00:00:05.000Z,wx-js-sdk,5',
1177
+ ',1970-01-01T00:00:06.000Z,wx-js-sdk,6',
1178
+ ];
1179
+ assert.deepEqual(logsFull2.split('\n'), last5Logs);
1180
+
1181
+ // check also the diff logs - they should also have just last 5 logs
1182
+ const logsDiff1 = webex.logger.formatLogs({diff: true});
1183
+ assert.deepEqual(logsDiff1.split('\n'), last5Logs);
1184
+
1185
+ // add more logs again and check full and diff logs
1186
+ doSomeLogs(1);
1187
+
1188
+ const logsFull3 = webex.logger.formatLogs({diff: false});
1189
+
1190
+ assert.deepEqual(logsFull3.split('\n'), [
1191
+ ',1970-01-01T00:00:03.000Z,wx-js-sdk,3',
1192
+ ',1970-01-01T00:00:04.000Z,wx-js-sdk,4',
1193
+ ',1970-01-01T00:00:05.000Z,wx-js-sdk,5',
1194
+ ',1970-01-01T00:00:06.000Z,wx-js-sdk,6',
1195
+ ',1970-01-01T00:00:07.000Z,wx-js-sdk,7',
1196
+ ]);
1197
+
1198
+ const logsDiff2 = webex.logger.formatLogs({diff: true});
1199
+ assert.deepEqual(logsDiff2.split('\n'), [',1970-01-01T00:00:07.000Z,wx-js-sdk,7']);
1200
+ });
1201
+ });
891
1202
  });
892
1203
 
893
1204
  describe('#logToBuffer()', () => {
@@ -895,7 +1206,7 @@ describe('plugin-logger', () => {
895
1206
  webex.logger.logToBuffer('sdklog');
896
1207
  webex.logger.client_logToBuffer('clientlog');
897
1208
 
898
- assert.lengthOf(webex.logger.buffer, 2);
1209
+ assert.lengthOf(webex.logger.buffer.buffer, 2);
899
1210
 
900
1211
  logSpies.forEach((logSpy) => {
901
1212
  assert.notCalled(logSpy);
@@ -908,8 +1219,8 @@ describe('plugin-logger', () => {
908
1219
  webex.logger.logToBuffer('sdklog');
909
1220
  webex.logger.client_logToBuffer('clientlog');
910
1221
 
911
- assert.lengthOf(webex.logger.sdkBuffer, 1);
912
- assert.lengthOf(webex.logger.clientBuffer, 1);
1222
+ assert.lengthOf(webex.logger.sdkBuffer.buffer, 1);
1223
+ assert.lengthOf(webex.logger.clientBuffer.buffer, 1);
913
1224
 
914
1225
  logSpies.forEach((logSpy) => {
915
1226
  assert.notCalled(logSpy);
@@ -918,7 +1229,7 @@ describe('plugin-logger', () => {
918
1229
  });
919
1230
  describe('limit', () => {
920
1231
  function logMessages() {
921
- return webex.logger.buffer.map((item) => item[3]);
1232
+ return webex.logger.buffer.buffer.map((item) => item[3]);
922
1233
  }
923
1234
 
924
1235
  it('can be increased in runtime', () => {
@@ -928,12 +1239,12 @@ describe('plugin-logger', () => {
928
1239
  }
929
1240
 
930
1241
  assert.deepEqual(logMessages(), [5, 6, 7, 8, 9]);
931
- assert.lengthOf(webex.logger.buffer, 5);
1242
+ assert.lengthOf(webex.logger.buffer.buffer, 5);
932
1243
 
933
1244
  webex.logger.config.historyLength = 10;
934
1245
  webex.logger.log(10);
935
1246
  assert.deepEqual(logMessages(), [5, 6, 7, 8, 9, 10]);
936
- assert.lengthOf(webex.logger.buffer, 6);
1247
+ assert.lengthOf(webex.logger.buffer.buffer, 6);
937
1248
  });
938
1249
 
939
1250
  it('can be decreased in runtime', () => {
@@ -942,16 +1253,16 @@ describe('plugin-logger', () => {
942
1253
  }
943
1254
 
944
1255
  assert.deepEqual(logMessages(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
945
- assert.lengthOf(webex.logger.buffer, 10);
1256
+ assert.lengthOf(webex.logger.buffer.buffer, 10);
946
1257
 
947
1258
  webex.logger.config.historyLength = 5;
948
1259
 
949
1260
  // Log buffer truncated when the next log added
950
- assert.lengthOf(webex.logger.buffer, 10);
1261
+ assert.lengthOf(webex.logger.buffer.buffer, 10);
951
1262
 
952
1263
  webex.logger.log(10);
953
1264
  assert.deepEqual(logMessages(), [6, 7, 8, 9, 10]);
954
- assert.lengthOf(webex.logger.buffer, 5);
1265
+ assert.lengthOf(webex.logger.buffer.buffer, 5);
955
1266
  });
956
1267
  });
957
1268
  });