@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
|
@@ -2,430 +2,430 @@ import { InjectionToken, Injectable, Inject, Injector, NgModule } from '@angular
|
|
|
2
2
|
import { getActionTypeFromInstance, Store, NGXS_PLUGINS } from '@ngxs/store';
|
|
3
3
|
import { tap, catchError } from 'rxjs/operators';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* @fileoverview added by tsickle
|
|
7
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
8
|
-
*/
|
|
9
|
-
/** @type {?} */
|
|
10
|
-
const repeat = (/**
|
|
11
|
-
* @param {?} str
|
|
12
|
-
* @param {?} times
|
|
13
|
-
* @return {?}
|
|
14
|
-
*/
|
|
15
|
-
(str, times) => new Array(times + 1).join(str));
|
|
16
|
-
/** @type {?} */
|
|
17
|
-
const pad = (/**
|
|
18
|
-
* @param {?} num
|
|
19
|
-
* @param {?} maxLength
|
|
20
|
-
* @return {?}
|
|
21
|
-
*/
|
|
22
|
-
(num, maxLength) => repeat('0', maxLength - num.toString().length) + num);
|
|
23
|
-
/**
|
|
24
|
-
* @param {?} time
|
|
25
|
-
* @return {?}
|
|
26
|
-
*/
|
|
27
|
-
function formatTime(time) {
|
|
28
|
-
return (pad(time.getHours(), 2) +
|
|
29
|
-
`:` +
|
|
30
|
-
pad(time.getMinutes(), 2) +
|
|
31
|
-
`:` +
|
|
32
|
-
pad(time.getSeconds(), 2) +
|
|
33
|
-
`.` +
|
|
34
|
-
pad(time.getMilliseconds(), 3));
|
|
5
|
+
/**
|
|
6
|
+
* @fileoverview added by tsickle
|
|
7
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
8
|
+
*/
|
|
9
|
+
/** @type {?} */
|
|
10
|
+
const repeat = (/**
|
|
11
|
+
* @param {?} str
|
|
12
|
+
* @param {?} times
|
|
13
|
+
* @return {?}
|
|
14
|
+
*/
|
|
15
|
+
(str, times) => new Array(times + 1).join(str));
|
|
16
|
+
/** @type {?} */
|
|
17
|
+
const pad = (/**
|
|
18
|
+
* @param {?} num
|
|
19
|
+
* @param {?} maxLength
|
|
20
|
+
* @return {?}
|
|
21
|
+
*/
|
|
22
|
+
(num, maxLength) => repeat('0', maxLength - num.toString().length) + num);
|
|
23
|
+
/**
|
|
24
|
+
* @param {?} time
|
|
25
|
+
* @return {?}
|
|
26
|
+
*/
|
|
27
|
+
function formatTime(time) {
|
|
28
|
+
return (pad(time.getHours(), 2) +
|
|
29
|
+
`:` +
|
|
30
|
+
pad(time.getMinutes(), 2) +
|
|
31
|
+
`:` +
|
|
32
|
+
pad(time.getSeconds(), 2) +
|
|
33
|
+
`.` +
|
|
34
|
+
pad(time.getMilliseconds(), 3));
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
/**
|
|
38
|
-
* @fileoverview added by tsickle
|
|
39
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
40
|
-
*/
|
|
41
|
-
class ActionLogger {
|
|
42
|
-
/**
|
|
43
|
-
* @param {?} action
|
|
44
|
-
* @param {?} store
|
|
45
|
-
* @param {?} logWriter
|
|
46
|
-
*/
|
|
47
|
-
constructor(action, store, logWriter) {
|
|
48
|
-
this.action = action;
|
|
49
|
-
this.store = store;
|
|
50
|
-
this.logWriter = logWriter;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* @param {?} state
|
|
54
|
-
* @return {?}
|
|
55
|
-
*/
|
|
56
|
-
dispatched(state) {
|
|
57
|
-
/** @type {?} */
|
|
58
|
-
const actionName = getActionTypeFromInstance(this.action);
|
|
59
|
-
/** @type {?} */
|
|
60
|
-
const formattedTime = formatTime(new Date());
|
|
61
|
-
/** @type {?} */
|
|
62
|
-
const message = `action ${actionName} @ ${formattedTime}`;
|
|
63
|
-
this.logWriter.startGroup(message);
|
|
64
|
-
// print payload only if at least one property is supplied
|
|
65
|
-
if (this._hasPayload(this.action)) {
|
|
66
|
-
this.logWriter.logGrey('payload', Object.assign({}, this.action));
|
|
67
|
-
}
|
|
68
|
-
this.logWriter.logGrey('prev state', state);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* @param {?} nextState
|
|
72
|
-
* @return {?}
|
|
73
|
-
*/
|
|
74
|
-
completed(nextState) {
|
|
75
|
-
this.logWriter.logGreen('next state', nextState);
|
|
76
|
-
this.logWriter.endGroup();
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* @param {?} error
|
|
80
|
-
* @return {?}
|
|
81
|
-
*/
|
|
82
|
-
errored(error) {
|
|
83
|
-
this.logWriter.logRedish('next state after error', this.store.snapshot());
|
|
84
|
-
this.logWriter.logRedish('error', error);
|
|
85
|
-
this.logWriter.endGroup();
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* @private
|
|
89
|
-
* @param {?} event
|
|
90
|
-
* @return {?}
|
|
91
|
-
*/
|
|
92
|
-
_hasPayload(event) {
|
|
93
|
-
/** @type {?} */
|
|
94
|
-
const nonEmptyProperties = this._getNonEmptyProperties(event);
|
|
95
|
-
return nonEmptyProperties.length > 0;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* @private
|
|
99
|
-
* @param {?} event
|
|
100
|
-
* @return {?}
|
|
101
|
-
*/
|
|
102
|
-
_getNonEmptyProperties(event) {
|
|
103
|
-
/** @type {?} */
|
|
104
|
-
const keys = Object.keys(event);
|
|
105
|
-
/** @type {?} */
|
|
106
|
-
const values = keys.map((/**
|
|
107
|
-
* @param {?} key
|
|
108
|
-
* @return {?}
|
|
109
|
-
*/
|
|
110
|
-
key => event[key]));
|
|
111
|
-
return values.filter((/**
|
|
112
|
-
* @param {?} value
|
|
113
|
-
* @return {?}
|
|
114
|
-
*/
|
|
115
|
-
value => value !== undefined));
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
if (false) {
|
|
119
|
-
/**
|
|
120
|
-
* @type {?}
|
|
121
|
-
* @private
|
|
122
|
-
*/
|
|
123
|
-
ActionLogger.prototype.action;
|
|
124
|
-
/**
|
|
125
|
-
* @type {?}
|
|
126
|
-
* @private
|
|
127
|
-
*/
|
|
128
|
-
ActionLogger.prototype.store;
|
|
129
|
-
/**
|
|
130
|
-
* @type {?}
|
|
131
|
-
* @private
|
|
132
|
-
*/
|
|
133
|
-
ActionLogger.prototype.logWriter;
|
|
37
|
+
/**
|
|
38
|
+
* @fileoverview added by tsickle
|
|
39
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
40
|
+
*/
|
|
41
|
+
class ActionLogger {
|
|
42
|
+
/**
|
|
43
|
+
* @param {?} action
|
|
44
|
+
* @param {?} store
|
|
45
|
+
* @param {?} logWriter
|
|
46
|
+
*/
|
|
47
|
+
constructor(action, store, logWriter) {
|
|
48
|
+
this.action = action;
|
|
49
|
+
this.store = store;
|
|
50
|
+
this.logWriter = logWriter;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* @param {?} state
|
|
54
|
+
* @return {?}
|
|
55
|
+
*/
|
|
56
|
+
dispatched(state) {
|
|
57
|
+
/** @type {?} */
|
|
58
|
+
const actionName = getActionTypeFromInstance(this.action);
|
|
59
|
+
/** @type {?} */
|
|
60
|
+
const formattedTime = formatTime(new Date());
|
|
61
|
+
/** @type {?} */
|
|
62
|
+
const message = `action ${actionName} @ ${formattedTime}`;
|
|
63
|
+
this.logWriter.startGroup(message);
|
|
64
|
+
// print payload only if at least one property is supplied
|
|
65
|
+
if (this._hasPayload(this.action)) {
|
|
66
|
+
this.logWriter.logGrey('payload', Object.assign({}, this.action));
|
|
67
|
+
}
|
|
68
|
+
this.logWriter.logGrey('prev state', state);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @param {?} nextState
|
|
72
|
+
* @return {?}
|
|
73
|
+
*/
|
|
74
|
+
completed(nextState) {
|
|
75
|
+
this.logWriter.logGreen('next state', nextState);
|
|
76
|
+
this.logWriter.endGroup();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* @param {?} error
|
|
80
|
+
* @return {?}
|
|
81
|
+
*/
|
|
82
|
+
errored(error) {
|
|
83
|
+
this.logWriter.logRedish('next state after error', this.store.snapshot());
|
|
84
|
+
this.logWriter.logRedish('error', error);
|
|
85
|
+
this.logWriter.endGroup();
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @private
|
|
89
|
+
* @param {?} event
|
|
90
|
+
* @return {?}
|
|
91
|
+
*/
|
|
92
|
+
_hasPayload(event) {
|
|
93
|
+
/** @type {?} */
|
|
94
|
+
const nonEmptyProperties = this._getNonEmptyProperties(event);
|
|
95
|
+
return nonEmptyProperties.length > 0;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @private
|
|
99
|
+
* @param {?} event
|
|
100
|
+
* @return {?}
|
|
101
|
+
*/
|
|
102
|
+
_getNonEmptyProperties(event) {
|
|
103
|
+
/** @type {?} */
|
|
104
|
+
const keys = Object.keys(event);
|
|
105
|
+
/** @type {?} */
|
|
106
|
+
const values = keys.map((/**
|
|
107
|
+
* @param {?} key
|
|
108
|
+
* @return {?}
|
|
109
|
+
*/
|
|
110
|
+
key => event[key]));
|
|
111
|
+
return values.filter((/**
|
|
112
|
+
* @param {?} value
|
|
113
|
+
* @return {?}
|
|
114
|
+
*/
|
|
115
|
+
value => value !== undefined));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (false) {
|
|
119
|
+
/**
|
|
120
|
+
* @type {?}
|
|
121
|
+
* @private
|
|
122
|
+
*/
|
|
123
|
+
ActionLogger.prototype.action;
|
|
124
|
+
/**
|
|
125
|
+
* @type {?}
|
|
126
|
+
* @private
|
|
127
|
+
*/
|
|
128
|
+
ActionLogger.prototype.store;
|
|
129
|
+
/**
|
|
130
|
+
* @type {?}
|
|
131
|
+
* @private
|
|
132
|
+
*/
|
|
133
|
+
ActionLogger.prototype.logWriter;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
/**
|
|
137
|
-
* @fileoverview added by tsickle
|
|
138
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
139
|
-
*/
|
|
140
|
-
class LogWriter {
|
|
141
|
-
/**
|
|
142
|
-
* @param {?} options
|
|
143
|
-
*/
|
|
144
|
-
constructor(options) {
|
|
145
|
-
this.options = options;
|
|
146
|
-
this.options = this.options || (/** @type {?} */ ({}));
|
|
147
|
-
this.logger = options.logger || console;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* @param {?} message
|
|
151
|
-
* @return {?}
|
|
152
|
-
*/
|
|
153
|
-
startGroup(message) {
|
|
154
|
-
/** @type {?} */
|
|
155
|
-
const startGroupFn = this.options.collapsed
|
|
156
|
-
? this.logger.groupCollapsed
|
|
157
|
-
: this.logger.group;
|
|
158
|
-
try {
|
|
159
|
-
startGroupFn.call(this.logger, message);
|
|
160
|
-
}
|
|
161
|
-
catch (e) {
|
|
162
|
-
console.log(message);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* @return {?}
|
|
167
|
-
*/
|
|
168
|
-
endGroup() {
|
|
169
|
-
try {
|
|
170
|
-
this.logger.groupEnd();
|
|
171
|
-
}
|
|
172
|
-
catch (e) {
|
|
173
|
-
this.logger.log('—— log end ——');
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* @param {?} title
|
|
178
|
-
* @param {?} payload
|
|
179
|
-
* @return {?}
|
|
180
|
-
*/
|
|
181
|
-
logGrey(title, payload) {
|
|
182
|
-
/** @type {?} */
|
|
183
|
-
const greyStyle = 'color: #9E9E9E; font-weight: bold';
|
|
184
|
-
this.log(title, greyStyle, payload);
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* @param {?} title
|
|
188
|
-
* @param {?} payload
|
|
189
|
-
* @return {?}
|
|
190
|
-
*/
|
|
191
|
-
logGreen(title, payload) {
|
|
192
|
-
/** @type {?} */
|
|
193
|
-
const greenStyle = 'color: #4CAF50; font-weight: bold';
|
|
194
|
-
this.log(title, greenStyle, payload);
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* @param {?} title
|
|
198
|
-
* @param {?} payload
|
|
199
|
-
* @return {?}
|
|
200
|
-
*/
|
|
201
|
-
logRedish(title, payload) {
|
|
202
|
-
/** @type {?} */
|
|
203
|
-
const redishStyle = 'color: #FD8182; font-weight: bold';
|
|
204
|
-
this.log(title, redishStyle, payload);
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* @param {?} title
|
|
208
|
-
* @param {?} color
|
|
209
|
-
* @param {?} payload
|
|
210
|
-
* @return {?}
|
|
211
|
-
*/
|
|
212
|
-
log(title, color, payload) {
|
|
213
|
-
if (this.isIE()) {
|
|
214
|
-
this.logger.log(title, payload);
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
this.logger.log('%c ' + title, color, payload);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* @return {?}
|
|
222
|
-
*/
|
|
223
|
-
isIE() {
|
|
224
|
-
/** @type {?} */
|
|
225
|
-
const ua = typeof window !== 'undefined' && window.navigator.userAgent
|
|
226
|
-
? window.navigator.userAgent
|
|
227
|
-
: '';
|
|
228
|
-
/** @type {?} */
|
|
229
|
-
let msIE = false;
|
|
230
|
-
/** @type {?} */
|
|
231
|
-
const oldIE = ua.indexOf('MSIE ');
|
|
232
|
-
/** @type {?} */
|
|
233
|
-
const newIE = ua.indexOf('Trident/');
|
|
234
|
-
if (oldIE > -1 || newIE > -1) {
|
|
235
|
-
msIE = true;
|
|
236
|
-
}
|
|
237
|
-
return msIE;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
if (false) {
|
|
241
|
-
/**
|
|
242
|
-
* @type {?}
|
|
243
|
-
* @private
|
|
244
|
-
*/
|
|
245
|
-
LogWriter.prototype.logger;
|
|
246
|
-
/**
|
|
247
|
-
* @type {?}
|
|
248
|
-
* @private
|
|
249
|
-
*/
|
|
250
|
-
LogWriter.prototype.options;
|
|
136
|
+
/**
|
|
137
|
+
* @fileoverview added by tsickle
|
|
138
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
139
|
+
*/
|
|
140
|
+
class LogWriter {
|
|
141
|
+
/**
|
|
142
|
+
* @param {?} options
|
|
143
|
+
*/
|
|
144
|
+
constructor(options) {
|
|
145
|
+
this.options = options;
|
|
146
|
+
this.options = this.options || (/** @type {?} */ ({}));
|
|
147
|
+
this.logger = options.logger || console;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* @param {?} message
|
|
151
|
+
* @return {?}
|
|
152
|
+
*/
|
|
153
|
+
startGroup(message) {
|
|
154
|
+
/** @type {?} */
|
|
155
|
+
const startGroupFn = this.options.collapsed
|
|
156
|
+
? this.logger.groupCollapsed
|
|
157
|
+
: this.logger.group;
|
|
158
|
+
try {
|
|
159
|
+
startGroupFn.call(this.logger, message);
|
|
160
|
+
}
|
|
161
|
+
catch (e) {
|
|
162
|
+
console.log(message);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* @return {?}
|
|
167
|
+
*/
|
|
168
|
+
endGroup() {
|
|
169
|
+
try {
|
|
170
|
+
this.logger.groupEnd();
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
this.logger.log('—— log end ——');
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* @param {?} title
|
|
178
|
+
* @param {?} payload
|
|
179
|
+
* @return {?}
|
|
180
|
+
*/
|
|
181
|
+
logGrey(title, payload) {
|
|
182
|
+
/** @type {?} */
|
|
183
|
+
const greyStyle = 'color: #9E9E9E; font-weight: bold';
|
|
184
|
+
this.log(title, greyStyle, payload);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* @param {?} title
|
|
188
|
+
* @param {?} payload
|
|
189
|
+
* @return {?}
|
|
190
|
+
*/
|
|
191
|
+
logGreen(title, payload) {
|
|
192
|
+
/** @type {?} */
|
|
193
|
+
const greenStyle = 'color: #4CAF50; font-weight: bold';
|
|
194
|
+
this.log(title, greenStyle, payload);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* @param {?} title
|
|
198
|
+
* @param {?} payload
|
|
199
|
+
* @return {?}
|
|
200
|
+
*/
|
|
201
|
+
logRedish(title, payload) {
|
|
202
|
+
/** @type {?} */
|
|
203
|
+
const redishStyle = 'color: #FD8182; font-weight: bold';
|
|
204
|
+
this.log(title, redishStyle, payload);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* @param {?} title
|
|
208
|
+
* @param {?} color
|
|
209
|
+
* @param {?} payload
|
|
210
|
+
* @return {?}
|
|
211
|
+
*/
|
|
212
|
+
log(title, color, payload) {
|
|
213
|
+
if (this.isIE()) {
|
|
214
|
+
this.logger.log(title, payload);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
this.logger.log('%c ' + title, color, payload);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* @return {?}
|
|
222
|
+
*/
|
|
223
|
+
isIE() {
|
|
224
|
+
/** @type {?} */
|
|
225
|
+
const ua = typeof window !== 'undefined' && window.navigator.userAgent
|
|
226
|
+
? window.navigator.userAgent
|
|
227
|
+
: '';
|
|
228
|
+
/** @type {?} */
|
|
229
|
+
let msIE = false;
|
|
230
|
+
/** @type {?} */
|
|
231
|
+
const oldIE = ua.indexOf('MSIE ');
|
|
232
|
+
/** @type {?} */
|
|
233
|
+
const newIE = ua.indexOf('Trident/');
|
|
234
|
+
if (oldIE > -1 || newIE > -1) {
|
|
235
|
+
msIE = true;
|
|
236
|
+
}
|
|
237
|
+
return msIE;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (false) {
|
|
241
|
+
/**
|
|
242
|
+
* @type {?}
|
|
243
|
+
* @private
|
|
244
|
+
*/
|
|
245
|
+
LogWriter.prototype.logger;
|
|
246
|
+
/**
|
|
247
|
+
* @type {?}
|
|
248
|
+
* @private
|
|
249
|
+
*/
|
|
250
|
+
LogWriter.prototype.options;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
/**
|
|
254
|
-
* @fileoverview added by tsickle
|
|
255
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
256
|
-
*/
|
|
257
|
-
/**
|
|
258
|
-
* @record
|
|
259
|
-
*/
|
|
260
|
-
function NgxsLoggerPluginOptions() { }
|
|
261
|
-
if (false) {
|
|
262
|
-
/**
|
|
263
|
-
* Auto expand logged actions
|
|
264
|
-
* @type {?|undefined}
|
|
265
|
-
*/
|
|
266
|
-
NgxsLoggerPluginOptions.prototype.collapsed;
|
|
267
|
-
/**
|
|
268
|
-
* Provide alternate console.log implementation
|
|
269
|
-
* @type {?|undefined}
|
|
270
|
-
*/
|
|
271
|
-
NgxsLoggerPluginOptions.prototype.logger;
|
|
272
|
-
/**
|
|
273
|
-
* Disable the logger. Useful for prod mode.
|
|
274
|
-
* @type {?|undefined}
|
|
275
|
-
*/
|
|
276
|
-
NgxsLoggerPluginOptions.prototype.disabled;
|
|
277
|
-
/**
|
|
278
|
-
* Predicate for actions to be the logged. Takes action and state snapshot as parameters
|
|
279
|
-
* @type {?|undefined}
|
|
280
|
-
*/
|
|
281
|
-
NgxsLoggerPluginOptions.prototype.filter;
|
|
282
|
-
}
|
|
283
|
-
/** @type {?} */
|
|
253
|
+
/**
|
|
254
|
+
* @fileoverview added by tsickle
|
|
255
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
256
|
+
*/
|
|
257
|
+
/**
|
|
258
|
+
* @record
|
|
259
|
+
*/
|
|
260
|
+
function NgxsLoggerPluginOptions() { }
|
|
261
|
+
if (false) {
|
|
262
|
+
/**
|
|
263
|
+
* Auto expand logged actions
|
|
264
|
+
* @type {?|undefined}
|
|
265
|
+
*/
|
|
266
|
+
NgxsLoggerPluginOptions.prototype.collapsed;
|
|
267
|
+
/**
|
|
268
|
+
* Provide alternate console.log implementation
|
|
269
|
+
* @type {?|undefined}
|
|
270
|
+
*/
|
|
271
|
+
NgxsLoggerPluginOptions.prototype.logger;
|
|
272
|
+
/**
|
|
273
|
+
* Disable the logger. Useful for prod mode.
|
|
274
|
+
* @type {?|undefined}
|
|
275
|
+
*/
|
|
276
|
+
NgxsLoggerPluginOptions.prototype.disabled;
|
|
277
|
+
/**
|
|
278
|
+
* Predicate for actions to be the logged. Takes action and state snapshot as parameters
|
|
279
|
+
* @type {?|undefined}
|
|
280
|
+
*/
|
|
281
|
+
NgxsLoggerPluginOptions.prototype.filter;
|
|
282
|
+
}
|
|
283
|
+
/** @type {?} */
|
|
284
284
|
const NGXS_LOGGER_PLUGIN_OPTIONS = new InjectionToken('NGXS_LOGGER_PLUGIN_OPTIONS');
|
|
285
285
|
|
|
286
|
-
/**
|
|
287
|
-
* @fileoverview added by tsickle
|
|
288
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
289
|
-
*/
|
|
290
|
-
class NgxsLoggerPlugin {
|
|
291
|
-
/**
|
|
292
|
-
* @param {?} _options
|
|
293
|
-
* @param {?} _injector
|
|
294
|
-
*/
|
|
295
|
-
constructor(_options, _injector) {
|
|
296
|
-
this._options = _options;
|
|
297
|
-
this._injector = _injector;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* @param {?} state
|
|
301
|
-
* @param {?} event
|
|
302
|
-
* @param {?} next
|
|
303
|
-
* @return {?}
|
|
304
|
-
*/
|
|
305
|
-
handle(state, event, next) {
|
|
306
|
-
if (this._options.disabled || !(/** @type {?} */ (this._options.filter))(event, state)) {
|
|
307
|
-
return next(state, event);
|
|
308
|
-
}
|
|
309
|
-
this._logWriter = this._logWriter || new LogWriter(this._options);
|
|
310
|
-
// Retrieve lazily to avoid cyclic dependency exception
|
|
311
|
-
this._store = this._store || this._injector.get(Store);
|
|
312
|
-
/** @type {?} */
|
|
313
|
-
const actionLogger = new ActionLogger(event, this._store, this._logWriter);
|
|
314
|
-
actionLogger.dispatched(state);
|
|
315
|
-
return next(state, event).pipe(tap((/**
|
|
316
|
-
* @param {?} nextState
|
|
317
|
-
* @return {?}
|
|
318
|
-
*/
|
|
319
|
-
nextState => {
|
|
320
|
-
actionLogger.completed(nextState);
|
|
321
|
-
})), catchError((/**
|
|
322
|
-
* @param {?} error
|
|
323
|
-
* @return {?}
|
|
324
|
-
*/
|
|
325
|
-
error => {
|
|
326
|
-
actionLogger.errored(error);
|
|
327
|
-
throw error;
|
|
328
|
-
})));
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
NgxsLoggerPlugin.decorators = [
|
|
332
|
-
{ type: Injectable }
|
|
333
|
-
];
|
|
334
|
-
/** @nocollapse */
|
|
335
|
-
NgxsLoggerPlugin.ctorParameters = () => [
|
|
336
|
-
{ type: undefined, decorators: [{ type: Inject, args: [NGXS_LOGGER_PLUGIN_OPTIONS,] }] },
|
|
337
|
-
{ type: Injector }
|
|
338
|
-
];
|
|
339
|
-
if (false) {
|
|
340
|
-
/**
|
|
341
|
-
* @type {?}
|
|
342
|
-
* @private
|
|
343
|
-
*/
|
|
344
|
-
NgxsLoggerPlugin.prototype._store;
|
|
345
|
-
/**
|
|
346
|
-
* @type {?}
|
|
347
|
-
* @private
|
|
348
|
-
*/
|
|
349
|
-
NgxsLoggerPlugin.prototype._logWriter;
|
|
350
|
-
/**
|
|
351
|
-
* @type {?}
|
|
352
|
-
* @private
|
|
353
|
-
*/
|
|
354
|
-
NgxsLoggerPlugin.prototype._options;
|
|
355
|
-
/**
|
|
356
|
-
* @type {?}
|
|
357
|
-
* @private
|
|
358
|
-
*/
|
|
359
|
-
NgxsLoggerPlugin.prototype._injector;
|
|
286
|
+
/**
|
|
287
|
+
* @fileoverview added by tsickle
|
|
288
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
289
|
+
*/
|
|
290
|
+
class NgxsLoggerPlugin {
|
|
291
|
+
/**
|
|
292
|
+
* @param {?} _options
|
|
293
|
+
* @param {?} _injector
|
|
294
|
+
*/
|
|
295
|
+
constructor(_options, _injector) {
|
|
296
|
+
this._options = _options;
|
|
297
|
+
this._injector = _injector;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* @param {?} state
|
|
301
|
+
* @param {?} event
|
|
302
|
+
* @param {?} next
|
|
303
|
+
* @return {?}
|
|
304
|
+
*/
|
|
305
|
+
handle(state, event, next) {
|
|
306
|
+
if (this._options.disabled || !(/** @type {?} */ (this._options.filter))(event, state)) {
|
|
307
|
+
return next(state, event);
|
|
308
|
+
}
|
|
309
|
+
this._logWriter = this._logWriter || new LogWriter(this._options);
|
|
310
|
+
// Retrieve lazily to avoid cyclic dependency exception
|
|
311
|
+
this._store = this._store || this._injector.get(Store);
|
|
312
|
+
/** @type {?} */
|
|
313
|
+
const actionLogger = new ActionLogger(event, this._store, this._logWriter);
|
|
314
|
+
actionLogger.dispatched(state);
|
|
315
|
+
return next(state, event).pipe(tap((/**
|
|
316
|
+
* @param {?} nextState
|
|
317
|
+
* @return {?}
|
|
318
|
+
*/
|
|
319
|
+
nextState => {
|
|
320
|
+
actionLogger.completed(nextState);
|
|
321
|
+
})), catchError((/**
|
|
322
|
+
* @param {?} error
|
|
323
|
+
* @return {?}
|
|
324
|
+
*/
|
|
325
|
+
error => {
|
|
326
|
+
actionLogger.errored(error);
|
|
327
|
+
throw error;
|
|
328
|
+
})));
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
NgxsLoggerPlugin.decorators = [
|
|
332
|
+
{ type: Injectable }
|
|
333
|
+
];
|
|
334
|
+
/** @nocollapse */
|
|
335
|
+
NgxsLoggerPlugin.ctorParameters = () => [
|
|
336
|
+
{ type: undefined, decorators: [{ type: Inject, args: [NGXS_LOGGER_PLUGIN_OPTIONS,] }] },
|
|
337
|
+
{ type: Injector }
|
|
338
|
+
];
|
|
339
|
+
if (false) {
|
|
340
|
+
/**
|
|
341
|
+
* @type {?}
|
|
342
|
+
* @private
|
|
343
|
+
*/
|
|
344
|
+
NgxsLoggerPlugin.prototype._store;
|
|
345
|
+
/**
|
|
346
|
+
* @type {?}
|
|
347
|
+
* @private
|
|
348
|
+
*/
|
|
349
|
+
NgxsLoggerPlugin.prototype._logWriter;
|
|
350
|
+
/**
|
|
351
|
+
* @type {?}
|
|
352
|
+
* @private
|
|
353
|
+
*/
|
|
354
|
+
NgxsLoggerPlugin.prototype._options;
|
|
355
|
+
/**
|
|
356
|
+
* @type {?}
|
|
357
|
+
* @private
|
|
358
|
+
*/
|
|
359
|
+
NgxsLoggerPlugin.prototype._injector;
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
-
/**
|
|
363
|
-
* @fileoverview added by tsickle
|
|
364
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
365
|
-
*/
|
|
366
|
-
/** @type {?} */
|
|
367
|
-
const USER_OPTIONS = new InjectionToken('LOGGER_USER_OPTIONS');
|
|
368
|
-
/**
|
|
369
|
-
* @param {?} options
|
|
370
|
-
* @return {?}
|
|
371
|
-
*/
|
|
372
|
-
function loggerOptionsFactory(options) {
|
|
373
|
-
/** @type {?} */
|
|
374
|
-
const defaultLoggerOptions = {
|
|
375
|
-
logger: console,
|
|
376
|
-
collapsed: false,
|
|
377
|
-
disabled: false,
|
|
378
|
-
filter: (/**
|
|
379
|
-
* @return {?}
|
|
380
|
-
*/
|
|
381
|
-
() => true)
|
|
382
|
-
};
|
|
383
|
-
return Object.assign({}, defaultLoggerOptions, options);
|
|
384
|
-
}
|
|
385
|
-
class NgxsLoggerPluginModule {
|
|
386
|
-
/**
|
|
387
|
-
* @param {?=} options
|
|
388
|
-
* @return {?}
|
|
389
|
-
*/
|
|
390
|
-
static forRoot(options) {
|
|
391
|
-
return {
|
|
392
|
-
ngModule: NgxsLoggerPluginModule,
|
|
393
|
-
providers: [
|
|
394
|
-
{
|
|
395
|
-
provide: NGXS_PLUGINS,
|
|
396
|
-
useClass: NgxsLoggerPlugin,
|
|
397
|
-
multi: true
|
|
398
|
-
},
|
|
399
|
-
{
|
|
400
|
-
provide: USER_OPTIONS,
|
|
401
|
-
useValue: options
|
|
402
|
-
},
|
|
403
|
-
{
|
|
404
|
-
provide: NGXS_LOGGER_PLUGIN_OPTIONS,
|
|
405
|
-
useFactory: loggerOptionsFactory,
|
|
406
|
-
deps: [USER_OPTIONS]
|
|
407
|
-
}
|
|
408
|
-
]
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
NgxsLoggerPluginModule.decorators = [
|
|
413
|
-
{ type: NgModule }
|
|
362
|
+
/**
|
|
363
|
+
* @fileoverview added by tsickle
|
|
364
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
365
|
+
*/
|
|
366
|
+
/** @type {?} */
|
|
367
|
+
const USER_OPTIONS = new InjectionToken('LOGGER_USER_OPTIONS');
|
|
368
|
+
/**
|
|
369
|
+
* @param {?} options
|
|
370
|
+
* @return {?}
|
|
371
|
+
*/
|
|
372
|
+
function loggerOptionsFactory(options) {
|
|
373
|
+
/** @type {?} */
|
|
374
|
+
const defaultLoggerOptions = {
|
|
375
|
+
logger: console,
|
|
376
|
+
collapsed: false,
|
|
377
|
+
disabled: false,
|
|
378
|
+
filter: (/**
|
|
379
|
+
* @return {?}
|
|
380
|
+
*/
|
|
381
|
+
() => true)
|
|
382
|
+
};
|
|
383
|
+
return Object.assign({}, defaultLoggerOptions, options);
|
|
384
|
+
}
|
|
385
|
+
class NgxsLoggerPluginModule {
|
|
386
|
+
/**
|
|
387
|
+
* @param {?=} options
|
|
388
|
+
* @return {?}
|
|
389
|
+
*/
|
|
390
|
+
static forRoot(options) {
|
|
391
|
+
return {
|
|
392
|
+
ngModule: NgxsLoggerPluginModule,
|
|
393
|
+
providers: [
|
|
394
|
+
{
|
|
395
|
+
provide: NGXS_PLUGINS,
|
|
396
|
+
useClass: NgxsLoggerPlugin,
|
|
397
|
+
multi: true
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
provide: USER_OPTIONS,
|
|
401
|
+
useValue: options
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
provide: NGXS_LOGGER_PLUGIN_OPTIONS,
|
|
405
|
+
useFactory: loggerOptionsFactory,
|
|
406
|
+
deps: [USER_OPTIONS]
|
|
407
|
+
}
|
|
408
|
+
]
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
NgxsLoggerPluginModule.decorators = [
|
|
413
|
+
{ type: NgModule }
|
|
414
414
|
];
|
|
415
415
|
|
|
416
|
-
/**
|
|
417
|
-
* @fileoverview added by tsickle
|
|
418
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
416
|
+
/**
|
|
417
|
+
* @fileoverview added by tsickle
|
|
418
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
419
419
|
*/
|
|
420
420
|
|
|
421
|
-
/**
|
|
422
|
-
* @fileoverview added by tsickle
|
|
423
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
421
|
+
/**
|
|
422
|
+
* @fileoverview added by tsickle
|
|
423
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
424
424
|
*/
|
|
425
425
|
|
|
426
|
-
/**
|
|
427
|
-
* @fileoverview added by tsickle
|
|
428
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
426
|
+
/**
|
|
427
|
+
* @fileoverview added by tsickle
|
|
428
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
429
429
|
*/
|
|
430
430
|
|
|
431
431
|
export { NGXS_LOGGER_PLUGIN_OPTIONS, NgxsLoggerPlugin, NgxsLoggerPluginModule, USER_OPTIONS as ɵa, loggerOptionsFactory as ɵb };
|