@ngxs/logger-plugin 3.7.4 → 3.7.5-dev.master-17a1bb8
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/README.md +3 -3
- package/bundles/ngxs-logger-plugin.umd.js +458 -458
- package/bundles/ngxs-logger-plugin.umd.js.map +1 -1
- package/bundles/ngxs-logger-plugin.umd.min.js.map +1 -1
- package/esm2015/index.js +9 -9
- package/esm2015/ngxs-logger-plugin.js +9 -9
- package/esm2015/src/action-logger.js +101 -101
- package/esm2015/src/internals.js +32 -32
- package/esm2015/src/log-writer.js +117 -117
- package/esm2015/src/logger.module.js +58 -58
- package/esm2015/src/logger.plugin.js +82 -82
- package/esm2015/src/public_api.js +8 -8
- package/esm2015/src/symbols.js +34 -34
- package/esm5/index.js +9 -9
- package/esm5/ngxs-logger-plugin.js +9 -9
- package/esm5/src/action-logger.js +121 -121
- package/esm5/src/internals.js +34 -34
- package/esm5/src/log-writer.js +147 -147
- package/esm5/src/logger.module.js +67 -67
- package/esm5/src/logger.plugin.js +86 -86
- package/esm5/src/public_api.js +8 -8
- package/esm5/src/symbols.js +34 -34
- package/fesm2015/ngxs-logger-plugin.js +408 -408
- package/fesm2015/ngxs-logger-plugin.js.map +1 -1
- package/fesm5/ngxs-logger-plugin.js +467 -467
- package/fesm5/ngxs-logger-plugin.js.map +1 -1
- package/index.d.ts +4 -4
- package/ngxs-logger-plugin.d.ts +5 -5
- package/package.json +3 -3
- package/src/action-logger.d.ts +13 -13
- package/src/internals.d.ts +3 -3
- package/src/log-writer.d.ts +13 -13
- package/src/logger.module.d.ts +12 -12
- package/src/logger.plugin.d.ts +11 -11
- package/src/public_api.d.ts +3 -3
- package/src/symbols.d.ts +12 -12
|
@@ -223,474 +223,474 @@
|
|
|
223
223
|
return value;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
/**
|
|
227
|
-
* @fileoverview added by tsickle
|
|
228
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
229
|
-
*/
|
|
230
|
-
/** @type {?} */
|
|
231
|
-
var repeat = (/**
|
|
232
|
-
* @param {?} str
|
|
233
|
-
* @param {?} times
|
|
234
|
-
* @return {?}
|
|
235
|
-
*/
|
|
236
|
-
function (str, times) { return new Array(times + 1).join(str); });
|
|
237
|
-
/** @type {?} */
|
|
238
|
-
var pad = (/**
|
|
239
|
-
* @param {?} num
|
|
240
|
-
* @param {?} maxLength
|
|
241
|
-
* @return {?}
|
|
242
|
-
*/
|
|
243
|
-
function (num, maxLength) {
|
|
244
|
-
return repeat('0', maxLength - num.toString().length) + num;
|
|
245
|
-
});
|
|
246
|
-
/**
|
|
247
|
-
* @param {?} time
|
|
248
|
-
* @return {?}
|
|
249
|
-
*/
|
|
250
|
-
function formatTime(time) {
|
|
251
|
-
return (pad(time.getHours(), 2) +
|
|
252
|
-
":" +
|
|
253
|
-
pad(time.getMinutes(), 2) +
|
|
254
|
-
":" +
|
|
255
|
-
pad(time.getSeconds(), 2) +
|
|
256
|
-
"." +
|
|
257
|
-
pad(time.getMilliseconds(), 3));
|
|
226
|
+
/**
|
|
227
|
+
* @fileoverview added by tsickle
|
|
228
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
229
|
+
*/
|
|
230
|
+
/** @type {?} */
|
|
231
|
+
var repeat = (/**
|
|
232
|
+
* @param {?} str
|
|
233
|
+
* @param {?} times
|
|
234
|
+
* @return {?}
|
|
235
|
+
*/
|
|
236
|
+
function (str, times) { return new Array(times + 1).join(str); });
|
|
237
|
+
/** @type {?} */
|
|
238
|
+
var pad = (/**
|
|
239
|
+
* @param {?} num
|
|
240
|
+
* @param {?} maxLength
|
|
241
|
+
* @return {?}
|
|
242
|
+
*/
|
|
243
|
+
function (num, maxLength) {
|
|
244
|
+
return repeat('0', maxLength - num.toString().length) + num;
|
|
245
|
+
});
|
|
246
|
+
/**
|
|
247
|
+
* @param {?} time
|
|
248
|
+
* @return {?}
|
|
249
|
+
*/
|
|
250
|
+
function formatTime(time) {
|
|
251
|
+
return (pad(time.getHours(), 2) +
|
|
252
|
+
":" +
|
|
253
|
+
pad(time.getMinutes(), 2) +
|
|
254
|
+
":" +
|
|
255
|
+
pad(time.getSeconds(), 2) +
|
|
256
|
+
"." +
|
|
257
|
+
pad(time.getMilliseconds(), 3));
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
/**
|
|
261
|
-
* @fileoverview added by tsickle
|
|
262
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
263
|
-
*/
|
|
264
|
-
var ActionLogger = /** @class */ (function () {
|
|
265
|
-
function ActionLogger(action, store, logWriter) {
|
|
266
|
-
this.action = action;
|
|
267
|
-
this.store = store;
|
|
268
|
-
this.logWriter = logWriter;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* @param {?} state
|
|
272
|
-
* @return {?}
|
|
273
|
-
*/
|
|
274
|
-
ActionLogger.prototype.dispatched = /**
|
|
275
|
-
* @param {?} state
|
|
276
|
-
* @return {?}
|
|
277
|
-
*/
|
|
278
|
-
function (state) {
|
|
279
|
-
/** @type {?} */
|
|
280
|
-
var actionName = store.getActionTypeFromInstance(this.action);
|
|
281
|
-
/** @type {?} */
|
|
282
|
-
var formattedTime = formatTime(new Date());
|
|
283
|
-
/** @type {?} */
|
|
284
|
-
var message = "action " + actionName + " @ " + formattedTime;
|
|
285
|
-
this.logWriter.startGroup(message);
|
|
286
|
-
// print payload only if at least one property is supplied
|
|
287
|
-
if (this._hasPayload(this.action)) {
|
|
288
|
-
this.logWriter.logGrey('payload', __assign({}, this.action));
|
|
289
|
-
}
|
|
290
|
-
this.logWriter.logGrey('prev state', state);
|
|
291
|
-
};
|
|
292
|
-
/**
|
|
293
|
-
* @param {?} nextState
|
|
294
|
-
* @return {?}
|
|
295
|
-
*/
|
|
296
|
-
ActionLogger.prototype.completed = /**
|
|
297
|
-
* @param {?} nextState
|
|
298
|
-
* @return {?}
|
|
299
|
-
*/
|
|
300
|
-
function (nextState) {
|
|
301
|
-
this.logWriter.logGreen('next state', nextState);
|
|
302
|
-
this.logWriter.endGroup();
|
|
303
|
-
};
|
|
304
|
-
/**
|
|
305
|
-
* @param {?} error
|
|
306
|
-
* @return {?}
|
|
307
|
-
*/
|
|
308
|
-
ActionLogger.prototype.errored = /**
|
|
309
|
-
* @param {?} error
|
|
310
|
-
* @return {?}
|
|
311
|
-
*/
|
|
312
|
-
function (error) {
|
|
313
|
-
this.logWriter.logRedish('next state after error', this.store.snapshot());
|
|
314
|
-
this.logWriter.logRedish('error', error);
|
|
315
|
-
this.logWriter.endGroup();
|
|
316
|
-
};
|
|
317
|
-
/**
|
|
318
|
-
* @private
|
|
319
|
-
* @param {?} event
|
|
320
|
-
* @return {?}
|
|
321
|
-
*/
|
|
322
|
-
ActionLogger.prototype._hasPayload = /**
|
|
323
|
-
* @private
|
|
324
|
-
* @param {?} event
|
|
325
|
-
* @return {?}
|
|
326
|
-
*/
|
|
327
|
-
function (event) {
|
|
328
|
-
/** @type {?} */
|
|
329
|
-
var nonEmptyProperties = this._getNonEmptyProperties(event);
|
|
330
|
-
return nonEmptyProperties.length > 0;
|
|
331
|
-
};
|
|
332
|
-
/**
|
|
333
|
-
* @private
|
|
334
|
-
* @param {?} event
|
|
335
|
-
* @return {?}
|
|
336
|
-
*/
|
|
337
|
-
ActionLogger.prototype._getNonEmptyProperties = /**
|
|
338
|
-
* @private
|
|
339
|
-
* @param {?} event
|
|
340
|
-
* @return {?}
|
|
341
|
-
*/
|
|
342
|
-
function (event) {
|
|
343
|
-
/** @type {?} */
|
|
344
|
-
var keys = Object.keys(event);
|
|
345
|
-
/** @type {?} */
|
|
346
|
-
var values = keys.map((/**
|
|
347
|
-
* @param {?} key
|
|
348
|
-
* @return {?}
|
|
349
|
-
*/
|
|
350
|
-
function (key) { return event[key]; }));
|
|
351
|
-
return values.filter((/**
|
|
352
|
-
* @param {?} value
|
|
353
|
-
* @return {?}
|
|
354
|
-
*/
|
|
355
|
-
function (value) { return value !== undefined; }));
|
|
356
|
-
};
|
|
357
|
-
return ActionLogger;
|
|
358
|
-
}());
|
|
359
|
-
if (false) {
|
|
360
|
-
/**
|
|
361
|
-
* @type {?}
|
|
362
|
-
* @private
|
|
363
|
-
*/
|
|
364
|
-
ActionLogger.prototype.action;
|
|
365
|
-
/**
|
|
366
|
-
* @type {?}
|
|
367
|
-
* @private
|
|
368
|
-
*/
|
|
369
|
-
ActionLogger.prototype.store;
|
|
370
|
-
/**
|
|
371
|
-
* @type {?}
|
|
372
|
-
* @private
|
|
373
|
-
*/
|
|
374
|
-
ActionLogger.prototype.logWriter;
|
|
260
|
+
/**
|
|
261
|
+
* @fileoverview added by tsickle
|
|
262
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
263
|
+
*/
|
|
264
|
+
var ActionLogger = /** @class */ (function () {
|
|
265
|
+
function ActionLogger(action, store, logWriter) {
|
|
266
|
+
this.action = action;
|
|
267
|
+
this.store = store;
|
|
268
|
+
this.logWriter = logWriter;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* @param {?} state
|
|
272
|
+
* @return {?}
|
|
273
|
+
*/
|
|
274
|
+
ActionLogger.prototype.dispatched = /**
|
|
275
|
+
* @param {?} state
|
|
276
|
+
* @return {?}
|
|
277
|
+
*/
|
|
278
|
+
function (state) {
|
|
279
|
+
/** @type {?} */
|
|
280
|
+
var actionName = store.getActionTypeFromInstance(this.action);
|
|
281
|
+
/** @type {?} */
|
|
282
|
+
var formattedTime = formatTime(new Date());
|
|
283
|
+
/** @type {?} */
|
|
284
|
+
var message = "action " + actionName + " @ " + formattedTime;
|
|
285
|
+
this.logWriter.startGroup(message);
|
|
286
|
+
// print payload only if at least one property is supplied
|
|
287
|
+
if (this._hasPayload(this.action)) {
|
|
288
|
+
this.logWriter.logGrey('payload', __assign({}, this.action));
|
|
289
|
+
}
|
|
290
|
+
this.logWriter.logGrey('prev state', state);
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* @param {?} nextState
|
|
294
|
+
* @return {?}
|
|
295
|
+
*/
|
|
296
|
+
ActionLogger.prototype.completed = /**
|
|
297
|
+
* @param {?} nextState
|
|
298
|
+
* @return {?}
|
|
299
|
+
*/
|
|
300
|
+
function (nextState) {
|
|
301
|
+
this.logWriter.logGreen('next state', nextState);
|
|
302
|
+
this.logWriter.endGroup();
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* @param {?} error
|
|
306
|
+
* @return {?}
|
|
307
|
+
*/
|
|
308
|
+
ActionLogger.prototype.errored = /**
|
|
309
|
+
* @param {?} error
|
|
310
|
+
* @return {?}
|
|
311
|
+
*/
|
|
312
|
+
function (error) {
|
|
313
|
+
this.logWriter.logRedish('next state after error', this.store.snapshot());
|
|
314
|
+
this.logWriter.logRedish('error', error);
|
|
315
|
+
this.logWriter.endGroup();
|
|
316
|
+
};
|
|
317
|
+
/**
|
|
318
|
+
* @private
|
|
319
|
+
* @param {?} event
|
|
320
|
+
* @return {?}
|
|
321
|
+
*/
|
|
322
|
+
ActionLogger.prototype._hasPayload = /**
|
|
323
|
+
* @private
|
|
324
|
+
* @param {?} event
|
|
325
|
+
* @return {?}
|
|
326
|
+
*/
|
|
327
|
+
function (event) {
|
|
328
|
+
/** @type {?} */
|
|
329
|
+
var nonEmptyProperties = this._getNonEmptyProperties(event);
|
|
330
|
+
return nonEmptyProperties.length > 0;
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* @private
|
|
334
|
+
* @param {?} event
|
|
335
|
+
* @return {?}
|
|
336
|
+
*/
|
|
337
|
+
ActionLogger.prototype._getNonEmptyProperties = /**
|
|
338
|
+
* @private
|
|
339
|
+
* @param {?} event
|
|
340
|
+
* @return {?}
|
|
341
|
+
*/
|
|
342
|
+
function (event) {
|
|
343
|
+
/** @type {?} */
|
|
344
|
+
var keys = Object.keys(event);
|
|
345
|
+
/** @type {?} */
|
|
346
|
+
var values = keys.map((/**
|
|
347
|
+
* @param {?} key
|
|
348
|
+
* @return {?}
|
|
349
|
+
*/
|
|
350
|
+
function (key) { return event[key]; }));
|
|
351
|
+
return values.filter((/**
|
|
352
|
+
* @param {?} value
|
|
353
|
+
* @return {?}
|
|
354
|
+
*/
|
|
355
|
+
function (value) { return value !== undefined; }));
|
|
356
|
+
};
|
|
357
|
+
return ActionLogger;
|
|
358
|
+
}());
|
|
359
|
+
if (false) {
|
|
360
|
+
/**
|
|
361
|
+
* @type {?}
|
|
362
|
+
* @private
|
|
363
|
+
*/
|
|
364
|
+
ActionLogger.prototype.action;
|
|
365
|
+
/**
|
|
366
|
+
* @type {?}
|
|
367
|
+
* @private
|
|
368
|
+
*/
|
|
369
|
+
ActionLogger.prototype.store;
|
|
370
|
+
/**
|
|
371
|
+
* @type {?}
|
|
372
|
+
* @private
|
|
373
|
+
*/
|
|
374
|
+
ActionLogger.prototype.logWriter;
|
|
375
375
|
}
|
|
376
376
|
|
|
377
|
-
/**
|
|
378
|
-
* @fileoverview added by tsickle
|
|
379
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
380
|
-
*/
|
|
381
|
-
var LogWriter = /** @class */ (function () {
|
|
382
|
-
function LogWriter(options) {
|
|
383
|
-
this.options = options;
|
|
384
|
-
this.options = this.options || (/** @type {?} */ ({}));
|
|
385
|
-
this.logger = options.logger || console;
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* @param {?} message
|
|
389
|
-
* @return {?}
|
|
390
|
-
*/
|
|
391
|
-
LogWriter.prototype.startGroup = /**
|
|
392
|
-
* @param {?} message
|
|
393
|
-
* @return {?}
|
|
394
|
-
*/
|
|
395
|
-
function (message) {
|
|
396
|
-
/** @type {?} */
|
|
397
|
-
var startGroupFn = this.options.collapsed
|
|
398
|
-
? this.logger.groupCollapsed
|
|
399
|
-
: this.logger.group;
|
|
400
|
-
try {
|
|
401
|
-
startGroupFn.call(this.logger, message);
|
|
402
|
-
}
|
|
403
|
-
catch (e) {
|
|
404
|
-
console.log(message);
|
|
405
|
-
}
|
|
406
|
-
};
|
|
407
|
-
/**
|
|
408
|
-
* @return {?}
|
|
409
|
-
*/
|
|
410
|
-
LogWriter.prototype.endGroup = /**
|
|
411
|
-
* @return {?}
|
|
412
|
-
*/
|
|
413
|
-
function () {
|
|
414
|
-
try {
|
|
415
|
-
this.logger.groupEnd();
|
|
416
|
-
}
|
|
417
|
-
catch (e) {
|
|
418
|
-
this.logger.log('—— log end ——');
|
|
419
|
-
}
|
|
420
|
-
};
|
|
421
|
-
/**
|
|
422
|
-
* @param {?} title
|
|
423
|
-
* @param {?} payload
|
|
424
|
-
* @return {?}
|
|
425
|
-
*/
|
|
426
|
-
LogWriter.prototype.logGrey = /**
|
|
427
|
-
* @param {?} title
|
|
428
|
-
* @param {?} payload
|
|
429
|
-
* @return {?}
|
|
430
|
-
*/
|
|
431
|
-
function (title, payload) {
|
|
432
|
-
/** @type {?} */
|
|
433
|
-
var greyStyle = 'color: #9E9E9E; font-weight: bold';
|
|
434
|
-
this.log(title, greyStyle, payload);
|
|
435
|
-
};
|
|
436
|
-
/**
|
|
437
|
-
* @param {?} title
|
|
438
|
-
* @param {?} payload
|
|
439
|
-
* @return {?}
|
|
440
|
-
*/
|
|
441
|
-
LogWriter.prototype.logGreen = /**
|
|
442
|
-
* @param {?} title
|
|
443
|
-
* @param {?} payload
|
|
444
|
-
* @return {?}
|
|
445
|
-
*/
|
|
446
|
-
function (title, payload) {
|
|
447
|
-
/** @type {?} */
|
|
448
|
-
var greenStyle = 'color: #4CAF50; font-weight: bold';
|
|
449
|
-
this.log(title, greenStyle, payload);
|
|
450
|
-
};
|
|
451
|
-
/**
|
|
452
|
-
* @param {?} title
|
|
453
|
-
* @param {?} payload
|
|
454
|
-
* @return {?}
|
|
455
|
-
*/
|
|
456
|
-
LogWriter.prototype.logRedish = /**
|
|
457
|
-
* @param {?} title
|
|
458
|
-
* @param {?} payload
|
|
459
|
-
* @return {?}
|
|
460
|
-
*/
|
|
461
|
-
function (title, payload) {
|
|
462
|
-
/** @type {?} */
|
|
463
|
-
var redishStyle = 'color: #FD8182; font-weight: bold';
|
|
464
|
-
this.log(title, redishStyle, payload);
|
|
465
|
-
};
|
|
466
|
-
/**
|
|
467
|
-
* @param {?} title
|
|
468
|
-
* @param {?} color
|
|
469
|
-
* @param {?} payload
|
|
470
|
-
* @return {?}
|
|
471
|
-
*/
|
|
472
|
-
LogWriter.prototype.log = /**
|
|
473
|
-
* @param {?} title
|
|
474
|
-
* @param {?} color
|
|
475
|
-
* @param {?} payload
|
|
476
|
-
* @return {?}
|
|
477
|
-
*/
|
|
478
|
-
function (title, color, payload) {
|
|
479
|
-
if (this.isIE()) {
|
|
480
|
-
this.logger.log(title, payload);
|
|
481
|
-
}
|
|
482
|
-
else {
|
|
483
|
-
this.logger.log('%c ' + title, color, payload);
|
|
484
|
-
}
|
|
485
|
-
};
|
|
486
|
-
/**
|
|
487
|
-
* @return {?}
|
|
488
|
-
*/
|
|
489
|
-
LogWriter.prototype.isIE = /**
|
|
490
|
-
* @return {?}
|
|
491
|
-
*/
|
|
492
|
-
function () {
|
|
493
|
-
/** @type {?} */
|
|
494
|
-
var ua = typeof window !== 'undefined' && window.navigator.userAgent
|
|
495
|
-
? window.navigator.userAgent
|
|
496
|
-
: '';
|
|
497
|
-
/** @type {?} */
|
|
498
|
-
var msIE = false;
|
|
499
|
-
/** @type {?} */
|
|
500
|
-
var oldIE = ua.indexOf('MSIE ');
|
|
501
|
-
/** @type {?} */
|
|
502
|
-
var newIE = ua.indexOf('Trident/');
|
|
503
|
-
if (oldIE > -1 || newIE > -1) {
|
|
504
|
-
msIE = true;
|
|
505
|
-
}
|
|
506
|
-
return msIE;
|
|
507
|
-
};
|
|
508
|
-
return LogWriter;
|
|
509
|
-
}());
|
|
510
|
-
if (false) {
|
|
511
|
-
/**
|
|
512
|
-
* @type {?}
|
|
513
|
-
* @private
|
|
514
|
-
*/
|
|
515
|
-
LogWriter.prototype.logger;
|
|
516
|
-
/**
|
|
517
|
-
* @type {?}
|
|
518
|
-
* @private
|
|
519
|
-
*/
|
|
520
|
-
LogWriter.prototype.options;
|
|
377
|
+
/**
|
|
378
|
+
* @fileoverview added by tsickle
|
|
379
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
380
|
+
*/
|
|
381
|
+
var LogWriter = /** @class */ (function () {
|
|
382
|
+
function LogWriter(options) {
|
|
383
|
+
this.options = options;
|
|
384
|
+
this.options = this.options || (/** @type {?} */ ({}));
|
|
385
|
+
this.logger = options.logger || console;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* @param {?} message
|
|
389
|
+
* @return {?}
|
|
390
|
+
*/
|
|
391
|
+
LogWriter.prototype.startGroup = /**
|
|
392
|
+
* @param {?} message
|
|
393
|
+
* @return {?}
|
|
394
|
+
*/
|
|
395
|
+
function (message) {
|
|
396
|
+
/** @type {?} */
|
|
397
|
+
var startGroupFn = this.options.collapsed
|
|
398
|
+
? this.logger.groupCollapsed
|
|
399
|
+
: this.logger.group;
|
|
400
|
+
try {
|
|
401
|
+
startGroupFn.call(this.logger, message);
|
|
402
|
+
}
|
|
403
|
+
catch (e) {
|
|
404
|
+
console.log(message);
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
/**
|
|
408
|
+
* @return {?}
|
|
409
|
+
*/
|
|
410
|
+
LogWriter.prototype.endGroup = /**
|
|
411
|
+
* @return {?}
|
|
412
|
+
*/
|
|
413
|
+
function () {
|
|
414
|
+
try {
|
|
415
|
+
this.logger.groupEnd();
|
|
416
|
+
}
|
|
417
|
+
catch (e) {
|
|
418
|
+
this.logger.log('—— log end ——');
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
/**
|
|
422
|
+
* @param {?} title
|
|
423
|
+
* @param {?} payload
|
|
424
|
+
* @return {?}
|
|
425
|
+
*/
|
|
426
|
+
LogWriter.prototype.logGrey = /**
|
|
427
|
+
* @param {?} title
|
|
428
|
+
* @param {?} payload
|
|
429
|
+
* @return {?}
|
|
430
|
+
*/
|
|
431
|
+
function (title, payload) {
|
|
432
|
+
/** @type {?} */
|
|
433
|
+
var greyStyle = 'color: #9E9E9E; font-weight: bold';
|
|
434
|
+
this.log(title, greyStyle, payload);
|
|
435
|
+
};
|
|
436
|
+
/**
|
|
437
|
+
* @param {?} title
|
|
438
|
+
* @param {?} payload
|
|
439
|
+
* @return {?}
|
|
440
|
+
*/
|
|
441
|
+
LogWriter.prototype.logGreen = /**
|
|
442
|
+
* @param {?} title
|
|
443
|
+
* @param {?} payload
|
|
444
|
+
* @return {?}
|
|
445
|
+
*/
|
|
446
|
+
function (title, payload) {
|
|
447
|
+
/** @type {?} */
|
|
448
|
+
var greenStyle = 'color: #4CAF50; font-weight: bold';
|
|
449
|
+
this.log(title, greenStyle, payload);
|
|
450
|
+
};
|
|
451
|
+
/**
|
|
452
|
+
* @param {?} title
|
|
453
|
+
* @param {?} payload
|
|
454
|
+
* @return {?}
|
|
455
|
+
*/
|
|
456
|
+
LogWriter.prototype.logRedish = /**
|
|
457
|
+
* @param {?} title
|
|
458
|
+
* @param {?} payload
|
|
459
|
+
* @return {?}
|
|
460
|
+
*/
|
|
461
|
+
function (title, payload) {
|
|
462
|
+
/** @type {?} */
|
|
463
|
+
var redishStyle = 'color: #FD8182; font-weight: bold';
|
|
464
|
+
this.log(title, redishStyle, payload);
|
|
465
|
+
};
|
|
466
|
+
/**
|
|
467
|
+
* @param {?} title
|
|
468
|
+
* @param {?} color
|
|
469
|
+
* @param {?} payload
|
|
470
|
+
* @return {?}
|
|
471
|
+
*/
|
|
472
|
+
LogWriter.prototype.log = /**
|
|
473
|
+
* @param {?} title
|
|
474
|
+
* @param {?} color
|
|
475
|
+
* @param {?} payload
|
|
476
|
+
* @return {?}
|
|
477
|
+
*/
|
|
478
|
+
function (title, color, payload) {
|
|
479
|
+
if (this.isIE()) {
|
|
480
|
+
this.logger.log(title, payload);
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
this.logger.log('%c ' + title, color, payload);
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
/**
|
|
487
|
+
* @return {?}
|
|
488
|
+
*/
|
|
489
|
+
LogWriter.prototype.isIE = /**
|
|
490
|
+
* @return {?}
|
|
491
|
+
*/
|
|
492
|
+
function () {
|
|
493
|
+
/** @type {?} */
|
|
494
|
+
var ua = typeof window !== 'undefined' && window.navigator.userAgent
|
|
495
|
+
? window.navigator.userAgent
|
|
496
|
+
: '';
|
|
497
|
+
/** @type {?} */
|
|
498
|
+
var msIE = false;
|
|
499
|
+
/** @type {?} */
|
|
500
|
+
var oldIE = ua.indexOf('MSIE ');
|
|
501
|
+
/** @type {?} */
|
|
502
|
+
var newIE = ua.indexOf('Trident/');
|
|
503
|
+
if (oldIE > -1 || newIE > -1) {
|
|
504
|
+
msIE = true;
|
|
505
|
+
}
|
|
506
|
+
return msIE;
|
|
507
|
+
};
|
|
508
|
+
return LogWriter;
|
|
509
|
+
}());
|
|
510
|
+
if (false) {
|
|
511
|
+
/**
|
|
512
|
+
* @type {?}
|
|
513
|
+
* @private
|
|
514
|
+
*/
|
|
515
|
+
LogWriter.prototype.logger;
|
|
516
|
+
/**
|
|
517
|
+
* @type {?}
|
|
518
|
+
* @private
|
|
519
|
+
*/
|
|
520
|
+
LogWriter.prototype.options;
|
|
521
521
|
}
|
|
522
522
|
|
|
523
|
-
/**
|
|
524
|
-
* @fileoverview added by tsickle
|
|
525
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
526
|
-
*/
|
|
527
|
-
/**
|
|
528
|
-
* @record
|
|
529
|
-
*/
|
|
530
|
-
function NgxsLoggerPluginOptions() { }
|
|
531
|
-
if (false) {
|
|
532
|
-
/**
|
|
533
|
-
* Auto expand logged actions
|
|
534
|
-
* @type {?|undefined}
|
|
535
|
-
*/
|
|
536
|
-
NgxsLoggerPluginOptions.prototype.collapsed;
|
|
537
|
-
/**
|
|
538
|
-
* Provide alternate console.log implementation
|
|
539
|
-
* @type {?|undefined}
|
|
540
|
-
*/
|
|
541
|
-
NgxsLoggerPluginOptions.prototype.logger;
|
|
542
|
-
/**
|
|
543
|
-
* Disable the logger. Useful for prod mode.
|
|
544
|
-
* @type {?|undefined}
|
|
545
|
-
*/
|
|
546
|
-
NgxsLoggerPluginOptions.prototype.disabled;
|
|
547
|
-
/**
|
|
548
|
-
* Predicate for actions to be the logged. Takes action and state snapshot as parameters
|
|
549
|
-
* @type {?|undefined}
|
|
550
|
-
*/
|
|
551
|
-
NgxsLoggerPluginOptions.prototype.filter;
|
|
552
|
-
}
|
|
553
|
-
/** @type {?} */
|
|
523
|
+
/**
|
|
524
|
+
* @fileoverview added by tsickle
|
|
525
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
526
|
+
*/
|
|
527
|
+
/**
|
|
528
|
+
* @record
|
|
529
|
+
*/
|
|
530
|
+
function NgxsLoggerPluginOptions() { }
|
|
531
|
+
if (false) {
|
|
532
|
+
/**
|
|
533
|
+
* Auto expand logged actions
|
|
534
|
+
* @type {?|undefined}
|
|
535
|
+
*/
|
|
536
|
+
NgxsLoggerPluginOptions.prototype.collapsed;
|
|
537
|
+
/**
|
|
538
|
+
* Provide alternate console.log implementation
|
|
539
|
+
* @type {?|undefined}
|
|
540
|
+
*/
|
|
541
|
+
NgxsLoggerPluginOptions.prototype.logger;
|
|
542
|
+
/**
|
|
543
|
+
* Disable the logger. Useful for prod mode.
|
|
544
|
+
* @type {?|undefined}
|
|
545
|
+
*/
|
|
546
|
+
NgxsLoggerPluginOptions.prototype.disabled;
|
|
547
|
+
/**
|
|
548
|
+
* Predicate for actions to be the logged. Takes action and state snapshot as parameters
|
|
549
|
+
* @type {?|undefined}
|
|
550
|
+
*/
|
|
551
|
+
NgxsLoggerPluginOptions.prototype.filter;
|
|
552
|
+
}
|
|
553
|
+
/** @type {?} */
|
|
554
554
|
var NGXS_LOGGER_PLUGIN_OPTIONS = new core.InjectionToken('NGXS_LOGGER_PLUGIN_OPTIONS');
|
|
555
555
|
|
|
556
|
-
/**
|
|
557
|
-
* @fileoverview added by tsickle
|
|
558
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
559
|
-
*/
|
|
560
|
-
var NgxsLoggerPlugin = /** @class */ (function () {
|
|
561
|
-
function NgxsLoggerPlugin(_options, _injector) {
|
|
562
|
-
this._options = _options;
|
|
563
|
-
this._injector = _injector;
|
|
564
|
-
}
|
|
565
|
-
/**
|
|
566
|
-
* @param {?} state
|
|
567
|
-
* @param {?} event
|
|
568
|
-
* @param {?} next
|
|
569
|
-
* @return {?}
|
|
570
|
-
*/
|
|
571
|
-
NgxsLoggerPlugin.prototype.handle = /**
|
|
572
|
-
* @param {?} state
|
|
573
|
-
* @param {?} event
|
|
574
|
-
* @param {?} next
|
|
575
|
-
* @return {?}
|
|
576
|
-
*/
|
|
577
|
-
function (state, event, next) {
|
|
578
|
-
if (this._options.disabled || !(/** @type {?} */ (this._options.filter))(event, state)) {
|
|
579
|
-
return next(state, event);
|
|
580
|
-
}
|
|
581
|
-
this._logWriter = this._logWriter || new LogWriter(this._options);
|
|
582
|
-
// Retrieve lazily to avoid cyclic dependency exception
|
|
583
|
-
this._store = this._store || this._injector.get(store.Store);
|
|
584
|
-
/** @type {?} */
|
|
585
|
-
var actionLogger = new ActionLogger(event, this._store, this._logWriter);
|
|
586
|
-
actionLogger.dispatched(state);
|
|
587
|
-
return next(state, event).pipe(operators.tap((/**
|
|
588
|
-
* @param {?} nextState
|
|
589
|
-
* @return {?}
|
|
590
|
-
*/
|
|
591
|
-
function (nextState) {
|
|
592
|
-
actionLogger.completed(nextState);
|
|
593
|
-
})), operators.catchError((/**
|
|
594
|
-
* @param {?} error
|
|
595
|
-
* @return {?}
|
|
596
|
-
*/
|
|
597
|
-
function (error) {
|
|
598
|
-
actionLogger.errored(error);
|
|
599
|
-
throw error;
|
|
600
|
-
})));
|
|
601
|
-
};
|
|
602
|
-
NgxsLoggerPlugin.decorators = [
|
|
603
|
-
{ type: core.Injectable }
|
|
604
|
-
];
|
|
605
|
-
/** @nocollapse */
|
|
606
|
-
NgxsLoggerPlugin.ctorParameters = function () { return [
|
|
607
|
-
{ type: undefined, decorators: [{ type: core.Inject, args: [NGXS_LOGGER_PLUGIN_OPTIONS,] }] },
|
|
608
|
-
{ type: core.Injector }
|
|
609
|
-
]; };
|
|
610
|
-
return NgxsLoggerPlugin;
|
|
611
|
-
}());
|
|
612
|
-
if (false) {
|
|
613
|
-
/**
|
|
614
|
-
* @type {?}
|
|
615
|
-
* @private
|
|
616
|
-
*/
|
|
617
|
-
NgxsLoggerPlugin.prototype._store;
|
|
618
|
-
/**
|
|
619
|
-
* @type {?}
|
|
620
|
-
* @private
|
|
621
|
-
*/
|
|
622
|
-
NgxsLoggerPlugin.prototype._logWriter;
|
|
623
|
-
/**
|
|
624
|
-
* @type {?}
|
|
625
|
-
* @private
|
|
626
|
-
*/
|
|
627
|
-
NgxsLoggerPlugin.prototype._options;
|
|
628
|
-
/**
|
|
629
|
-
* @type {?}
|
|
630
|
-
* @private
|
|
631
|
-
*/
|
|
632
|
-
NgxsLoggerPlugin.prototype._injector;
|
|
556
|
+
/**
|
|
557
|
+
* @fileoverview added by tsickle
|
|
558
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
559
|
+
*/
|
|
560
|
+
var NgxsLoggerPlugin = /** @class */ (function () {
|
|
561
|
+
function NgxsLoggerPlugin(_options, _injector) {
|
|
562
|
+
this._options = _options;
|
|
563
|
+
this._injector = _injector;
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* @param {?} state
|
|
567
|
+
* @param {?} event
|
|
568
|
+
* @param {?} next
|
|
569
|
+
* @return {?}
|
|
570
|
+
*/
|
|
571
|
+
NgxsLoggerPlugin.prototype.handle = /**
|
|
572
|
+
* @param {?} state
|
|
573
|
+
* @param {?} event
|
|
574
|
+
* @param {?} next
|
|
575
|
+
* @return {?}
|
|
576
|
+
*/
|
|
577
|
+
function (state, event, next) {
|
|
578
|
+
if (this._options.disabled || !(/** @type {?} */ (this._options.filter))(event, state)) {
|
|
579
|
+
return next(state, event);
|
|
580
|
+
}
|
|
581
|
+
this._logWriter = this._logWriter || new LogWriter(this._options);
|
|
582
|
+
// Retrieve lazily to avoid cyclic dependency exception
|
|
583
|
+
this._store = this._store || this._injector.get(store.Store);
|
|
584
|
+
/** @type {?} */
|
|
585
|
+
var actionLogger = new ActionLogger(event, this._store, this._logWriter);
|
|
586
|
+
actionLogger.dispatched(state);
|
|
587
|
+
return next(state, event).pipe(operators.tap((/**
|
|
588
|
+
* @param {?} nextState
|
|
589
|
+
* @return {?}
|
|
590
|
+
*/
|
|
591
|
+
function (nextState) {
|
|
592
|
+
actionLogger.completed(nextState);
|
|
593
|
+
})), operators.catchError((/**
|
|
594
|
+
* @param {?} error
|
|
595
|
+
* @return {?}
|
|
596
|
+
*/
|
|
597
|
+
function (error) {
|
|
598
|
+
actionLogger.errored(error);
|
|
599
|
+
throw error;
|
|
600
|
+
})));
|
|
601
|
+
};
|
|
602
|
+
NgxsLoggerPlugin.decorators = [
|
|
603
|
+
{ type: core.Injectable }
|
|
604
|
+
];
|
|
605
|
+
/** @nocollapse */
|
|
606
|
+
NgxsLoggerPlugin.ctorParameters = function () { return [
|
|
607
|
+
{ type: undefined, decorators: [{ type: core.Inject, args: [NGXS_LOGGER_PLUGIN_OPTIONS,] }] },
|
|
608
|
+
{ type: core.Injector }
|
|
609
|
+
]; };
|
|
610
|
+
return NgxsLoggerPlugin;
|
|
611
|
+
}());
|
|
612
|
+
if (false) {
|
|
613
|
+
/**
|
|
614
|
+
* @type {?}
|
|
615
|
+
* @private
|
|
616
|
+
*/
|
|
617
|
+
NgxsLoggerPlugin.prototype._store;
|
|
618
|
+
/**
|
|
619
|
+
* @type {?}
|
|
620
|
+
* @private
|
|
621
|
+
*/
|
|
622
|
+
NgxsLoggerPlugin.prototype._logWriter;
|
|
623
|
+
/**
|
|
624
|
+
* @type {?}
|
|
625
|
+
* @private
|
|
626
|
+
*/
|
|
627
|
+
NgxsLoggerPlugin.prototype._options;
|
|
628
|
+
/**
|
|
629
|
+
* @type {?}
|
|
630
|
+
* @private
|
|
631
|
+
*/
|
|
632
|
+
NgxsLoggerPlugin.prototype._injector;
|
|
633
633
|
}
|
|
634
634
|
|
|
635
|
-
/**
|
|
636
|
-
* @fileoverview added by tsickle
|
|
637
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
638
|
-
*/
|
|
639
|
-
/** @type {?} */
|
|
640
|
-
var USER_OPTIONS = new core.InjectionToken('LOGGER_USER_OPTIONS');
|
|
641
|
-
/**
|
|
642
|
-
* @param {?} options
|
|
643
|
-
* @return {?}
|
|
644
|
-
*/
|
|
645
|
-
function loggerOptionsFactory(options) {
|
|
646
|
-
/** @type {?} */
|
|
647
|
-
var defaultLoggerOptions = {
|
|
648
|
-
logger: console,
|
|
649
|
-
collapsed: false,
|
|
650
|
-
disabled: false,
|
|
651
|
-
filter: (/**
|
|
652
|
-
* @return {?}
|
|
653
|
-
*/
|
|
654
|
-
function () { return true; })
|
|
655
|
-
};
|
|
656
|
-
return __assign({}, defaultLoggerOptions, options);
|
|
657
|
-
}
|
|
658
|
-
var NgxsLoggerPluginModule = /** @class */ (function () {
|
|
659
|
-
function NgxsLoggerPluginModule() {
|
|
660
|
-
}
|
|
661
|
-
/**
|
|
662
|
-
* @param {?=} options
|
|
663
|
-
* @return {?}
|
|
664
|
-
*/
|
|
665
|
-
NgxsLoggerPluginModule.forRoot = /**
|
|
666
|
-
* @param {?=} options
|
|
667
|
-
* @return {?}
|
|
668
|
-
*/
|
|
669
|
-
function (options) {
|
|
670
|
-
return {
|
|
671
|
-
ngModule: NgxsLoggerPluginModule,
|
|
672
|
-
providers: [
|
|
673
|
-
{
|
|
674
|
-
provide: store.NGXS_PLUGINS,
|
|
675
|
-
useClass: NgxsLoggerPlugin,
|
|
676
|
-
multi: true
|
|
677
|
-
},
|
|
678
|
-
{
|
|
679
|
-
provide: USER_OPTIONS,
|
|
680
|
-
useValue: options
|
|
681
|
-
},
|
|
682
|
-
{
|
|
683
|
-
provide: NGXS_LOGGER_PLUGIN_OPTIONS,
|
|
684
|
-
useFactory: loggerOptionsFactory,
|
|
685
|
-
deps: [USER_OPTIONS]
|
|
686
|
-
}
|
|
687
|
-
]
|
|
688
|
-
};
|
|
689
|
-
};
|
|
690
|
-
NgxsLoggerPluginModule.decorators = [
|
|
691
|
-
{ type: core.NgModule }
|
|
692
|
-
];
|
|
693
|
-
return NgxsLoggerPluginModule;
|
|
635
|
+
/**
|
|
636
|
+
* @fileoverview added by tsickle
|
|
637
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
638
|
+
*/
|
|
639
|
+
/** @type {?} */
|
|
640
|
+
var USER_OPTIONS = new core.InjectionToken('LOGGER_USER_OPTIONS');
|
|
641
|
+
/**
|
|
642
|
+
* @param {?} options
|
|
643
|
+
* @return {?}
|
|
644
|
+
*/
|
|
645
|
+
function loggerOptionsFactory(options) {
|
|
646
|
+
/** @type {?} */
|
|
647
|
+
var defaultLoggerOptions = {
|
|
648
|
+
logger: console,
|
|
649
|
+
collapsed: false,
|
|
650
|
+
disabled: false,
|
|
651
|
+
filter: (/**
|
|
652
|
+
* @return {?}
|
|
653
|
+
*/
|
|
654
|
+
function () { return true; })
|
|
655
|
+
};
|
|
656
|
+
return __assign({}, defaultLoggerOptions, options);
|
|
657
|
+
}
|
|
658
|
+
var NgxsLoggerPluginModule = /** @class */ (function () {
|
|
659
|
+
function NgxsLoggerPluginModule() {
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* @param {?=} options
|
|
663
|
+
* @return {?}
|
|
664
|
+
*/
|
|
665
|
+
NgxsLoggerPluginModule.forRoot = /**
|
|
666
|
+
* @param {?=} options
|
|
667
|
+
* @return {?}
|
|
668
|
+
*/
|
|
669
|
+
function (options) {
|
|
670
|
+
return {
|
|
671
|
+
ngModule: NgxsLoggerPluginModule,
|
|
672
|
+
providers: [
|
|
673
|
+
{
|
|
674
|
+
provide: store.NGXS_PLUGINS,
|
|
675
|
+
useClass: NgxsLoggerPlugin,
|
|
676
|
+
multi: true
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
provide: USER_OPTIONS,
|
|
680
|
+
useValue: options
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
provide: NGXS_LOGGER_PLUGIN_OPTIONS,
|
|
684
|
+
useFactory: loggerOptionsFactory,
|
|
685
|
+
deps: [USER_OPTIONS]
|
|
686
|
+
}
|
|
687
|
+
]
|
|
688
|
+
};
|
|
689
|
+
};
|
|
690
|
+
NgxsLoggerPluginModule.decorators = [
|
|
691
|
+
{ type: core.NgModule }
|
|
692
|
+
];
|
|
693
|
+
return NgxsLoggerPluginModule;
|
|
694
694
|
}());
|
|
695
695
|
|
|
696
696
|
exports.NGXS_LOGGER_PLUGIN_OPTIONS = NGXS_LOGGER_PLUGIN_OPTIONS;
|