ng2-logger 13.0.25 → 13.1.1

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