ng2-logger 13.1.15 → 13.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +192 -192
- package/app/index.d.ts +4 -4
- package/app/ng2-logger.component.d.ts +5 -5
- package/app/ng2-logger.module.d.ts +2 -2
- package/browser/README.md +24 -24
- package/browser/esm2020/lib/backend-logging.mjs +93 -93
- package/browser/esm2020/lib/display.mjs +96 -96
- package/browser/esm2020/lib/index.mjs +6 -6
- package/browser/esm2020/lib/level.mjs +32 -32
- package/browser/esm2020/lib/log.mjs +160 -160
- package/browser/esm2020/lib/logger.mjs +236 -236
- package/browser/esm2020/ng2-logger.mjs +4 -4
- package/browser/esm2020/public-api.mjs +1 -1
- package/browser/fesm2015/ng2-logger.mjs +514 -514
- package/browser/fesm2020/ng2-logger.mjs +514 -514
- package/browser/lib/backend-logging.d.ts +3 -3
- package/browser/lib/display.d.ts +3 -3
- package/browser/lib/index.d.ts +3 -3
- package/browser/lib/level.d.ts +20 -20
- package/browser/lib/log.d.ts +24 -24
- package/browser/lib/logger.d.ts +80 -80
- package/browser/ng2-logger.d.ts +4 -4
- package/client/README.md +24 -24
- package/client/esm2020/lib/backend-logging.mjs +93 -93
- package/client/esm2020/lib/display.mjs +96 -96
- package/client/esm2020/lib/index.mjs +6 -6
- package/client/esm2020/lib/level.mjs +32 -32
- package/client/esm2020/lib/log.mjs +160 -160
- package/client/esm2020/lib/logger.mjs +236 -236
- package/client/esm2020/ng2-logger.mjs +4 -4
- package/client/esm2020/public-api.mjs +1 -1
- package/client/fesm2015/ng2-logger.mjs +514 -514
- package/client/fesm2020/ng2-logger.mjs +514 -514
- package/client/lib/backend-logging.d.ts +3 -3
- package/client/lib/display.d.ts +3 -3
- package/client/lib/index.d.ts +3 -3
- package/client/lib/level.d.ts +20 -20
- package/client/lib/log.d.ts +24 -24
- package/client/lib/logger.d.ts +80 -80
- package/client/ng2-logger.d.ts +4 -4
- package/index.d.ts +1 -1
- package/lib/backend-logging.d.ts +4 -4
- package/lib/display.d.ts +4 -4
- package/lib/index.d.ts +4 -4
- package/lib/level.d.ts +21 -21
- package/lib/log.d.ts +25 -25
- package/lib/logger.d.ts +81 -81
- package/package.json +3 -3
- package/package.json_devDependencies.json +184 -184
- package/package.json_tnp.json5 +51 -51
- package/tmp-environment.json +35 -38
- package/websql/README.md +24 -24
- package/websql/esm2020/lib/backend-logging.mjs +93 -93
- package/websql/esm2020/lib/display.mjs +96 -96
- package/websql/esm2020/lib/index.mjs +6 -6
- package/websql/esm2020/lib/level.mjs +32 -32
- package/websql/esm2020/lib/log.mjs +160 -160
- package/websql/esm2020/lib/logger.mjs +236 -236
- package/websql/esm2020/ng2-logger.mjs +4 -4
- package/websql/esm2020/public-api.mjs +1 -1
- package/websql/fesm2015/ng2-logger.mjs +514 -514
- package/websql/fesm2020/ng2-logger.mjs +514 -514
- package/websql/lib/backend-logging.d.ts +3 -3
- package/websql/lib/display.d.ts +3 -3
- package/websql/lib/index.d.ts +3 -3
- package/websql/lib/level.d.ts +20 -20
- package/websql/lib/log.d.ts +24 -24
- package/websql/lib/logger.d.ts +80 -80
- package/websql/ng2-logger.d.ts +4 -4
|
@@ -1,529 +1,529 @@
|
|
|
1
1
|
import { Helpers } from 'tnp-core/browser';
|
|
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
|
+
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
|
+
;
|
|
128
128
|
({}); // @--end-of-file-for-module=ng2-logger lib/display.ts
|
|
129
129
|
|
|
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
|
-
/** @deprecated Use data(...)
|
|
139
|
-
* @see data
|
|
140
|
-
*/
|
|
141
|
-
this.d = (name, ...data) => this._data(name, data);
|
|
142
|
-
/** @deprecated Use error(...)
|
|
143
|
-
* @see error
|
|
144
|
-
*/
|
|
145
|
-
this.er = (name, ...data) => this._error(name, data);
|
|
146
|
-
/** @deprecated Use info(...)
|
|
147
|
-
* @see info
|
|
148
|
-
*/
|
|
149
|
-
this.i = (name, ...data) => this._info(name, data);
|
|
150
|
-
/** @deprecated Use warn(...)
|
|
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
|
-
;
|
|
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
|
+
/** @deprecated Use data(...)
|
|
139
|
+
* @see data
|
|
140
|
+
*/
|
|
141
|
+
this.d = (name, ...data) => this._data(name, data);
|
|
142
|
+
/** @deprecated Use error(...)
|
|
143
|
+
* @see error
|
|
144
|
+
*/
|
|
145
|
+
this.er = (name, ...data) => this._error(name, data);
|
|
146
|
+
/** @deprecated Use info(...)
|
|
147
|
+
* @see info
|
|
148
|
+
*/
|
|
149
|
+
this.i = (name, ...data) => this._info(name, data);
|
|
150
|
+
/** @deprecated Use warn(...)
|
|
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
|
+
;
|
|
362
362
|
({}); // @--end-of-file-for-module=ng2-logger lib/logger.ts
|
|
363
363
|
|
|
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
|
-
;
|
|
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
|
+
;
|
|
520
520
|
({}); // @--end-of-file-for-module=ng2-logger lib/log.ts
|
|
521
521
|
|
|
522
|
-
;
|
|
522
|
+
;
|
|
523
523
|
({}); // @--end-of-file-for-module=ng2-logger lib/index.ts
|
|
524
524
|
|
|
525
|
-
/**
|
|
526
|
-
* Generated bundle index. Do not edit.
|
|
525
|
+
/**
|
|
526
|
+
* Generated bundle index. Do not edit.
|
|
527
527
|
*/
|
|
528
528
|
|
|
529
529
|
export { Display, Level, LevelKey, LevelOrder, Log, Logger };
|