ng2-logger 13.1.1 → 13.1.2

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.
Files changed (90) hide show
  1. package/README.md +206 -206
  2. package/app/index.d.ts +4 -4
  3. package/app/index.js +19 -19
  4. package/app/ng2-logger.component.d.ts +5 -5
  5. package/app/ng2-logger.component.js +33 -33
  6. package/app/ng2-logger.module.d.ts +2 -2
  7. package/app/ng2-logger.module.js +30 -30
  8. package/browser/README.md +24 -24
  9. package/browser/esm2020/lib/backend-logging.mjs +91 -91
  10. package/browser/esm2020/lib/display.mjs +96 -96
  11. package/browser/esm2020/lib/helpers.mjs +1 -1
  12. package/browser/esm2020/lib/index.mjs +5 -5
  13. package/browser/esm2020/lib/level.mjs +30 -30
  14. package/browser/esm2020/lib/log.mjs +163 -163
  15. package/browser/esm2020/lib/logger.mjs +234 -234
  16. package/browser/esm2020/ng2-logger.mjs +4 -4
  17. package/browser/esm2020/public-api.mjs +1 -1
  18. package/browser/fesm2015/ng2-logger.mjs +512 -512
  19. package/browser/fesm2020/ng2-logger.mjs +512 -512
  20. package/browser/lib/backend-logging.d.ts +4 -4
  21. package/browser/lib/display.d.ts +4 -4
  22. package/browser/lib/helpers.d.ts +1 -1
  23. package/browser/lib/index.d.ts +5 -5
  24. package/browser/lib/level.d.ts +21 -21
  25. package/browser/lib/log.d.ts +25 -25
  26. package/browser/lib/logger.d.ts +81 -81
  27. package/browser/ng2-logger.d.ts +5 -5
  28. package/browser/public-api.d.ts +1 -1
  29. package/client/README.md +24 -24
  30. package/client/esm2020/lib/backend-logging.mjs +91 -91
  31. package/client/esm2020/lib/display.mjs +96 -96
  32. package/client/esm2020/lib/helpers.mjs +1 -1
  33. package/client/esm2020/lib/index.mjs +5 -5
  34. package/client/esm2020/lib/level.mjs +30 -30
  35. package/client/esm2020/lib/log.mjs +163 -163
  36. package/client/esm2020/lib/logger.mjs +234 -234
  37. package/client/esm2020/ng2-logger.mjs +4 -4
  38. package/client/esm2020/public-api.mjs +1 -1
  39. package/client/fesm2015/ng2-logger.mjs +512 -512
  40. package/client/fesm2020/ng2-logger.mjs +512 -512
  41. package/client/lib/backend-logging.d.ts +4 -4
  42. package/client/lib/display.d.ts +4 -4
  43. package/client/lib/helpers.d.ts +1 -1
  44. package/client/lib/index.d.ts +5 -5
  45. package/client/lib/level.d.ts +21 -21
  46. package/client/lib/log.d.ts +25 -25
  47. package/client/lib/logger.d.ts +81 -81
  48. package/client/ng2-logger.d.ts +5 -5
  49. package/client/public-api.d.ts +1 -1
  50. package/index.d.ts +1 -1
  51. package/index.js +5 -5
  52. package/lib/backend-logging.d.ts +4 -4
  53. package/lib/backend-logging.js +115 -115
  54. package/lib/display.d.ts +4 -4
  55. package/lib/display.js +104 -104
  56. package/lib/helpers.d.ts +1 -1
  57. package/lib/helpers.js +6 -6
  58. package/lib/index.d.ts +5 -5
  59. package/lib/index.js +9 -9
  60. package/lib/level.d.ts +21 -21
  61. package/lib/level.js +35 -35
  62. package/lib/log.d.ts +25 -25
  63. package/lib/log.js +197 -197
  64. package/lib/logger.d.ts +81 -81
  65. package/lib/logger.js +340 -340
  66. package/package.json +3 -3
  67. package/package.json_devDependencies.json +184 -184
  68. package/package.json_tnp.json5 +47 -47
  69. package/tmp-environment.json +15 -14
  70. package/websql/README.md +24 -24
  71. package/websql/esm2020/lib/backend-logging.mjs +91 -91
  72. package/websql/esm2020/lib/display.mjs +96 -96
  73. package/websql/esm2020/lib/helpers.mjs +1 -1
  74. package/websql/esm2020/lib/index.mjs +5 -5
  75. package/websql/esm2020/lib/level.mjs +30 -30
  76. package/websql/esm2020/lib/log.mjs +163 -163
  77. package/websql/esm2020/lib/logger.mjs +234 -234
  78. package/websql/esm2020/ng2-logger.mjs +4 -4
  79. package/websql/esm2020/public-api.mjs +1 -1
  80. package/websql/fesm2015/ng2-logger.mjs +512 -512
  81. package/websql/fesm2020/ng2-logger.mjs +512 -512
  82. package/websql/lib/backend-logging.d.ts +4 -4
  83. package/websql/lib/display.d.ts +4 -4
  84. package/websql/lib/helpers.d.ts +1 -1
  85. package/websql/lib/index.d.ts +5 -5
  86. package/websql/lib/level.d.ts +21 -21
  87. package/websql/lib/log.d.ts +25 -25
  88. package/websql/lib/logger.d.ts +81 -81
  89. package/websql/ng2-logger.d.ts +5 -5
  90. package/websql/public-api.d.ts +1 -1
@@ -1,526 +1,526 @@
1
1
  import { Helpers } from 'tnp-core/browser';
2
2
  export { Helpers } from 'tnp-config/browser';
3
3
 
4
- var Level;
5
- (function (Level) {
6
- Level[Level["DATA"] = 0] = "DATA";
7
- Level[Level["INFO"] = 1] = "INFO";
8
- Level[Level["WARN"] = 2] = "WARN";
9
- Level[Level["ERROR"] = 3] = "ERROR";
10
- Level[Level["SUCCESS"] = 4] = "SUCCESS";
11
- Level[Level["TASK_STARTED"] = 5] = "TASK_STARTED";
12
- Level[Level["TASK_DONE"] = 6] = "TASK_DONE";
13
- Level[Level["__NOTHING"] = 7] = "__NOTHING";
14
- })(Level || (Level = {}));
15
- const LevelKey = {
16
- [Level.DATA]: 'log',
17
- [Level.INFO]: 'info',
18
- [Level.WARN]: 'warn',
19
- [Level.ERROR]: 'error',
20
- [Level.SUCCESS]: 'success',
21
- [Level.TASK_STARTED]: 'taskstarted',
22
- [Level.TASK_DONE]: 'taskdone',
23
- [Level.__NOTHING]: '',
24
- };
25
- const LevelOrder = [
26
- LevelKey[Level.DATA],
27
- LevelKey[Level.TASK_STARTED],
28
- LevelKey[Level.TASK_DONE],
29
- LevelKey[Level.INFO],
30
- LevelKey[Level.SUCCESS],
31
- LevelKey[Level.WARN],
32
- LevelKey[Level.ERROR],
4
+ var Level;
5
+ (function (Level) {
6
+ Level[Level["DATA"] = 0] = "DATA";
7
+ Level[Level["INFO"] = 1] = "INFO";
8
+ Level[Level["WARN"] = 2] = "WARN";
9
+ Level[Level["ERROR"] = 3] = "ERROR";
10
+ Level[Level["SUCCESS"] = 4] = "SUCCESS";
11
+ Level[Level["TASK_STARTED"] = 5] = "TASK_STARTED";
12
+ Level[Level["TASK_DONE"] = 6] = "TASK_DONE";
13
+ Level[Level["__NOTHING"] = 7] = "__NOTHING";
14
+ })(Level || (Level = {}));
15
+ const LevelKey = {
16
+ [Level.DATA]: 'log',
17
+ [Level.INFO]: 'info',
18
+ [Level.WARN]: 'warn',
19
+ [Level.ERROR]: 'error',
20
+ [Level.SUCCESS]: 'success',
21
+ [Level.TASK_STARTED]: 'taskstarted',
22
+ [Level.TASK_DONE]: 'taskdone',
23
+ [Level.__NOTHING]: '',
24
+ };
25
+ const LevelOrder = [
26
+ LevelKey[Level.DATA],
27
+ LevelKey[Level.TASK_STARTED],
28
+ LevelKey[Level.TASK_DONE],
29
+ LevelKey[Level.INFO],
30
+ LevelKey[Level.SUCCESS],
31
+ LevelKey[Level.WARN],
32
+ LevelKey[Level.ERROR],
33
33
  ];
34
34
 
35
- /* */
36
- /* */
37
- /* */
38
- class Display {
39
- static msg(message, params, moduleName, moduleColor, level, moduleWidth, isProductionMode) {
40
- if (isProductionMode) {
41
- return;
42
- }
43
- ;
44
- let color = 'gray';
45
- if (level === Level.INFO) {
46
- color = 'deepskyblue';
47
- }
48
- if (level === Level.ERROR) {
49
- color = 'red';
50
- }
51
- if (level === Level.WARN) {
52
- color = 'orange';
53
- }
54
- if (moduleWidth) {
55
- const diff = moduleWidth - moduleName.length;
56
- if (diff > 0) {
57
- for (let i = 0; i < diff; i++) {
58
- moduleName += ' ';
59
- }
60
- }
61
- }
62
- //#region @browser
63
- if (Helpers.isBrowser
64
- /* */
65
- /* */
66
- ) {
67
- // @ts-ignore
68
- const isEdgeOrIe8orAbove = (document['documentMode'] || /Edge/.test(navigator.userAgent));
69
- if (isEdgeOrIe8orAbove) {
70
- if (typeof message === 'string') {
71
- let a1 = '[[ ' + moduleName + ' ]] ' + message + ' ';
72
- params.unshift(a1);
73
- }
74
- else {
75
- let a1 = '[[ ' + moduleName + ']] ';
76
- params.push(message);
77
- params.unshift(a1);
78
- }
79
- if (level === Level.INFO) {
80
- console.info.apply(console, params);
81
- }
82
- else if (level === Level.ERROR) {
83
- console.error.apply(console, params);
84
- }
85
- else if (level === Level.WARN) {
86
- console.warn.apply(console, params);
87
- }
88
- else {
89
- console.log.apply(console, params);
90
- }
91
- }
92
- else {
93
- if (typeof message === 'string') {
94
- let a1 = '%c ' + moduleName + ' %c ' + message + ' ';
95
- let a2 = 'background: ' + moduleColor + ';color:white; border: 1px solid ' + moduleColor + '; ';
96
- let a3 = 'border: 1px solid ' + color + '; ';
97
- params.unshift(a3);
98
- params.unshift(a2);
99
- params.unshift(a1);
100
- }
101
- else {
102
- let a1 = '%c ' + moduleName + ' ';
103
- let a2 = 'background: ' + moduleColor + ';color:white; border: 1px solid ' + color + '; ';
104
- params.push(message);
105
- params.unshift(a2);
106
- params.unshift(a1);
107
- }
108
- console.log.apply(console, params);
109
- }
110
- }
111
- //#endregion
112
- /* */
113
- /* */
114
- /* */
115
- /* */
116
- /* */
117
- /* */
118
- /* */
119
- /* */
120
- /* */
121
- /* */
122
- /* */
123
- /* */
124
- /* */
125
- /* */
126
- }
35
+ /* */
36
+ /* */
37
+ /* */
38
+ class Display {
39
+ static msg(message, params, moduleName, moduleColor, level, moduleWidth, isProductionMode) {
40
+ if (isProductionMode) {
41
+ return;
42
+ }
43
+ ;
44
+ let color = 'gray';
45
+ if (level === Level.INFO) {
46
+ color = 'deepskyblue';
47
+ }
48
+ if (level === Level.ERROR) {
49
+ color = 'red';
50
+ }
51
+ if (level === Level.WARN) {
52
+ color = 'orange';
53
+ }
54
+ if (moduleWidth) {
55
+ const diff = moduleWidth - moduleName.length;
56
+ if (diff > 0) {
57
+ for (let i = 0; i < diff; i++) {
58
+ moduleName += ' ';
59
+ }
60
+ }
61
+ }
62
+ //#region @browser
63
+ if (Helpers.isBrowser
64
+ /* */
65
+ /* */
66
+ ) {
67
+ // @ts-ignore
68
+ const isEdgeOrIe8orAbove = (document['documentMode'] || /Edge/.test(navigator.userAgent));
69
+ if (isEdgeOrIe8orAbove) {
70
+ if (typeof message === 'string') {
71
+ let a1 = '[[ ' + moduleName + ' ]] ' + message + ' ';
72
+ params.unshift(a1);
73
+ }
74
+ else {
75
+ let a1 = '[[ ' + moduleName + ']] ';
76
+ params.push(message);
77
+ params.unshift(a1);
78
+ }
79
+ if (level === Level.INFO) {
80
+ console.info.apply(console, params);
81
+ }
82
+ else if (level === Level.ERROR) {
83
+ console.error.apply(console, params);
84
+ }
85
+ else if (level === Level.WARN) {
86
+ console.warn.apply(console, params);
87
+ }
88
+ else {
89
+ console.log.apply(console, params);
90
+ }
91
+ }
92
+ else {
93
+ if (typeof message === 'string') {
94
+ let a1 = '%c ' + moduleName + ' %c ' + message + ' ';
95
+ let a2 = 'background: ' + moduleColor + ';color:white; border: 1px solid ' + moduleColor + '; ';
96
+ let a3 = 'border: 1px solid ' + color + '; ';
97
+ params.unshift(a3);
98
+ params.unshift(a2);
99
+ params.unshift(a1);
100
+ }
101
+ else {
102
+ let a1 = '%c ' + moduleName + ' ';
103
+ let a2 = 'background: ' + moduleColor + ';color:white; border: 1px solid ' + color + '; ';
104
+ params.push(message);
105
+ params.unshift(a2);
106
+ params.unshift(a1);
107
+ }
108
+ console.log.apply(console, params);
109
+ }
110
+ }
111
+ //#endregion
112
+ /* */
113
+ /* */
114
+ /* */
115
+ /* */
116
+ /* */
117
+ /* */
118
+ /* */
119
+ /* */
120
+ /* */
121
+ /* */
122
+ /* */
123
+ /* */
124
+ /* */
125
+ /* */
126
+ }
127
127
  }
128
128
 
129
- class Logger {
130
- constructor(name, color, developmentMode, allowed, isMuted, fixedWidth) {
131
- this.name = name;
132
- this.color = color;
133
- this.developmentMode = developmentMode;
134
- this.allowed = allowed;
135
- this.isMuted = isMuted;
136
- this.fixedWidth = fixedWidth;
137
- /** @deprecated Use data(...)
138
- * @see data
139
- */
140
- this.d = (name, ...data) => this._data(name, data);
141
- /** @deprecated Use error(...)
142
- * @see error
143
- */
144
- this.er = (name, ...data) => this._error(name, data);
145
- /** @deprecated Use info(...)
146
- * @see info
147
- */
148
- this.i = (name, ...data) => this._info(name, data);
149
- /** @deprecated Use warn(...)
150
- * @see warn
151
- */
152
- this.w = (name, ...data) => this._warn(name, data);
153
- /**
154
- * Logs message and data with the level=data
155
- * @param message The message
156
- * @param otherParams Additional parameters
157
- */
158
- this.data = (message, ...otherParams) => { return this._data(message, otherParams); };
159
- /**
160
- * Logs message and data with the level=error
161
- * @param message The message
162
- * @param otherParams Additional parameters
163
- */
164
- this.error = (message, ...otherParams) => this._error(message, otherParams);
165
- /**
166
- * Logs message and data with the level=info
167
- * @param message The message
168
- * @param otherParams Additional parameters
169
- */
170
- this.info = (message, ...otherParams) => this._info(message, otherParams);
171
- /**
172
- * Logs message and data with the level=success
173
- * @param message The message
174
- * @param otherParams Additional parameters
175
- */
176
- this.success = (message, ...otherParams) => this._success(message, otherParams);
177
- /**
178
- * Logs message and data with the level=taskStarted
179
- * @param message The message
180
- * @param otherParams Additional parameters
181
- */
182
- this.taskStarted = (message, ...otherParams) => this._taskStarted(message, otherParams);
183
- /**
184
- * Logs message and data with the level=taskDone
185
- * @param message The message
186
- * @param otherParams Additional parameters
187
- */
188
- this.taskDone = (message, ...otherParams) => this._taskDone(message, otherParams);
189
- /**
190
- * Logs message and data with the level=warn
191
- * @param message The message
192
- * @param otherParams Additional parameters
193
- */
194
- this.warn = (message, ...otherParams) => this._warn(message, otherParams);
195
- }
196
- setLevel(l) {
197
- this._level = l;
198
- return this;
199
- }
200
- get isProductionMode() {
201
- return !this.developmentMode;
202
- }
203
- setProductionMode(productionMode) {
204
- this.developmentMode = !productionMode;
205
- return this;
206
- }
207
- mute() {
208
- this.isMuted = true;
209
- return this;
210
- }
211
- onlyWhen(expression) {
212
- if (typeof expression === 'function') {
213
- this.isMuted = !expression();
214
- }
215
- else if (typeof expression === 'boolean') {
216
- this.isMuted = !expression;
217
- }
218
- }
219
- _data(name, ...data) {
220
- if (this.isMuted)
221
- return this;
222
- if (this.allowed.length >= 1 && Helpers.contain(this.allowed, Level.__NOTHING)
223
- && !Helpers.contain(this.allowed, Level.DATA))
224
- return this;
225
- if (this.allowed.length === 0 || Helpers.contain(this.allowed, Level.DATA)) {
226
- // @ts-ignore
227
- Display.msg.apply(void 0, [
228
- name,
229
- ...data,
230
- this.name,
231
- this.color,
232
- Level.DATA,
233
- this.fixedWidth,
234
- this.isProductionMode,
235
- ]);
236
- }
237
- return this;
238
- }
239
- _error(name, ...data) {
240
- if (this.isMuted)
241
- return this;
242
- if (this.allowed.length >= 1 && Helpers.contain(this.allowed, Level.__NOTHING)
243
- && !Helpers.contain(this.allowed, Level.ERROR))
244
- return this;
245
- if (this.allowed.length === 0 || Helpers.contain(this.allowed, Level.ERROR)) {
246
- // @ts-ignore
247
- Display.msg.apply(void 0, [
248
- name,
249
- ...data,
250
- this.name,
251
- this.color,
252
- Level.ERROR,
253
- this.fixedWidth,
254
- this.isProductionMode,
255
- ]);
256
- }
257
- return this;
258
- }
259
- _info(name, ...data) {
260
- if (this.isMuted)
261
- return this;
262
- if (this.allowed.length >= 1 && Helpers.contain(this.allowed, Level.__NOTHING)
263
- && !Helpers.contain(this.allowed, Level.INFO))
264
- return this;
265
- if (this.allowed.length === 0 || Helpers.contain(this.allowed, Level.INFO)) {
266
- // @ts-ignore
267
- Display.msg.apply(void 0, [
268
- name,
269
- ...data,
270
- this.name,
271
- this.color,
272
- Level.INFO,
273
- this.fixedWidth,
274
- this.isProductionMode,
275
- ]);
276
- }
277
- return this;
278
- }
279
- _success(name, ...data) {
280
- if (this.isMuted)
281
- return this;
282
- if (this.allowed.length >= 1 && Helpers.contain(this.allowed, Level.__NOTHING)
283
- && !Helpers.contain(this.allowed, Level.SUCCESS))
284
- return this;
285
- if (this.allowed.length === 0 || Helpers.contain(this.allowed, Level.SUCCESS)) {
286
- // @ts-ignore
287
- Display.msg.apply(void 0, [
288
- name,
289
- ...data,
290
- this.name,
291
- this.color,
292
- Level.SUCCESS,
293
- this.fixedWidth,
294
- this.isProductionMode,
295
- ]);
296
- }
297
- return this;
298
- }
299
- _taskStarted(name, ...data) {
300
- if (this.isMuted)
301
- return this;
302
- if (this.allowed.length >= 1 && Helpers.contain(this.allowed, Level.__NOTHING)
303
- && !Helpers.contain(this.allowed, Level.TASK_STARTED))
304
- return this;
305
- if (this.allowed.length === 0 || Helpers.contain(this.allowed, Level.TASK_STARTED)) {
306
- // @ts-ignore
307
- Display.msg.apply(void 0, [
308
- name,
309
- ...data,
310
- this.name,
311
- this.color,
312
- Level.TASK_STARTED,
313
- this.fixedWidth,
314
- this.isProductionMode,
315
- ]);
316
- }
317
- return this;
318
- }
319
- _taskDone(name, ...data) {
320
- if (this.isMuted)
321
- return this;
322
- if (this.allowed.length >= 1 && Helpers.contain(this.allowed, Level.__NOTHING)
323
- && !Helpers.contain(this.allowed, Level.TASK_DONE))
324
- return this;
325
- if (this.allowed.length === 0 || Helpers.contain(this.allowed, Level.TASK_DONE)) {
326
- // @ts-ignore
327
- Display.msg.apply(void 0, [
328
- name,
329
- ...data,
330
- this.name,
331
- this.color,
332
- Level.TASK_DONE,
333
- this.fixedWidth,
334
- this.isProductionMode,
335
- ]);
336
- }
337
- return this;
338
- }
339
- _warn(name, ...data) {
340
- if (this.isMuted)
341
- return this;
342
- if (this.allowed.length >= 1 && Helpers.contain(this.allowed, Level.__NOTHING)
343
- && !Helpers.contain(this.allowed, Level.WARN))
344
- return this;
345
- if (this.allowed.length === 0 || Helpers.contain(this.allowed, Level.WARN)) {
346
- // @ts-ignore
347
- Display.msg.apply(void 0, [
348
- name,
349
- ...data,
350
- this.name,
351
- this.color,
352
- Level.WARN,
353
- this.fixedWidth,
354
- this.isProductionMode,
355
- ]);
356
- }
357
- return this;
358
- }
129
+ class Logger {
130
+ constructor(name, color, developmentMode, allowed, isMuted, fixedWidth) {
131
+ this.name = name;
132
+ this.color = color;
133
+ this.developmentMode = developmentMode;
134
+ this.allowed = allowed;
135
+ this.isMuted = isMuted;
136
+ this.fixedWidth = fixedWidth;
137
+ /** @deprecated Use data(...)
138
+ * @see data
139
+ */
140
+ this.d = (name, ...data) => this._data(name, data);
141
+ /** @deprecated Use error(...)
142
+ * @see error
143
+ */
144
+ this.er = (name, ...data) => this._error(name, data);
145
+ /** @deprecated Use info(...)
146
+ * @see info
147
+ */
148
+ this.i = (name, ...data) => this._info(name, data);
149
+ /** @deprecated Use warn(...)
150
+ * @see warn
151
+ */
152
+ this.w = (name, ...data) => this._warn(name, data);
153
+ /**
154
+ * Logs message and data with the level=data
155
+ * @param message The message
156
+ * @param otherParams Additional parameters
157
+ */
158
+ this.data = (message, ...otherParams) => { return this._data(message, otherParams); };
159
+ /**
160
+ * Logs message and data with the level=error
161
+ * @param message The message
162
+ * @param otherParams Additional parameters
163
+ */
164
+ this.error = (message, ...otherParams) => this._error(message, otherParams);
165
+ /**
166
+ * Logs message and data with the level=info
167
+ * @param message The message
168
+ * @param otherParams Additional parameters
169
+ */
170
+ this.info = (message, ...otherParams) => this._info(message, otherParams);
171
+ /**
172
+ * Logs message and data with the level=success
173
+ * @param message The message
174
+ * @param otherParams Additional parameters
175
+ */
176
+ this.success = (message, ...otherParams) => this._success(message, otherParams);
177
+ /**
178
+ * Logs message and data with the level=taskStarted
179
+ * @param message The message
180
+ * @param otherParams Additional parameters
181
+ */
182
+ this.taskStarted = (message, ...otherParams) => this._taskStarted(message, otherParams);
183
+ /**
184
+ * Logs message and data with the level=taskDone
185
+ * @param message The message
186
+ * @param otherParams Additional parameters
187
+ */
188
+ this.taskDone = (message, ...otherParams) => this._taskDone(message, otherParams);
189
+ /**
190
+ * Logs message and data with the level=warn
191
+ * @param message The message
192
+ * @param otherParams Additional parameters
193
+ */
194
+ this.warn = (message, ...otherParams) => this._warn(message, otherParams);
195
+ }
196
+ setLevel(l) {
197
+ this._level = l;
198
+ return this;
199
+ }
200
+ get isProductionMode() {
201
+ return !this.developmentMode;
202
+ }
203
+ setProductionMode(productionMode) {
204
+ this.developmentMode = !productionMode;
205
+ return this;
206
+ }
207
+ mute() {
208
+ this.isMuted = true;
209
+ return this;
210
+ }
211
+ onlyWhen(expression) {
212
+ if (typeof expression === 'function') {
213
+ this.isMuted = !expression();
214
+ }
215
+ else if (typeof expression === 'boolean') {
216
+ this.isMuted = !expression;
217
+ }
218
+ }
219
+ _data(name, ...data) {
220
+ if (this.isMuted)
221
+ return this;
222
+ if (this.allowed.length >= 1 && Helpers.contain(this.allowed, Level.__NOTHING)
223
+ && !Helpers.contain(this.allowed, Level.DATA))
224
+ return this;
225
+ if (this.allowed.length === 0 || Helpers.contain(this.allowed, Level.DATA)) {
226
+ // @ts-ignore
227
+ Display.msg.apply(void 0, [
228
+ name,
229
+ ...data,
230
+ this.name,
231
+ this.color,
232
+ Level.DATA,
233
+ this.fixedWidth,
234
+ this.isProductionMode,
235
+ ]);
236
+ }
237
+ return this;
238
+ }
239
+ _error(name, ...data) {
240
+ if (this.isMuted)
241
+ return this;
242
+ if (this.allowed.length >= 1 && Helpers.contain(this.allowed, Level.__NOTHING)
243
+ && !Helpers.contain(this.allowed, Level.ERROR))
244
+ return this;
245
+ if (this.allowed.length === 0 || Helpers.contain(this.allowed, Level.ERROR)) {
246
+ // @ts-ignore
247
+ Display.msg.apply(void 0, [
248
+ name,
249
+ ...data,
250
+ this.name,
251
+ this.color,
252
+ Level.ERROR,
253
+ this.fixedWidth,
254
+ this.isProductionMode,
255
+ ]);
256
+ }
257
+ return this;
258
+ }
259
+ _info(name, ...data) {
260
+ if (this.isMuted)
261
+ return this;
262
+ if (this.allowed.length >= 1 && Helpers.contain(this.allowed, Level.__NOTHING)
263
+ && !Helpers.contain(this.allowed, Level.INFO))
264
+ return this;
265
+ if (this.allowed.length === 0 || Helpers.contain(this.allowed, Level.INFO)) {
266
+ // @ts-ignore
267
+ Display.msg.apply(void 0, [
268
+ name,
269
+ ...data,
270
+ this.name,
271
+ this.color,
272
+ Level.INFO,
273
+ this.fixedWidth,
274
+ this.isProductionMode,
275
+ ]);
276
+ }
277
+ return this;
278
+ }
279
+ _success(name, ...data) {
280
+ if (this.isMuted)
281
+ return this;
282
+ if (this.allowed.length >= 1 && Helpers.contain(this.allowed, Level.__NOTHING)
283
+ && !Helpers.contain(this.allowed, Level.SUCCESS))
284
+ return this;
285
+ if (this.allowed.length === 0 || Helpers.contain(this.allowed, Level.SUCCESS)) {
286
+ // @ts-ignore
287
+ Display.msg.apply(void 0, [
288
+ name,
289
+ ...data,
290
+ this.name,
291
+ this.color,
292
+ Level.SUCCESS,
293
+ this.fixedWidth,
294
+ this.isProductionMode,
295
+ ]);
296
+ }
297
+ return this;
298
+ }
299
+ _taskStarted(name, ...data) {
300
+ if (this.isMuted)
301
+ return this;
302
+ if (this.allowed.length >= 1 && Helpers.contain(this.allowed, Level.__NOTHING)
303
+ && !Helpers.contain(this.allowed, Level.TASK_STARTED))
304
+ return this;
305
+ if (this.allowed.length === 0 || Helpers.contain(this.allowed, Level.TASK_STARTED)) {
306
+ // @ts-ignore
307
+ Display.msg.apply(void 0, [
308
+ name,
309
+ ...data,
310
+ this.name,
311
+ this.color,
312
+ Level.TASK_STARTED,
313
+ this.fixedWidth,
314
+ this.isProductionMode,
315
+ ]);
316
+ }
317
+ return this;
318
+ }
319
+ _taskDone(name, ...data) {
320
+ if (this.isMuted)
321
+ return this;
322
+ if (this.allowed.length >= 1 && Helpers.contain(this.allowed, Level.__NOTHING)
323
+ && !Helpers.contain(this.allowed, Level.TASK_DONE))
324
+ return this;
325
+ if (this.allowed.length === 0 || Helpers.contain(this.allowed, Level.TASK_DONE)) {
326
+ // @ts-ignore
327
+ Display.msg.apply(void 0, [
328
+ name,
329
+ ...data,
330
+ this.name,
331
+ this.color,
332
+ Level.TASK_DONE,
333
+ this.fixedWidth,
334
+ this.isProductionMode,
335
+ ]);
336
+ }
337
+ return this;
338
+ }
339
+ _warn(name, ...data) {
340
+ if (this.isMuted)
341
+ return this;
342
+ if (this.allowed.length >= 1 && Helpers.contain(this.allowed, Level.__NOTHING)
343
+ && !Helpers.contain(this.allowed, Level.WARN))
344
+ return this;
345
+ if (this.allowed.length === 0 || Helpers.contain(this.allowed, Level.WARN)) {
346
+ // @ts-ignore
347
+ Display.msg.apply(void 0, [
348
+ name,
349
+ ...data,
350
+ this.name,
351
+ this.color,
352
+ Level.WARN,
353
+ this.fixedWidth,
354
+ this.isProductionMode,
355
+ ]);
356
+ }
357
+ return this;
358
+ }
359
359
  }
360
360
 
361
- /* */
362
- /* */
363
- /* */
364
- /* */
365
- /* */
366
- class Log {
367
- //#region singleton
368
- constructor() {
369
- this._logOnly = false;
370
- this._logModules = false;
371
- this.isDevelopmentMode = true;
372
- this.modeIsSet = false;
373
- this.fixedWidth = 0;
374
- this.instances = {};
375
- this.levels = [];
376
- this.modules = [];
377
- }
378
- // @ts-ignore
379
- static get instance() {
380
- // @ts-ignore
381
- if (!Log['_instance']) {
382
- // @ts-ignore
383
- Log['_instance'] = new Log();
384
- }
385
- // @ts-ignore
386
- return Log['_instance'];
387
- }
388
- static create(name, ...level) {
389
- return Log.instance.create(name, ...level);
390
- }
391
- static disableLogs(level = Level.__NOTHING) {
392
- /* */
393
- /* */
394
- /* */
395
- /* */
396
- /* */
397
- /* */
398
- /* */
399
- LevelOrder.reverse().find(a => {
400
- // @ts-ignore
401
- if (!this.consolelogfn[a]) {
402
- // @ts-ignore
403
- this.consolelogfn[a] = console[a];
404
- }
405
- // @ts-ignore
406
- console[a] = () => { };
407
- if (a === LevelKey[level]) {
408
- return true;
409
- }
410
- return false;
411
- });
412
- }
413
- static enableLogs() {
414
- /* */
415
- /* */
416
- /* */
417
- /* */
418
- LevelOrder.forEach(a => {
419
- // @ts-ignore
420
- console[a] = this.consolelogfn[a];
421
- });
422
- }
423
- //#region public api
424
- setProductionMode() {
425
- if (this.modeIsSet) {
426
- this.modeIsSet = false;
427
- throw '[ng2-logger] Production mode is already set';
428
- }
429
- else {
430
- this.modeIsSet = true;
431
- setTimeout(() => {
432
- if (this.modeIsSet && console !== void 0 && console.clear !== void 0) {
433
- console.clear();
434
- console.log = () => { };
435
- console.error = () => { };
436
- console.warn = () => { };
437
- console.info = () => { };
438
- }
439
- });
440
- this.isDevelopmentMode = false;
441
- }
442
- }
443
- onlyModules(...modules) {
444
- if (this._logModules) {
445
- throw '[ng2-logger] You should use funcion onlyModules only once';
446
- }
447
- if (!this._logModules) {
448
- this._logModules = true;
449
- }
450
- if (modules.length === 0)
451
- return;
452
- this.modules = modules;
453
- // console.log('only log this', Log.modules)
454
- this.muteAllOtherModules();
455
- }
456
- onlyLevel(...level) {
457
- if (this._logOnly) {
458
- throw '[ng2-logger] You should use funcion onlyLevel only once';
459
- }
460
- if (!this._logOnly) {
461
- this._logOnly = true;
462
- }
463
- this.levels = Array.isArray(level) ? level : [level];
464
- for (const logName in this.instances) {
465
- if (this.instances.hasOwnProperty(logName)) {
466
- const element = this.instances[logName];
467
- element['allowed'] = this.levels;
468
- }
469
- }
470
- }
471
- //#endregion
472
- create(name, ...level) {
473
- let i;
474
- if (Array.isArray(this.levels) && this.levels.length > 0) {
475
- level = this.levels;
476
- }
477
- if (this.instances[name] === void 0) {
478
- i = new (Log.Logger)(name, getRandomColor(), this.isDevelopmentMode, level, this.isMutedModule(name), this.levels.length > 0 ? this.fixedWidth : void 0);
479
- this.instances[name] = i;
480
- }
481
- else {
482
- i = this.instances[name];
483
- }
484
- return i;
485
- }
486
- isMutedModule(moduleName) {
487
- if (this.modules.length == 0)
488
- return false;
489
- if (!Helpers.contain(this.modules, moduleName))
490
- return true;
491
- return false;
492
- }
493
- muteAllOtherModules() {
494
- for (var moduleName in this.instances) {
495
- if (!Helpers.contain(this.modules, moduleName))
496
- this.instances[moduleName].mute();
497
- }
498
- }
499
- }
500
- //#endregion
501
- Log.Logger = Logger;
502
- Log.consolelogfn = {};
503
- function getRandomColor() {
504
- /* */
505
- /* */
506
- /* */
507
- /* */
508
- let letters = '012345'.split('');
509
- let color = '#';
510
- color += letters[Math.round(Math.random() * 5)];
511
- letters = '0123456789ABCDEF'.split('');
512
- for (let i = 0; i < 5; i++) {
513
- color += letters[Math.round(Math.random() * 15)];
514
- }
515
- if (color === void 0) {
516
- return getRandomColor();
517
- }
518
- ;
519
- return color;
361
+ /* */
362
+ /* */
363
+ /* */
364
+ /* */
365
+ /* */
366
+ class Log {
367
+ //#region singleton
368
+ constructor() {
369
+ this._logOnly = false;
370
+ this._logModules = false;
371
+ this.isDevelopmentMode = true;
372
+ this.modeIsSet = false;
373
+ this.fixedWidth = 0;
374
+ this.instances = {};
375
+ this.levels = [];
376
+ this.modules = [];
377
+ }
378
+ // @ts-ignore
379
+ static get instance() {
380
+ // @ts-ignore
381
+ if (!Log['_instance']) {
382
+ // @ts-ignore
383
+ Log['_instance'] = new Log();
384
+ }
385
+ // @ts-ignore
386
+ return Log['_instance'];
387
+ }
388
+ static create(name, ...level) {
389
+ return Log.instance.create(name, ...level);
390
+ }
391
+ static disableLogs(level = Level.__NOTHING) {
392
+ /* */
393
+ /* */
394
+ /* */
395
+ /* */
396
+ /* */
397
+ /* */
398
+ /* */
399
+ LevelOrder.reverse().find(a => {
400
+ // @ts-ignore
401
+ if (!this.consolelogfn[a]) {
402
+ // @ts-ignore
403
+ this.consolelogfn[a] = console[a];
404
+ }
405
+ // @ts-ignore
406
+ console[a] = () => { };
407
+ if (a === LevelKey[level]) {
408
+ return true;
409
+ }
410
+ return false;
411
+ });
412
+ }
413
+ static enableLogs() {
414
+ /* */
415
+ /* */
416
+ /* */
417
+ /* */
418
+ LevelOrder.forEach(a => {
419
+ // @ts-ignore
420
+ console[a] = this.consolelogfn[a];
421
+ });
422
+ }
423
+ //#region public api
424
+ setProductionMode() {
425
+ if (this.modeIsSet) {
426
+ this.modeIsSet = false;
427
+ throw '[ng2-logger] Production mode is already set';
428
+ }
429
+ else {
430
+ this.modeIsSet = true;
431
+ setTimeout(() => {
432
+ if (this.modeIsSet && console !== void 0 && console.clear !== void 0) {
433
+ console.clear();
434
+ console.log = () => { };
435
+ console.error = () => { };
436
+ console.warn = () => { };
437
+ console.info = () => { };
438
+ }
439
+ });
440
+ this.isDevelopmentMode = false;
441
+ }
442
+ }
443
+ onlyModules(...modules) {
444
+ if (this._logModules) {
445
+ throw '[ng2-logger] You should use funcion onlyModules only once';
446
+ }
447
+ if (!this._logModules) {
448
+ this._logModules = true;
449
+ }
450
+ if (modules.length === 0)
451
+ return;
452
+ this.modules = modules;
453
+ // console.log('only log this', Log.modules)
454
+ this.muteAllOtherModules();
455
+ }
456
+ onlyLevel(...level) {
457
+ if (this._logOnly) {
458
+ throw '[ng2-logger] You should use funcion onlyLevel only once';
459
+ }
460
+ if (!this._logOnly) {
461
+ this._logOnly = true;
462
+ }
463
+ this.levels = Array.isArray(level) ? level : [level];
464
+ for (const logName in this.instances) {
465
+ if (this.instances.hasOwnProperty(logName)) {
466
+ const element = this.instances[logName];
467
+ element['allowed'] = this.levels;
468
+ }
469
+ }
470
+ }
471
+ //#endregion
472
+ create(name, ...level) {
473
+ let i;
474
+ if (Array.isArray(this.levels) && this.levels.length > 0) {
475
+ level = this.levels;
476
+ }
477
+ if (this.instances[name] === void 0) {
478
+ i = new (Log.Logger)(name, getRandomColor(), this.isDevelopmentMode, level, this.isMutedModule(name), this.levels.length > 0 ? this.fixedWidth : void 0);
479
+ this.instances[name] = i;
480
+ }
481
+ else {
482
+ i = this.instances[name];
483
+ }
484
+ return i;
485
+ }
486
+ isMutedModule(moduleName) {
487
+ if (this.modules.length == 0)
488
+ return false;
489
+ if (!Helpers.contain(this.modules, moduleName))
490
+ return true;
491
+ return false;
492
+ }
493
+ muteAllOtherModules() {
494
+ for (var moduleName in this.instances) {
495
+ if (!Helpers.contain(this.modules, moduleName))
496
+ this.instances[moduleName].mute();
497
+ }
498
+ }
499
+ }
500
+ //#endregion
501
+ Log.Logger = Logger;
502
+ Log.consolelogfn = {};
503
+ function getRandomColor() {
504
+ /* */
505
+ /* */
506
+ /* */
507
+ /* */
508
+ let letters = '012345'.split('');
509
+ let color = '#';
510
+ color += letters[Math.round(Math.random() * 5)];
511
+ letters = '0123456789ABCDEF'.split('');
512
+ for (let i = 0; i < 5; i++) {
513
+ color += letters[Math.round(Math.random() * 15)];
514
+ }
515
+ if (color === void 0) {
516
+ return getRandomColor();
517
+ }
518
+ ;
519
+ return color;
520
520
  }
521
521
 
522
- /**
523
- * Generated bundle index. Do not edit.
522
+ /**
523
+ * Generated bundle index. Do not edit.
524
524
  */
525
525
 
526
526
  export { Display, Level, LevelKey, LevelOrder, Log, Logger };