@webex/plugin-logger 3.0.0-beta.9 → 3.0.0-beta.91
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/config.js +0 -4
- package/dist/config.js.map +1 -1
- package/dist/index.js +1 -13
- package/dist/index.js.map +1 -1
- package/dist/logger.js +24 -75
- package/dist/logger.js.map +1 -1
- package/package.json +7 -7
- package/src/config.js +2 -2
- package/src/index.js +2 -5
- package/src/logger.js +53 -43
- package/test/unit/spec/logger.js +235 -96
package/dist/config.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
-
|
|
5
4
|
_Object$defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
|
|
9
7
|
exports.default = void 0;
|
|
10
|
-
|
|
11
8
|
/*!
|
|
12
9
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
13
10
|
*/
|
|
14
|
-
|
|
15
11
|
/**
|
|
16
12
|
* @typedef {Object} LoggerConfig
|
|
17
13
|
* @property {string} [level=process.env.WEBEX_LOG_LEVEL] - Maximum log level that
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["logger","level","process","env","WEBEX_LOG_LEVEL","historyLength"],"sources":["config.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/**\n * @typedef {Object} LoggerConfig\n * @property {string} [level=process.env.WEBEX_LOG_LEVEL] - Maximum log level that\n * should be printed to the console. One of\n * silent|error|warn|log|info|debug|trace\n * @property {number} [historyLength=1000] - Maximum number of entries to store in the log buffer.\n * @example\n * {\n * level: process.env.WEBEX_LOG_LEVEL,\n * historyLength: 1000\n * }\n */\n\nexport default {\n logger: {\n level: process.env.WEBEX_LOG_LEVEL,\n historyLength: 1000
|
|
1
|
+
{"version":3,"names":["logger","level","process","env","WEBEX_LOG_LEVEL","historyLength"],"sources":["config.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/**\n * @typedef {Object} LoggerConfig\n * @property {string} [level=process.env.WEBEX_LOG_LEVEL] - Maximum log level that\n * should be printed to the console. One of\n * silent|error|warn|log|info|debug|trace\n * @property {number} [historyLength=1000] - Maximum number of entries to store in the log buffer.\n * @example\n * {\n * level: process.env.WEBEX_LOG_LEVEL,\n * historyLength: 1000\n * }\n */\n\nexport default {\n logger: {\n level: process.env.WEBEX_LOG_LEVEL,\n historyLength: 1000,\n },\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAXA,eAae;EACbA,MAAM,EAAE;IACNC,KAAK,EAAEC,OAAO,CAACC,GAAG,CAACC,eAAe;IAClCC,aAAa,EAAE;EACjB;AACF,CAAC;AAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,46 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
|
|
4
|
-
|
|
5
4
|
var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
|
|
6
|
-
|
|
7
5
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
8
|
-
|
|
9
6
|
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
10
|
-
|
|
11
7
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
12
|
-
|
|
13
8
|
_Object$defineProperty(exports, "__esModule", {
|
|
14
9
|
value: true
|
|
15
10
|
});
|
|
16
|
-
|
|
17
11
|
_Object$defineProperty(exports, "default", {
|
|
18
12
|
enumerable: true,
|
|
19
13
|
get: function get() {
|
|
20
14
|
return _logger.default;
|
|
21
15
|
}
|
|
22
16
|
});
|
|
23
|
-
|
|
24
17
|
_Object$defineProperty(exports, "levels", {
|
|
25
18
|
enumerable: true,
|
|
26
19
|
get: function get() {
|
|
27
20
|
return _logger.levels;
|
|
28
21
|
}
|
|
29
22
|
});
|
|
30
|
-
|
|
31
23
|
var _webexCore = require("@webex/webex-core");
|
|
32
|
-
|
|
33
24
|
var _logger = _interopRequireWildcard(require("./logger"));
|
|
34
|
-
|
|
35
25
|
var _config = _interopRequireDefault(require("./config"));
|
|
36
|
-
|
|
37
26
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
38
|
-
|
|
39
27
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
40
|
-
|
|
41
28
|
/*!
|
|
42
29
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
43
30
|
*/
|
|
31
|
+
|
|
44
32
|
(0, _webexCore.registerPlugin)('logger', _logger.default, {
|
|
45
33
|
config: _config.default,
|
|
46
34
|
replace: true
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["registerPlugin","Logger","config","replace"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {registerPlugin} from '@webex/webex-core';\n\nimport Logger from './logger';\nimport config from './config';\n\nregisterPlugin('logger', Logger, {\n config,\n replace: true
|
|
1
|
+
{"version":3,"names":["registerPlugin","Logger","config","replace"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {registerPlugin} from '@webex/webex-core';\n\nimport Logger from './logger';\nimport config from './config';\n\nregisterPlugin('logger', Logger, {\n config,\n replace: true,\n});\n\nexport {default, levels} from './logger';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIA;AAEA;AACA;AAA8B;AAAA;AAP9B;AACA;AACA;;AAOA,IAAAA,yBAAc,EAAC,QAAQ,EAAEC,eAAM,EAAE;EAC/BC,MAAM,EAANA,eAAM;EACNC,OAAO,EAAE;AACX,CAAC,CAAC"}
|
package/dist/logger.js
CHANGED
|
@@ -1,42 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
|
|
11
8
|
exports.levels = exports.default = void 0;
|
|
12
|
-
|
|
13
9
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
|
|
14
|
-
|
|
15
10
|
var _entries = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/entries"));
|
|
16
|
-
|
|
17
11
|
var _deleteProperty = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/delete-property"));
|
|
18
|
-
|
|
19
12
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
|
|
20
|
-
|
|
21
13
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
22
|
-
|
|
23
14
|
var _isString2 = _interopRequireDefault(require("lodash/isString"));
|
|
24
|
-
|
|
25
15
|
var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
|
|
26
|
-
|
|
27
16
|
var _isArray2 = _interopRequireDefault(require("lodash/isArray"));
|
|
28
|
-
|
|
29
17
|
var _has2 = _interopRequireDefault(require("lodash/has"));
|
|
30
|
-
|
|
31
18
|
var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
32
|
-
|
|
33
19
|
var _common = require("@webex/common");
|
|
34
|
-
|
|
35
20
|
var _webexCore = require("@webex/webex-core");
|
|
36
|
-
|
|
37
21
|
/*!
|
|
38
22
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
39
23
|
*/
|
|
24
|
+
|
|
40
25
|
var precedence = {
|
|
41
26
|
silent: 0,
|
|
42
27
|
group: 1,
|
|
@@ -65,6 +50,7 @@ var LOG_TYPES = {
|
|
|
65
50
|
};
|
|
66
51
|
var SDK_LOG_TYPE_NAME = 'wx-js-sdk';
|
|
67
52
|
var authTokenKeyPattern = /[Aa]uthorization/;
|
|
53
|
+
|
|
68
54
|
/**
|
|
69
55
|
* Recursively strips "authorization" fields from the specified object
|
|
70
56
|
* @param {Object} object
|
|
@@ -72,52 +58,42 @@ var authTokenKeyPattern = /[Aa]uthorization/;
|
|
|
72
58
|
* @private
|
|
73
59
|
* @returns {Object}
|
|
74
60
|
*/
|
|
75
|
-
|
|
76
61
|
function walkAndFilter(object) {
|
|
77
62
|
var visited = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
78
|
-
|
|
79
63
|
if (visited.includes(object)) {
|
|
80
64
|
// Prevent circular references
|
|
81
65
|
return object;
|
|
82
66
|
}
|
|
83
|
-
|
|
84
67
|
visited.push(object);
|
|
85
|
-
|
|
86
68
|
if ((0, _isArray2.default)(object)) {
|
|
87
69
|
return object.map(function (o) {
|
|
88
70
|
return walkAndFilter(o, visited);
|
|
89
71
|
});
|
|
90
72
|
}
|
|
91
|
-
|
|
92
73
|
if (!(0, _isObject2.default)(object)) {
|
|
93
74
|
if ((0, _isString2.default)(object)) {
|
|
94
75
|
if (_common.patterns.containsEmails.test(object)) {
|
|
95
76
|
return object.replace(_common.patterns.containsEmails, '[REDACTED]');
|
|
96
77
|
}
|
|
97
78
|
}
|
|
98
|
-
|
|
99
79
|
return object;
|
|
100
80
|
}
|
|
101
|
-
|
|
102
81
|
for (var _i = 0, _Object$entries = (0, _entries.default)(object); _i < _Object$entries.length; _i++) {
|
|
103
82
|
var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
83
|
+
key = _Object$entries$_i[0],
|
|
84
|
+
value = _Object$entries$_i[1];
|
|
107
85
|
if (authTokenKeyPattern.test(key)) {
|
|
108
86
|
(0, _deleteProperty.default)(object, key);
|
|
109
87
|
} else {
|
|
110
88
|
object[key] = walkAndFilter(value, visited);
|
|
111
89
|
}
|
|
112
90
|
}
|
|
113
|
-
|
|
114
91
|
return object;
|
|
115
92
|
}
|
|
93
|
+
|
|
116
94
|
/**
|
|
117
95
|
* @class
|
|
118
96
|
*/
|
|
119
|
-
|
|
120
|
-
|
|
121
97
|
var Logger = _webexCore.WebexPlugin.extend({
|
|
122
98
|
namespace: 'Logger',
|
|
123
99
|
derived: {
|
|
@@ -162,7 +138,6 @@ var Logger = _webexCore.WebexPlugin.extend({
|
|
|
162
138
|
}
|
|
163
139
|
}
|
|
164
140
|
},
|
|
165
|
-
|
|
166
141
|
/**
|
|
167
142
|
* Ensures auth headers don't get printed in logs
|
|
168
143
|
* @param {Array<mixed>} args
|
|
@@ -174,7 +149,6 @@ var Logger = _webexCore.WebexPlugin.extend({
|
|
|
174
149
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
175
150
|
args[_key] = arguments[_key];
|
|
176
151
|
}
|
|
177
|
-
|
|
178
152
|
return args.map(function (arg) {
|
|
179
153
|
// WebexHttpError already ensures auth tokens don't get printed, so, no
|
|
180
154
|
// need to alter it here.
|
|
@@ -188,15 +162,12 @@ var Logger = _webexCore.WebexPlugin.extend({
|
|
|
188
162
|
ret += 'END STACK';
|
|
189
163
|
return ret;
|
|
190
164
|
}
|
|
191
|
-
|
|
192
165
|
return arg;
|
|
193
166
|
}
|
|
194
|
-
|
|
195
167
|
arg = (0, _cloneDeep2.default)(arg);
|
|
196
168
|
return walkAndFilter(arg);
|
|
197
169
|
});
|
|
198
170
|
},
|
|
199
|
-
|
|
200
171
|
/**
|
|
201
172
|
* Determines if the current level allows logs at the specified level to be
|
|
202
173
|
* printed
|
|
@@ -210,7 +181,6 @@ var Logger = _webexCore.WebexPlugin.extend({
|
|
|
210
181
|
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : LOG_TYPES.SDK;
|
|
211
182
|
return precedence[level] <= precedence[type === LOG_TYPES.SDK ? this.getCurrentLevel() : this.getCurrentClientLevel()];
|
|
212
183
|
},
|
|
213
|
-
|
|
214
184
|
/**
|
|
215
185
|
* Determines if the current level allows logs at the specified level to be
|
|
216
186
|
* put into the log buffer. We're configuring it omit trace and debug logs
|
|
@@ -226,7 +196,6 @@ var Logger = _webexCore.WebexPlugin.extend({
|
|
|
226
196
|
shouldBuffer: function shouldBuffer(level) {
|
|
227
197
|
return precedence[level] <= (this.config.bufferLogLevel ? precedence[this.config.bufferLogLevel] : precedence.info);
|
|
228
198
|
},
|
|
229
|
-
|
|
230
199
|
/**
|
|
231
200
|
* Indicates the current SDK log level based on env vars, feature toggles, and
|
|
232
201
|
* user type.
|
|
@@ -242,28 +211,24 @@ var Logger = _webexCore.WebexPlugin.extend({
|
|
|
242
211
|
if (this.config.level) {
|
|
243
212
|
return this.config.level;
|
|
244
213
|
}
|
|
245
|
-
|
|
246
214
|
if (levels.includes(process.env.WEBEX_LOG_LEVEL)) {
|
|
247
215
|
return process.env.WEBEX_LOG_LEVEL;
|
|
248
|
-
}
|
|
249
|
-
|
|
216
|
+
}
|
|
250
217
|
|
|
218
|
+
// Always use debug-level logging in test mode;
|
|
251
219
|
if (process.env.NODE_ENV === 'test') {
|
|
252
220
|
return 'trace';
|
|
253
|
-
}
|
|
254
|
-
|
|
221
|
+
}
|
|
255
222
|
|
|
223
|
+
// Use server-side-feature toggles to configure log levels
|
|
256
224
|
var level = this.webex.internal.device && this.webex.internal.device.features.developer.get('log-level');
|
|
257
|
-
|
|
258
225
|
if (level) {
|
|
259
226
|
if (levels.includes(level)) {
|
|
260
227
|
return level;
|
|
261
228
|
}
|
|
262
229
|
}
|
|
263
|
-
|
|
264
230
|
return 'error';
|
|
265
231
|
},
|
|
266
|
-
|
|
267
232
|
/**
|
|
268
233
|
* Indicates the current client log level based on config, defaults to SDK level
|
|
269
234
|
* @instance
|
|
@@ -276,12 +241,11 @@ var Logger = _webexCore.WebexPlugin.extend({
|
|
|
276
241
|
// If a client log level has been explicitly set via config, alway use it.
|
|
277
242
|
if (this.config.clientLevel) {
|
|
278
243
|
return this.config.clientLevel;
|
|
279
|
-
}
|
|
280
|
-
|
|
244
|
+
}
|
|
281
245
|
|
|
246
|
+
// otherwise default to SDK level
|
|
282
247
|
return this.getCurrentLevel();
|
|
283
248
|
},
|
|
284
|
-
|
|
285
249
|
/**
|
|
286
250
|
* Format logs (for upload)
|
|
287
251
|
*
|
|
@@ -297,22 +261,22 @@ var Logger = _webexCore.WebexPlugin.extend({
|
|
|
297
261
|
function getDate(log) {
|
|
298
262
|
return log[1];
|
|
299
263
|
}
|
|
300
|
-
|
|
301
264
|
var buffer = [];
|
|
302
265
|
var clientIndex = 0;
|
|
303
266
|
var sdkIndex = 0;
|
|
304
|
-
|
|
305
267
|
if (this.config.separateLogBuffers) {
|
|
306
268
|
// merge the client and sdk buffers
|
|
307
269
|
// while we have entries in either buffer
|
|
308
270
|
while (clientIndex < this.clientBuffer.length || sdkIndex < this.sdkBuffer.length) {
|
|
309
271
|
// if we have remaining entries in the SDK buffer
|
|
310
|
-
if (sdkIndex < this.sdkBuffer.length && (
|
|
272
|
+
if (sdkIndex < this.sdkBuffer.length && (
|
|
273
|
+
// and we haven't exhausted all the client buffer entries, or SDK date is before client date
|
|
311
274
|
clientIndex >= this.clientBuffer.length || new Date(getDate(this.sdkBuffer[sdkIndex])) <= new Date(getDate(this.clientBuffer[clientIndex])))) {
|
|
312
275
|
// then add to the SDK buffer
|
|
313
276
|
buffer.push(this.sdkBuffer[sdkIndex]);
|
|
314
277
|
sdkIndex += 1;
|
|
315
|
-
}
|
|
278
|
+
}
|
|
279
|
+
// otherwise if we haven't exhausted all the client buffer entries, add client entry, whether it was because
|
|
316
280
|
// it was the only remaining entries or date was later (the above if)
|
|
317
281
|
else if (clientIndex < this.clientBuffer.length) {
|
|
318
282
|
buffer.push(this.clientBuffer[clientIndex]);
|
|
@@ -322,11 +286,11 @@ var Logger = _webexCore.WebexPlugin.extend({
|
|
|
322
286
|
} else {
|
|
323
287
|
buffer = this.buffer;
|
|
324
288
|
}
|
|
325
|
-
|
|
326
289
|
return buffer.join('\n');
|
|
327
290
|
},
|
|
328
|
-
version: "3.0.0-beta.
|
|
291
|
+
version: "3.0.0-beta.91"
|
|
329
292
|
});
|
|
293
|
+
|
|
330
294
|
/**
|
|
331
295
|
* Creates a logger method
|
|
332
296
|
*
|
|
@@ -342,8 +306,6 @@ var Logger = _webexCore.WebexPlugin.extend({
|
|
|
342
306
|
* @memberof Logger
|
|
343
307
|
* @returns {function} logger method with specified params
|
|
344
308
|
*/
|
|
345
|
-
|
|
346
|
-
|
|
347
309
|
function makeLoggerMethod(level, impl, type) {
|
|
348
310
|
var neverPrint = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
349
311
|
var alwaysBuffer = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
@@ -357,7 +319,6 @@ function makeLoggerMethod(level, impl, type) {
|
|
|
357
319
|
var clientName = logType === LOG_TYPES.SDK ? SDK_LOG_TYPE_NAME : this.config.clientName || logType;
|
|
358
320
|
var buffer;
|
|
359
321
|
var historyLength;
|
|
360
|
-
|
|
361
322
|
if (this.config.separateLogBuffers) {
|
|
362
323
|
historyLength = this.config.clientHistoryLength ? this.config.clientHistoryLength : this.config.historyLength;
|
|
363
324
|
buffer = logType === LOG_TYPES.SDK ? this.sdkBuffer : this.clientBuffer;
|
|
@@ -365,52 +326,42 @@ function makeLoggerMethod(level, impl, type) {
|
|
|
365
326
|
buffer = this.buffer;
|
|
366
327
|
historyLength = this.config.historyLength;
|
|
367
328
|
}
|
|
368
|
-
|
|
369
329
|
try {
|
|
370
330
|
var shouldPrint = !neverPrint && this.shouldPrint(level, logType);
|
|
371
331
|
var shouldBuffer = alwaysBuffer || this.shouldBuffer(level);
|
|
372
|
-
|
|
373
332
|
if (!shouldBuffer && !shouldPrint) {
|
|
374
333
|
return;
|
|
375
334
|
}
|
|
376
|
-
|
|
377
335
|
var filtered = [clientName].concat((0, _toConsumableArray2.default)(this.filter.apply(this, arguments)));
|
|
378
336
|
var stringified = filtered.map(function (item) {
|
|
379
337
|
if (item instanceof _webexCore.WebexHttpError) {
|
|
380
338
|
return item.toString();
|
|
381
339
|
}
|
|
382
|
-
|
|
383
340
|
return item;
|
|
384
341
|
});
|
|
385
|
-
|
|
386
342
|
if (shouldPrint) {
|
|
387
343
|
var _console;
|
|
388
|
-
|
|
389
344
|
// when logging an object in browsers, we tend to get a dynamic
|
|
390
345
|
// reference, thus going back to look at the logged value doesn't
|
|
391
346
|
// necessarily show the state at log time, thus we print the stringified
|
|
392
347
|
// value.
|
|
393
348
|
var toPrint = _common.inBrowser ? stringified : filtered;
|
|
394
|
-
/* istanbul ignore if */
|
|
395
349
|
|
|
350
|
+
/* istanbul ignore if */
|
|
396
351
|
if (process.env.NODE_ENV === 'test' && (0, _has2.default)(this, 'webex.internal.device.url')) {
|
|
397
352
|
toPrint.unshift(this.webex.internal.device.url.slice(-3));
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
|
|
353
|
+
}
|
|
354
|
+
// eslint-disable-next-line no-console
|
|
401
355
|
(_console = console)[impl].apply(_console, (0, _toConsumableArray2.default)(toPrint));
|
|
402
356
|
}
|
|
403
|
-
|
|
404
357
|
if (shouldBuffer) {
|
|
405
358
|
var logDate = new Date();
|
|
406
359
|
stringified.unshift(logDate.toISOString());
|
|
407
360
|
stringified.unshift('| '.repeat(this.groupLevel));
|
|
408
361
|
buffer.push(stringified);
|
|
409
|
-
|
|
410
362
|
if (buffer.length > historyLength) {
|
|
411
363
|
buffer.shift();
|
|
412
364
|
}
|
|
413
|
-
|
|
414
365
|
if (level === 'group') this.groupLevel += 1;
|
|
415
366
|
if (level === 'groupEnd' && this.groupLevel > 0) this.groupLevel -= 1;
|
|
416
367
|
}
|
|
@@ -423,20 +374,18 @@ function makeLoggerMethod(level, impl, type) {
|
|
|
423
374
|
}
|
|
424
375
|
};
|
|
425
376
|
}
|
|
426
|
-
|
|
427
377
|
levels.forEach(function (level) {
|
|
428
378
|
var impls = fallbacks[level];
|
|
429
379
|
var impl = level;
|
|
430
|
-
|
|
431
380
|
if (impls) {
|
|
432
|
-
impls = impls.slice();
|
|
433
|
-
|
|
381
|
+
impls = impls.slice();
|
|
382
|
+
// eslint-disable-next-line no-console
|
|
434
383
|
while (!console[impl]) {
|
|
435
384
|
impl = impls.pop();
|
|
436
385
|
}
|
|
437
|
-
}
|
|
438
|
-
|
|
386
|
+
}
|
|
439
387
|
|
|
388
|
+
// eslint-disable-next-line complexity
|
|
440
389
|
Logger.prototype["client_".concat(level)] = makeLoggerMethod(level, impl, LOG_TYPES.CLIENT);
|
|
441
390
|
Logger.prototype[level] = makeLoggerMethod(level, impl, LOG_TYPES.SDK);
|
|
442
391
|
});
|
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["precedence","silent","group","groupEnd","error","warn","log","info","debug","trace","levels","filter","level","fallbacks","LOG_TYPES","SDK","CLIENT","SDK_LOG_TYPE_NAME","authTokenKeyPattern","walkAndFilter","object","visited","includes","push","map","o","patterns","containsEmails","test","replace","key","value","Logger","WebexPlugin","extend","namespace","derived","cache","fn","getCurrentLevel","client_level","getCurrentClientLevel","session","buffer","type","default","groupLevel","sdkBuffer","clientBuffer","args","arg","Error","process","env","NODE_ENV","inBrowser","ret","toString","stack","shouldPrint","shouldBuffer","config","bufferLogLevel","WEBEX_LOG_LEVEL","webex","internal","device","features","developer","get","clientLevel","formatLogs","getDate","clientIndex","sdkIndex","separateLogBuffers","length","Date","join","makeLoggerMethod","impl","neverPrint","alwaysBuffer","wrappedConsoleMethod","logType","clientName","historyLength","clientHistoryLength","filtered","stringified","item","WebexHttpError","toPrint","unshift","url","slice","console","logDate","toISOString","repeat","shift","reason","forEach","impls","pop","prototype","client_logToBuffer","logToBuffer"],"sources":["logger.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {inBrowser, patterns} from '@webex/common';\nimport {\n WebexHttpError,\n WebexPlugin\n} from '@webex/webex-core';\nimport {\n cloneDeep,\n has,\n isArray,\n isObject,\n isString\n} 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 }\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 }\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 precedence[level] <= precedence[type === LOG_TYPES.SDK ? this.getCurrentLevel() : this.getCurrentClientLevel()];\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 precedence[level] <= (this.config.bufferLogLevel ? precedence[this.config.bufferLogLevel] : precedence.info);\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 = 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 (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])) <= new Date(getDate(this.clientBuffer[clientIndex]))))) {\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 }\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 = 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 ? this.config.clientHistoryLength : this.config.historyLength;\n buffer = logType === LOG_TYPES.SDK ? this.sdkBuffer : this.clientBuffer;\n }\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 WebexHttpError) {\n return item.toString();\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.shift();\n }\n if (level === 'group') this.groupLevel += 1;\n if (level === 'groupEnd' && this.groupLevel > 0) this.groupLevel -= 1;\n }\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\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 =\n makeLoggerMethod(levels.info, levels.info, LOG_TYPES.CLIENT, true, true);\nLogger.prototype.logToBuffer = makeLoggerMethod(levels.info, levels.info, LOG_TYPES.SDK, true, true);\n\nexport default Logger;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AACA;;AALA;AACA;AACA;AAeA,IAAMA,UAAU,GAAG;EACjBC,MAAM,EAAE,CADS;EAEjBC,KAAK,EAAE,CAFU;EAGjBC,QAAQ,EAAE,CAHO;EAIjBC,KAAK,EAAE,CAJU;EAKjBC,IAAI,EAAE,CALW;EAMjBC,GAAG,EAAE,CANY;EAOjBC,IAAI,EAAE,CAPW;EAQjBC,KAAK,EAAE,CARU;EASjBC,KAAK,EAAE;AATU,CAAnB;AAYO,IAAMC,MAAM,GAAG,mBAAYV,UAAZ,EAAwBW,MAAxB,CAA+B,UAACC,KAAD;EAAA,OAAWA,KAAK,KAAK,QAArB;AAAA,CAA/B,CAAf;;AAEP,IAAMC,SAAS,GAAG;EAChBT,KAAK,EAAE,CAAC,KAAD,CADS;EAEhBC,IAAI,EAAE,CAAC,OAAD,EAAU,KAAV,CAFU;EAGhBE,IAAI,EAAE,CAAC,KAAD,CAHU;EAIhBC,KAAK,EAAE,CAAC,MAAD,EAAS,KAAT,CAJS;EAKhBC,KAAK,EAAE,CAAC,OAAD,EAAU,MAAV,EAAkB,KAAlB;AALS,CAAlB;AAQA,IAAMK,SAAS,GAAG;EAChBC,GAAG,EAAE,KADW;EAEhBC,MAAM,EAAE;AAFQ,CAAlB;AAKA,IAAMC,iBAAiB,GAAG,WAA1B;AAEA,IAAMC,mBAAmB,GAAG,kBAA5B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,aAAT,CAAuBC,MAAvB,EAA6C;EAAA,IAAdC,OAAc,uEAAJ,EAAI;;EAC3C,IAAIA,OAAO,CAACC,QAAR,CAAiBF,MAAjB,CAAJ,EAA8B;IAC5B;IACA,OAAOA,MAAP;EACD;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Ae,OAAO,CAAC3F,IAAR,oCAAyCO,KAAzC,GAAkDyF,MAAlD;MACD;IACF;EACF,CAvED;AAwED;;AAED3F,MAAM,CAAC4F,OAAP,CAAe,UAAC1F,KAAD,EAAW;EACxB,IAAI2F,KAAK,GAAG1F,SAAS,CAACD,KAAD,CAArB;EACA,IAAIoE,IAAI,GAAGpE,KAAX;;EAEA,IAAI2F,KAAJ,EAAW;IACTA,KAAK,GAAGA,KAAK,CAACR,KAAN,EAAR,CADS,CAET;;IACA,OAAO,CAACC,OAAO,CAAChB,IAAD,CAAf,EAAuB;MACrBA,IAAI,GAAGuB,KAAK,CAACC,GAAN,EAAP;IACD;EACF,CAVuB,CAaxB;;;EACAxE,MAAM,CAACyE,SAAP,kBAA2B7F,KAA3B,KAAsCmE,gBAAgB,CAACnE,KAAD,EAAQoE,IAAR,EAAclE,SAAS,CAACE,MAAxB,CAAtD;EACAgB,MAAM,CAACyE,SAAP,CAAiB7F,KAAjB,IAA0BmE,gBAAgB,CAACnE,KAAD,EAAQoE,IAAR,EAAclE,SAAS,CAACC,GAAxB,CAA1C;AACD,CAhBD;AAkBAiB,MAAM,CAACyE,SAAP,CAAiBC,kBAAjB,GACE3B,gBAAgB,CAACrE,MAAM,CAACH,IAAR,EAAcG,MAAM,CAACH,IAArB,EAA2BO,SAAS,CAACE,MAArC,EAA6C,IAA7C,EAAmD,IAAnD,CADlB;AAEAgB,MAAM,CAACyE,SAAP,CAAiBE,WAAjB,GAA+B5B,gBAAgB,CAACrE,MAAM,CAACH,IAAR,EAAcG,MAAM,CAACH,IAArB,EAA2BO,SAAS,CAACC,GAArC,EAA0C,IAA1C,EAAgD,IAAhD,CAA/C;gBAEeiB,M"}
|
|
1
|
+
{"version":3,"names":["precedence","silent","group","groupEnd","error","warn","log","info","debug","trace","levels","filter","level","fallbacks","LOG_TYPES","SDK","CLIENT","SDK_LOG_TYPE_NAME","authTokenKeyPattern","walkAndFilter","object","visited","includes","push","map","o","patterns","containsEmails","test","replace","key","value","Logger","WebexPlugin","extend","namespace","derived","cache","fn","getCurrentLevel","client_level","getCurrentClientLevel","session","buffer","type","default","groupLevel","sdkBuffer","clientBuffer","args","arg","Error","process","env","NODE_ENV","inBrowser","ret","toString","stack","shouldPrint","shouldBuffer","config","bufferLogLevel","WEBEX_LOG_LEVEL","webex","internal","device","features","developer","get","clientLevel","formatLogs","getDate","clientIndex","sdkIndex","separateLogBuffers","length","Date","join","makeLoggerMethod","impl","neverPrint","alwaysBuffer","wrappedConsoleMethod","logType","clientName","historyLength","clientHistoryLength","filtered","stringified","item","WebexHttpError","toPrint","unshift","url","slice","console","logDate","toISOString","repeat","shift","reason","forEach","impls","pop","prototype","client_logToBuffer","logToBuffer"],"sources":["logger.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {inBrowser, patterns} from '@webex/common';\nimport {WebexHttpError, 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 }\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 WebexHttpError) {\n return item.toString();\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.shift();\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;AACA;AALA;AACA;AACA;;AAMA,IAAMA,UAAU,GAAG;EACjBC,MAA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AAI,GAAGuB,KAAK,CAACC,GAAG,EAAE;IACpB;EACF;;EAEA;EACAxE,MAAM,CAACyE,SAAS,kBAAW7F,KAAK,EAAG,GAAGmE,gBAAgB,CAACnE,KAAK,EAAEoE,IAAI,EAAElE,SAAS,CAACE,MAAM,CAAC;EACrFgB,MAAM,CAACyE,SAAS,CAAC7F,KAAK,CAAC,GAAGmE,gBAAgB,CAACnE,KAAK,EAAEoE,IAAI,EAAElE,SAAS,CAACC,GAAG,CAAC;AACxE,CAAC,CAAC;AAEFiB,MAAM,CAACyE,SAAS,CAACC,kBAAkB,GAAG3B,gBAAgB,CACpDrE,MAAM,CAACH,IAAI,EACXG,MAAM,CAACH,IAAI,EACXO,SAAS,CAACE,MAAM,EAChB,IAAI,EACJ,IAAI,CACL;AACDgB,MAAM,CAACyE,SAAS,CAACE,WAAW,GAAG5B,gBAAgB,CAC7CrE,MAAM,CAACH,IAAI,EACXG,MAAM,CAACH,IAAI,EACXO,SAAS,CAACC,GAAG,EACb,IAAI,EACJ,IAAI,CACL;AAAC,gBAEaiB,MAAM;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/plugin-logger",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.91",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"sinon": "^9.2.4"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@webex/common": "3.0.0-beta.
|
|
27
|
-
"@webex/plugin-logger": "3.0.0-beta.
|
|
28
|
-
"@webex/test-helper-chai": "3.0.0-beta.
|
|
29
|
-
"@webex/test-helper-mocha": "3.0.0-beta.
|
|
30
|
-
"@webex/test-helper-mock-webex": "3.0.0-beta.
|
|
31
|
-
"@webex/webex-core": "3.0.0-beta.
|
|
26
|
+
"@webex/common": "3.0.0-beta.91",
|
|
27
|
+
"@webex/plugin-logger": "3.0.0-beta.91",
|
|
28
|
+
"@webex/test-helper-chai": "3.0.0-beta.91",
|
|
29
|
+
"@webex/test-helper-mocha": "3.0.0-beta.91",
|
|
30
|
+
"@webex/test-helper-mock-webex": "3.0.0-beta.91",
|
|
31
|
+
"@webex/webex-core": "3.0.0-beta.91",
|
|
32
32
|
"lodash": "^4.17.21"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/config.js
CHANGED
package/src/index.js
CHANGED
package/src/logger.js
CHANGED
|
@@ -3,17 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import {inBrowser, patterns} from '@webex/common';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
WebexPlugin
|
|
9
|
-
} from '@webex/webex-core';
|
|
10
|
-
import {
|
|
11
|
-
cloneDeep,
|
|
12
|
-
has,
|
|
13
|
-
isArray,
|
|
14
|
-
isObject,
|
|
15
|
-
isString
|
|
16
|
-
} from 'lodash';
|
|
6
|
+
import {WebexHttpError, WebexPlugin} from '@webex/webex-core';
|
|
7
|
+
import {cloneDeep, has, isArray, isObject, isString} from 'lodash';
|
|
17
8
|
|
|
18
9
|
const precedence = {
|
|
19
10
|
silent: 0,
|
|
@@ -24,7 +15,7 @@ const precedence = {
|
|
|
24
15
|
log: 5,
|
|
25
16
|
info: 6,
|
|
26
17
|
debug: 7,
|
|
27
|
-
trace: 8
|
|
18
|
+
trace: 8,
|
|
28
19
|
};
|
|
29
20
|
|
|
30
21
|
export const levels = Object.keys(precedence).filter((level) => level !== 'silent');
|
|
@@ -34,12 +25,12 @@ const fallbacks = {
|
|
|
34
25
|
warn: ['error', 'log'],
|
|
35
26
|
info: ['log'],
|
|
36
27
|
debug: ['info', 'log'],
|
|
37
|
-
trace: ['debug', 'info', 'log']
|
|
28
|
+
trace: ['debug', 'info', 'log'],
|
|
38
29
|
};
|
|
39
30
|
|
|
40
31
|
const LOG_TYPES = {
|
|
41
32
|
SDK: 'sdk',
|
|
42
|
-
CLIENT: 'client'
|
|
33
|
+
CLIENT: 'client',
|
|
43
34
|
};
|
|
44
35
|
|
|
45
36
|
const SDK_LOG_TYPE_NAME = 'wx-js-sdk';
|
|
@@ -77,8 +68,7 @@ function walkAndFilter(object, visited = []) {
|
|
|
77
68
|
for (const [key, value] of Object.entries(object)) {
|
|
78
69
|
if (authTokenKeyPattern.test(key)) {
|
|
79
70
|
Reflect.deleteProperty(object, key);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
71
|
+
} else {
|
|
82
72
|
object[key] = walkAndFilter(value, visited);
|
|
83
73
|
}
|
|
84
74
|
}
|
|
@@ -97,14 +87,14 @@ const Logger = WebexPlugin.extend({
|
|
|
97
87
|
cache: false,
|
|
98
88
|
fn() {
|
|
99
89
|
return this.getCurrentLevel();
|
|
100
|
-
}
|
|
90
|
+
},
|
|
101
91
|
},
|
|
102
92
|
client_level: {
|
|
103
93
|
cache: false,
|
|
104
94
|
fn() {
|
|
105
95
|
return this.getCurrentClientLevel();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
96
|
+
},
|
|
97
|
+
},
|
|
108
98
|
},
|
|
109
99
|
session: {
|
|
110
100
|
// for when configured to use single buffer
|
|
@@ -112,27 +102,27 @@ const Logger = WebexPlugin.extend({
|
|
|
112
102
|
type: 'array',
|
|
113
103
|
default() {
|
|
114
104
|
return [];
|
|
115
|
-
}
|
|
105
|
+
},
|
|
116
106
|
},
|
|
117
107
|
groupLevel: {
|
|
118
108
|
type: 'number',
|
|
119
109
|
default() {
|
|
120
110
|
return 0;
|
|
121
|
-
}
|
|
111
|
+
},
|
|
122
112
|
},
|
|
123
113
|
// for when configured to use separate buffers
|
|
124
114
|
sdkBuffer: {
|
|
125
115
|
type: 'array',
|
|
126
116
|
default() {
|
|
127
117
|
return [];
|
|
128
|
-
}
|
|
118
|
+
},
|
|
129
119
|
},
|
|
130
120
|
clientBuffer: {
|
|
131
121
|
type: 'array',
|
|
132
122
|
default() {
|
|
133
123
|
return [];
|
|
134
|
-
}
|
|
135
|
-
}
|
|
124
|
+
},
|
|
125
|
+
},
|
|
136
126
|
},
|
|
137
127
|
|
|
138
128
|
/**
|
|
@@ -178,7 +168,10 @@ const Logger = WebexPlugin.extend({
|
|
|
178
168
|
* @returns {boolean}
|
|
179
169
|
*/
|
|
180
170
|
shouldPrint(level, type = LOG_TYPES.SDK) {
|
|
181
|
-
return
|
|
171
|
+
return (
|
|
172
|
+
precedence[level] <=
|
|
173
|
+
precedence[type === LOG_TYPES.SDK ? this.getCurrentLevel() : this.getCurrentClientLevel()]
|
|
174
|
+
);
|
|
182
175
|
},
|
|
183
176
|
|
|
184
177
|
/**
|
|
@@ -194,7 +187,10 @@ const Logger = WebexPlugin.extend({
|
|
|
194
187
|
* @returns {boolean}
|
|
195
188
|
*/
|
|
196
189
|
shouldBuffer(level) {
|
|
197
|
-
return
|
|
190
|
+
return (
|
|
191
|
+
precedence[level] <=
|
|
192
|
+
(this.config.bufferLogLevel ? precedence[this.config.bufferLogLevel] : precedence.info)
|
|
193
|
+
);
|
|
198
194
|
},
|
|
199
195
|
|
|
200
196
|
/**
|
|
@@ -223,7 +219,8 @@ const Logger = WebexPlugin.extend({
|
|
|
223
219
|
}
|
|
224
220
|
|
|
225
221
|
// Use server-side-feature toggles to configure log levels
|
|
226
|
-
const level =
|
|
222
|
+
const level =
|
|
223
|
+
this.webex.internal.device && this.webex.internal.device.features.developer.get('log-level');
|
|
227
224
|
|
|
228
225
|
if (level) {
|
|
229
226
|
if (levels.includes(level)) {
|
|
@@ -275,11 +272,14 @@ const Logger = WebexPlugin.extend({
|
|
|
275
272
|
// merge the client and sdk buffers
|
|
276
273
|
// while we have entries in either buffer
|
|
277
274
|
while (clientIndex < this.clientBuffer.length || sdkIndex < this.sdkBuffer.length) {
|
|
278
|
-
|
|
279
|
-
if (
|
|
275
|
+
// if we have remaining entries in the SDK buffer
|
|
276
|
+
if (
|
|
277
|
+
sdkIndex < this.sdkBuffer.length &&
|
|
280
278
|
// and we haven't exhausted all the client buffer entries, or SDK date is before client date
|
|
281
279
|
(clientIndex >= this.clientBuffer.length ||
|
|
282
|
-
|
|
280
|
+
new Date(getDate(this.sdkBuffer[sdkIndex])) <=
|
|
281
|
+
new Date(getDate(this.clientBuffer[clientIndex])))
|
|
282
|
+
) {
|
|
283
283
|
// then add to the SDK buffer
|
|
284
284
|
buffer.push(this.sdkBuffer[sdkIndex]);
|
|
285
285
|
sdkIndex += 1;
|
|
@@ -291,13 +291,12 @@ const Logger = WebexPlugin.extend({
|
|
|
291
291
|
clientIndex += 1;
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
294
|
+
} else {
|
|
296
295
|
buffer = this.buffer;
|
|
297
296
|
}
|
|
298
297
|
|
|
299
298
|
return buffer.join('\n');
|
|
300
|
-
}
|
|
299
|
+
},
|
|
301
300
|
});
|
|
302
301
|
|
|
303
302
|
/**
|
|
@@ -323,16 +322,18 @@ function makeLoggerMethod(level, impl, type, neverPrint = false, alwaysBuffer =
|
|
|
323
322
|
// in Ampersand, even if the initialize method is used to set this up. so we keep the type to achieve
|
|
324
323
|
// a sort of late binding to allow retrieving a name from config.
|
|
325
324
|
const logType = type;
|
|
326
|
-
const clientName =
|
|
325
|
+
const clientName =
|
|
326
|
+
logType === LOG_TYPES.SDK ? SDK_LOG_TYPE_NAME : this.config.clientName || logType;
|
|
327
327
|
|
|
328
328
|
let buffer;
|
|
329
329
|
let historyLength;
|
|
330
330
|
|
|
331
331
|
if (this.config.separateLogBuffers) {
|
|
332
|
-
historyLength = this.config.clientHistoryLength
|
|
332
|
+
historyLength = this.config.clientHistoryLength
|
|
333
|
+
? this.config.clientHistoryLength
|
|
334
|
+
: this.config.historyLength;
|
|
333
335
|
buffer = logType === LOG_TYPES.SDK ? this.sdkBuffer : this.clientBuffer;
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
+
} else {
|
|
336
337
|
buffer = this.buffer;
|
|
337
338
|
historyLength = this.config.historyLength;
|
|
338
339
|
}
|
|
@@ -381,8 +382,7 @@ function makeLoggerMethod(level, impl, type, neverPrint = false, alwaysBuffer =
|
|
|
381
382
|
if (level === 'group') this.groupLevel += 1;
|
|
382
383
|
if (level === 'groupEnd' && this.groupLevel > 0) this.groupLevel -= 1;
|
|
383
384
|
}
|
|
384
|
-
}
|
|
385
|
-
catch (reason) {
|
|
385
|
+
} catch (reason) {
|
|
386
386
|
if (!neverPrint) {
|
|
387
387
|
/* istanbul ignore next */
|
|
388
388
|
// eslint-disable-next-line no-console
|
|
@@ -404,14 +404,24 @@ levels.forEach((level) => {
|
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
-
|
|
408
407
|
// eslint-disable-next-line complexity
|
|
409
408
|
Logger.prototype[`client_${level}`] = makeLoggerMethod(level, impl, LOG_TYPES.CLIENT);
|
|
410
409
|
Logger.prototype[level] = makeLoggerMethod(level, impl, LOG_TYPES.SDK);
|
|
411
410
|
});
|
|
412
411
|
|
|
413
|
-
Logger.prototype.client_logToBuffer =
|
|
414
|
-
|
|
415
|
-
|
|
412
|
+
Logger.prototype.client_logToBuffer = makeLoggerMethod(
|
|
413
|
+
levels.info,
|
|
414
|
+
levels.info,
|
|
415
|
+
LOG_TYPES.CLIENT,
|
|
416
|
+
true,
|
|
417
|
+
true
|
|
418
|
+
);
|
|
419
|
+
Logger.prototype.logToBuffer = makeLoggerMethod(
|
|
420
|
+
levels.info,
|
|
421
|
+
levels.info,
|
|
422
|
+
LOG_TYPES.SDK,
|
|
423
|
+
true,
|
|
424
|
+
true
|
|
425
|
+
);
|
|
416
426
|
|
|
417
427
|
export default Logger;
|
package/test/unit/spec/logger.js
CHANGED
|
@@ -45,8 +45,8 @@ describe('plugin-logger', () => {
|
|
|
45
45
|
beforeEach(() => {
|
|
46
46
|
webex = new MockWebex({
|
|
47
47
|
children: {
|
|
48
|
-
logger: Logger
|
|
49
|
-
}
|
|
48
|
+
logger: Logger,
|
|
49
|
+
},
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
52
|
|
|
@@ -55,7 +55,7 @@ describe('plugin-logger', () => {
|
|
|
55
55
|
warn: ['error', 'log'],
|
|
56
56
|
info: ['log'],
|
|
57
57
|
debug: ['info', 'log'],
|
|
58
|
-
trace: ['debug', 'info', 'log']
|
|
58
|
+
trace: ['debug', 'info', 'log'],
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
function impl(level) {
|
|
@@ -154,12 +154,12 @@ describe('plugin-logger', () => {
|
|
|
154
154
|
const error = new WebexHttpError({
|
|
155
155
|
statusCode: 500,
|
|
156
156
|
body: {
|
|
157
|
-
error: 'Internal Error'
|
|
157
|
+
error: 'Internal Error',
|
|
158
158
|
},
|
|
159
159
|
options: {
|
|
160
160
|
service: '',
|
|
161
|
-
headers: {}
|
|
162
|
-
}
|
|
161
|
+
headers: {},
|
|
162
|
+
},
|
|
163
163
|
});
|
|
164
164
|
|
|
165
165
|
webex.logger.log(error);
|
|
@@ -172,12 +172,12 @@ describe('plugin-logger', () => {
|
|
|
172
172
|
const error = new WebexHttpError({
|
|
173
173
|
statusCode: 500,
|
|
174
174
|
body: {
|
|
175
|
-
error: 'Internal Error'
|
|
175
|
+
error: 'Internal Error',
|
|
176
176
|
},
|
|
177
177
|
options: {
|
|
178
178
|
service: '',
|
|
179
|
-
headers: {}
|
|
180
|
-
}
|
|
179
|
+
headers: {},
|
|
180
|
+
},
|
|
181
181
|
});
|
|
182
182
|
|
|
183
183
|
webex.logger.log(error);
|
|
@@ -196,60 +196,186 @@ describe('plugin-logger', () => {
|
|
|
196
196
|
function testLevels(logType, logConfigSetting) {
|
|
197
197
|
/* eslint max-statements: [0] */
|
|
198
198
|
webex.logger.config[logConfigSetting] = 'trace';
|
|
199
|
-
assert.isTrue(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
assert.isTrue(
|
|
204
|
-
|
|
199
|
+
assert.isTrue(
|
|
200
|
+
webex.logger.shouldPrint('error', logType),
|
|
201
|
+
'it prints `error` logs when the level is `trace`'
|
|
202
|
+
);
|
|
203
|
+
assert.isTrue(
|
|
204
|
+
webex.logger.shouldPrint('warn', logType),
|
|
205
|
+
'it prints `warn` logs when the level is `trace`'
|
|
206
|
+
);
|
|
207
|
+
assert.isTrue(
|
|
208
|
+
webex.logger.shouldPrint('log', logType),
|
|
209
|
+
'it prints `log` logs when the level is `trace`'
|
|
210
|
+
);
|
|
211
|
+
assert.isTrue(
|
|
212
|
+
webex.logger.shouldPrint('info', logType),
|
|
213
|
+
'it prints `info` logs when the level is `trace`'
|
|
214
|
+
);
|
|
215
|
+
assert.isTrue(
|
|
216
|
+
webex.logger.shouldPrint('debug', logType),
|
|
217
|
+
'it prints `debug` logs when the level is `trace`'
|
|
218
|
+
);
|
|
219
|
+
assert.isTrue(
|
|
220
|
+
webex.logger.shouldPrint('trace', logType),
|
|
221
|
+
'it prints `trace` logs when the level is `trace`'
|
|
222
|
+
);
|
|
205
223
|
|
|
206
224
|
webex.logger.config[logConfigSetting] = 'debug';
|
|
207
|
-
assert.isTrue(
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
assert.isTrue(
|
|
212
|
-
|
|
225
|
+
assert.isTrue(
|
|
226
|
+
webex.logger.shouldPrint('error', logType),
|
|
227
|
+
'it prints `error` logs when the level is `debug`'
|
|
228
|
+
);
|
|
229
|
+
assert.isTrue(
|
|
230
|
+
webex.logger.shouldPrint('warn', logType),
|
|
231
|
+
'it prints `warn` logs when the level is `debug`'
|
|
232
|
+
);
|
|
233
|
+
assert.isTrue(
|
|
234
|
+
webex.logger.shouldPrint('log', logType),
|
|
235
|
+
'it prints `log` logs when the level is `debug`'
|
|
236
|
+
);
|
|
237
|
+
assert.isTrue(
|
|
238
|
+
webex.logger.shouldPrint('info', logType),
|
|
239
|
+
'it prints `info` logs when the level is `debug`'
|
|
240
|
+
);
|
|
241
|
+
assert.isTrue(
|
|
242
|
+
webex.logger.shouldPrint('debug', logType),
|
|
243
|
+
'it prints `debug` logs when the level is `debug`'
|
|
244
|
+
);
|
|
245
|
+
assert.isFalse(
|
|
246
|
+
webex.logger.shouldPrint('trace', logType),
|
|
247
|
+
'it does not print `trace` logs when the level is `debug`'
|
|
248
|
+
);
|
|
213
249
|
|
|
214
250
|
webex.logger.config[logConfigSetting] = 'info';
|
|
215
|
-
assert.isTrue(
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
assert.
|
|
220
|
-
|
|
251
|
+
assert.isTrue(
|
|
252
|
+
webex.logger.shouldPrint('error', logType),
|
|
253
|
+
'it prints `error` logs when the level is `info`'
|
|
254
|
+
);
|
|
255
|
+
assert.isTrue(
|
|
256
|
+
webex.logger.shouldPrint('warn', logType),
|
|
257
|
+
'it prints `warn` logs when the level is `info`'
|
|
258
|
+
);
|
|
259
|
+
assert.isTrue(
|
|
260
|
+
webex.logger.shouldPrint('log', logType),
|
|
261
|
+
'it prints `log` logs when the level is `info`'
|
|
262
|
+
);
|
|
263
|
+
assert.isTrue(
|
|
264
|
+
webex.logger.shouldPrint('info', logType),
|
|
265
|
+
'it prints `info` logs when the level is `info`'
|
|
266
|
+
);
|
|
267
|
+
assert.isFalse(
|
|
268
|
+
webex.logger.shouldPrint('debug', logType),
|
|
269
|
+
'it does not print `debug` logs when the level is `info`'
|
|
270
|
+
);
|
|
271
|
+
assert.isFalse(
|
|
272
|
+
webex.logger.shouldPrint('trace', logType),
|
|
273
|
+
'it does not print `trace` logs when the level is `info`'
|
|
274
|
+
);
|
|
221
275
|
|
|
222
276
|
webex.logger.config[logConfigSetting] = 'log';
|
|
223
|
-
assert.isTrue(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
assert.
|
|
228
|
-
|
|
277
|
+
assert.isTrue(
|
|
278
|
+
webex.logger.shouldPrint('error', logType),
|
|
279
|
+
'it prints `error` logs when the level is `log`'
|
|
280
|
+
);
|
|
281
|
+
assert.isTrue(
|
|
282
|
+
webex.logger.shouldPrint('warn', logType),
|
|
283
|
+
'it prints `warn` logs when the level is `log`'
|
|
284
|
+
);
|
|
285
|
+
assert.isTrue(
|
|
286
|
+
webex.logger.shouldPrint('log', logType),
|
|
287
|
+
'it prints `log` logs when the level is `log`'
|
|
288
|
+
);
|
|
289
|
+
assert.isFalse(
|
|
290
|
+
webex.logger.shouldPrint('info', logType),
|
|
291
|
+
'it does not print `info` logs when the level is `log`'
|
|
292
|
+
);
|
|
293
|
+
assert.isFalse(
|
|
294
|
+
webex.logger.shouldPrint('debug', logType),
|
|
295
|
+
'it does not print `debug` logs when the level is `log`'
|
|
296
|
+
);
|
|
297
|
+
assert.isFalse(
|
|
298
|
+
webex.logger.shouldPrint('trace', logType),
|
|
299
|
+
'it does not print `trace` logs when the level is `log`'
|
|
300
|
+
);
|
|
229
301
|
|
|
230
302
|
webex.logger.config[logConfigSetting] = 'warn';
|
|
231
|
-
assert.isTrue(
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
assert.
|
|
236
|
-
|
|
303
|
+
assert.isTrue(
|
|
304
|
+
webex.logger.shouldPrint('error', logType),
|
|
305
|
+
'it prints `error` logs when the level is `warn`'
|
|
306
|
+
);
|
|
307
|
+
assert.isTrue(
|
|
308
|
+
webex.logger.shouldPrint('warn', logType),
|
|
309
|
+
'it prints `warn` logs when the level is `warn`'
|
|
310
|
+
);
|
|
311
|
+
assert.isFalse(
|
|
312
|
+
webex.logger.shouldPrint('log', logType),
|
|
313
|
+
'it does not print `log` logs when the level is `warn`'
|
|
314
|
+
);
|
|
315
|
+
assert.isFalse(
|
|
316
|
+
webex.logger.shouldPrint('info', logType),
|
|
317
|
+
'it does not print `info` logs when the level is `warn`'
|
|
318
|
+
);
|
|
319
|
+
assert.isFalse(
|
|
320
|
+
webex.logger.shouldPrint('debug', logType),
|
|
321
|
+
'it does not print `debug` logs when the level is `warn`'
|
|
322
|
+
);
|
|
323
|
+
assert.isFalse(
|
|
324
|
+
webex.logger.shouldPrint('trace', logType),
|
|
325
|
+
'it does not print `trace` logs when the level is `warn`'
|
|
326
|
+
);
|
|
237
327
|
|
|
238
328
|
webex.logger.config[logConfigSetting] = 'error';
|
|
239
|
-
assert.isTrue(
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
assert.isFalse(
|
|
244
|
-
|
|
329
|
+
assert.isTrue(
|
|
330
|
+
webex.logger.shouldPrint('error', logType),
|
|
331
|
+
'it prints `error` logs when the level is `error`'
|
|
332
|
+
);
|
|
333
|
+
assert.isFalse(
|
|
334
|
+
webex.logger.shouldPrint('warn', logType),
|
|
335
|
+
'it does not print `warn` logs when the level `error` is '
|
|
336
|
+
);
|
|
337
|
+
assert.isFalse(
|
|
338
|
+
webex.logger.shouldPrint('log', logType),
|
|
339
|
+
'it does not print `log` logs when the level is `error`'
|
|
340
|
+
);
|
|
341
|
+
assert.isFalse(
|
|
342
|
+
webex.logger.shouldPrint('info', logType),
|
|
343
|
+
'it does not print `info` logs when the level is `error`'
|
|
344
|
+
);
|
|
345
|
+
assert.isFalse(
|
|
346
|
+
webex.logger.shouldPrint('debug', logType),
|
|
347
|
+
'it does not print `debug` logs when the level is `error`'
|
|
348
|
+
);
|
|
349
|
+
assert.isFalse(
|
|
350
|
+
webex.logger.shouldPrint('trace', logType),
|
|
351
|
+
'it does not print `trace` logs when the level is `error`'
|
|
352
|
+
);
|
|
245
353
|
|
|
246
354
|
webex.logger.config[logConfigSetting] = 'silent';
|
|
247
|
-
assert.isFalse(
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
assert.isFalse(
|
|
252
|
-
|
|
355
|
+
assert.isFalse(
|
|
356
|
+
webex.logger.shouldPrint('error', logType),
|
|
357
|
+
'it does not print `error` logs when the level is `silent`'
|
|
358
|
+
);
|
|
359
|
+
assert.isFalse(
|
|
360
|
+
webex.logger.shouldPrint('warn', logType),
|
|
361
|
+
'it does not print `warn` logs when the level is `silent`'
|
|
362
|
+
);
|
|
363
|
+
assert.isFalse(
|
|
364
|
+
webex.logger.shouldPrint('log', logType),
|
|
365
|
+
'it does not print `log` logs when the level is `silent`'
|
|
366
|
+
);
|
|
367
|
+
assert.isFalse(
|
|
368
|
+
webex.logger.shouldPrint('info', logType),
|
|
369
|
+
'it does not print `info` logs when the level is `silent`'
|
|
370
|
+
);
|
|
371
|
+
assert.isFalse(
|
|
372
|
+
webex.logger.shouldPrint('debug', logType),
|
|
373
|
+
'it does not print `debug` logs when the level is `silent`'
|
|
374
|
+
);
|
|
375
|
+
assert.isFalse(
|
|
376
|
+
webex.logger.shouldPrint('trace', logType),
|
|
377
|
+
'it does not print `trace` logs when the level is `silent`'
|
|
378
|
+
);
|
|
253
379
|
}
|
|
254
380
|
|
|
255
381
|
it('indicates whether or not the desired log should be printed at the current log level', () => {
|
|
@@ -310,20 +436,20 @@ describe('plugin-logger', () => {
|
|
|
310
436
|
developer: {
|
|
311
437
|
get() {
|
|
312
438
|
return 'info';
|
|
313
|
-
}
|
|
439
|
+
},
|
|
314
440
|
},
|
|
315
441
|
entitlement: {
|
|
316
442
|
get() {
|
|
317
443
|
return false;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
444
|
+
},
|
|
445
|
+
},
|
|
446
|
+
},
|
|
321
447
|
};
|
|
322
448
|
webex.logger.info('test');
|
|
323
449
|
assert.called(console.info);
|
|
324
450
|
});
|
|
325
451
|
|
|
326
|
-
nodeOnly(it)(
|
|
452
|
+
nodeOnly(it)("doesn't break if the feature toggle is set to an incorrect value", () => {
|
|
327
453
|
assert.doesNotThrow(() => {
|
|
328
454
|
assert.notCalled(console.info);
|
|
329
455
|
webex.logger.info('test');
|
|
@@ -334,14 +460,14 @@ describe('plugin-logger', () => {
|
|
|
334
460
|
developer: {
|
|
335
461
|
get() {
|
|
336
462
|
return 'not-a-log-method';
|
|
337
|
-
}
|
|
463
|
+
},
|
|
338
464
|
},
|
|
339
465
|
entitlement: {
|
|
340
466
|
get() {
|
|
341
467
|
return false;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
},
|
|
345
471
|
};
|
|
346
472
|
webex.logger.info('test');
|
|
347
473
|
assert.notCalled(console.info);
|
|
@@ -378,29 +504,30 @@ describe('plugin-logger', () => {
|
|
|
378
504
|
});
|
|
379
505
|
});
|
|
380
506
|
|
|
381
|
-
|
|
382
507
|
describe('#filter', () => {
|
|
383
508
|
it('redacts email addresses', () => {
|
|
384
509
|
const message = {
|
|
385
|
-
blarg: 'test@example.com'
|
|
510
|
+
blarg: 'test@example.com',
|
|
386
511
|
};
|
|
387
512
|
|
|
388
|
-
assert.deepEqual(webex.logger.filter(message), [
|
|
389
|
-
|
|
390
|
-
|
|
513
|
+
assert.deepEqual(webex.logger.filter(message), [
|
|
514
|
+
{
|
|
515
|
+
blarg: '[REDACTED]',
|
|
516
|
+
},
|
|
517
|
+
]);
|
|
391
518
|
});
|
|
392
519
|
|
|
393
520
|
it('strips auth headers from log output', () => {
|
|
394
521
|
const msg = {
|
|
395
522
|
headers: {
|
|
396
|
-
authorization: 'Bearer'
|
|
523
|
+
authorization: 'Bearer',
|
|
397
524
|
},
|
|
398
525
|
options: {
|
|
399
526
|
headers: {
|
|
400
527
|
trackingid: '123',
|
|
401
|
-
authorization: 'Bearer'
|
|
402
|
-
}
|
|
403
|
-
}
|
|
528
|
+
authorization: 'Bearer',
|
|
529
|
+
},
|
|
530
|
+
},
|
|
404
531
|
};
|
|
405
532
|
|
|
406
533
|
assert.doesNotThrow(() => {
|
|
@@ -416,23 +543,36 @@ describe('plugin-logger', () => {
|
|
|
416
543
|
const [filtered] = webex.logger.filter(msg);
|
|
417
544
|
|
|
418
545
|
assert.nestedProperty(msg, 'headers.authorization', 'it does not alter the original message');
|
|
419
|
-
assert.nestedProperty(
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
546
|
+
assert.nestedProperty(
|
|
547
|
+
msg,
|
|
548
|
+
'options.headers.authorization',
|
|
549
|
+
'it does not alter the original message'
|
|
550
|
+
);
|
|
551
|
+
|
|
552
|
+
assert.notNestedProperty(
|
|
553
|
+
filtered,
|
|
554
|
+
'headers.authorization',
|
|
555
|
+
'it removes headers.authorization'
|
|
556
|
+
);
|
|
557
|
+
assert.notNestedProperty(
|
|
558
|
+
filtered,
|
|
559
|
+
'options.headers.authorization',
|
|
560
|
+
'it removes options.headers.authorization'
|
|
561
|
+
);
|
|
562
|
+
assert.nestedProperty(
|
|
563
|
+
msg,
|
|
564
|
+
'options.headers.trackingid',
|
|
565
|
+
'it does not remove other header values'
|
|
566
|
+
);
|
|
567
|
+
assert.nestedProperty(
|
|
568
|
+
filtered,
|
|
569
|
+
'options.headers.trackingid',
|
|
570
|
+
'it does not remove other header values'
|
|
571
|
+
);
|
|
425
572
|
});
|
|
426
573
|
});
|
|
427
574
|
|
|
428
|
-
[
|
|
429
|
-
'error',
|
|
430
|
-
'warn',
|
|
431
|
-
'log',
|
|
432
|
-
'info',
|
|
433
|
-
'debug',
|
|
434
|
-
'trace'
|
|
435
|
-
].forEach((level) => {
|
|
575
|
+
['error', 'warn', 'log', 'info', 'debug', 'trace'].forEach((level) => {
|
|
436
576
|
describe(`#${level}()`, () => {
|
|
437
577
|
it(`proxies console.${level}`, () => {
|
|
438
578
|
webex.logger.config.level = level;
|
|
@@ -446,13 +586,13 @@ describe('plugin-logger', () => {
|
|
|
446
586
|
webex.logger[level]({
|
|
447
587
|
headers: {
|
|
448
588
|
authorization: 'Bearer',
|
|
449
|
-
trackingid: '123'
|
|
450
|
-
}
|
|
589
|
+
trackingid: '123',
|
|
590
|
+
},
|
|
451
591
|
});
|
|
452
592
|
assert.calledWith(console[impl(level)], 'wx-js-sdk', {
|
|
453
593
|
headers: {
|
|
454
|
-
trackingid: '123'
|
|
455
|
-
}
|
|
594
|
+
trackingid: '123',
|
|
595
|
+
},
|
|
456
596
|
});
|
|
457
597
|
});
|
|
458
598
|
});
|
|
@@ -463,7 +603,7 @@ describe('plugin-logger', () => {
|
|
|
463
603
|
webex.config.logger.level = 'trace';
|
|
464
604
|
webex.logger.log({
|
|
465
605
|
Authorization: 'XXXXXXX',
|
|
466
|
-
Key: 'myKey'
|
|
606
|
+
Key: 'myKey',
|
|
467
607
|
});
|
|
468
608
|
|
|
469
609
|
// Assert auth was filtered
|
|
@@ -471,7 +611,7 @@ describe('plugin-logger', () => {
|
|
|
471
611
|
|
|
472
612
|
webex.logger.log({
|
|
473
613
|
authorization: 'XXXXXXX',
|
|
474
|
-
Key: 'myKey'
|
|
614
|
+
Key: 'myKey',
|
|
475
615
|
});
|
|
476
616
|
|
|
477
617
|
assert.calledWith(console.log, 'wx-js-sdk', {Key: 'myKey'});
|
|
@@ -493,7 +633,7 @@ describe('plugin-logger', () => {
|
|
|
493
633
|
const object = {
|
|
494
634
|
authorization: 'XXXXXXX',
|
|
495
635
|
string: 'test@cisco.com',
|
|
496
|
-
Key: 'myKey'
|
|
636
|
+
Key: 'myKey',
|
|
497
637
|
};
|
|
498
638
|
|
|
499
639
|
// Add a circular reference to the object
|
|
@@ -503,7 +643,7 @@ describe('plugin-logger', () => {
|
|
|
503
643
|
|
|
504
644
|
const expected = {
|
|
505
645
|
string: '[REDACTED]',
|
|
506
|
-
Key: 'myKey'
|
|
646
|
+
Key: 'myKey',
|
|
507
647
|
};
|
|
508
648
|
|
|
509
649
|
expected.selfReference = expected;
|
|
@@ -530,8 +670,8 @@ describe('plugin-logger', () => {
|
|
|
530
670
|
otherPrimativeNum: 6,
|
|
531
671
|
subPrimativeBool: true,
|
|
532
672
|
otherPrimativeBool: false,
|
|
533
|
-
subPrimativeSymbol: sym
|
|
534
|
-
}
|
|
673
|
+
subPrimativeSymbol: sym,
|
|
674
|
+
},
|
|
535
675
|
};
|
|
536
676
|
|
|
537
677
|
object.subObject.circularObjectRef = object;
|
|
@@ -555,8 +695,8 @@ describe('plugin-logger', () => {
|
|
|
555
695
|
otherPrimativeBool: false,
|
|
556
696
|
subPrimativeSymbol: sym,
|
|
557
697
|
circularObjectRef: object,
|
|
558
|
-
circularFunctionRef: func
|
|
559
|
-
}
|
|
698
|
+
circularFunctionRef: func,
|
|
699
|
+
},
|
|
560
700
|
});
|
|
561
701
|
});
|
|
562
702
|
});
|
|
@@ -585,7 +725,6 @@ describe('plugin-logger', () => {
|
|
|
585
725
|
}
|
|
586
726
|
}
|
|
587
727
|
|
|
588
|
-
|
|
589
728
|
it('formats mixed log types in order by default', async () => {
|
|
590
729
|
for (let i = 0; i < 10; i += 1) {
|
|
591
730
|
sendRandomLog(i);
|