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