@foxford/logger 1.2.2 → 1.2.3
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/browser.js +19 -19
- package/browser.mjs +19 -19
- package/package.json +4 -3
package/browser.js
CHANGED
|
@@ -31,7 +31,7 @@ function generateHexByString(str) {
|
|
|
31
31
|
const rValue = r != null ? r : 0;
|
|
32
32
|
const gValue = g != null ? g : 0;
|
|
33
33
|
const bValue = b != null ? b : 0;
|
|
34
|
-
const color =
|
|
34
|
+
const color = "#".concat((rValue << 16 | gValue << 8 | bValue).toString(16).padStart(6, "0"));
|
|
35
35
|
return color;
|
|
36
36
|
}
|
|
37
37
|
const DEBUG_LC_KEY = "debug";
|
|
@@ -80,29 +80,29 @@ function setDebugValue(value) {
|
|
|
80
80
|
}
|
|
81
81
|
function formatter(level, name, timestamp) {
|
|
82
82
|
const baseStyle = "font-weight: bold;";
|
|
83
|
-
const date =
|
|
83
|
+
const date = "".concat(timestamp.toLocaleDateString(), " ").concat(timestamp.toLocaleTimeString());
|
|
84
84
|
let dateStyle;
|
|
85
85
|
let levelStyle;
|
|
86
86
|
let nameStyle;
|
|
87
87
|
switch (name) {
|
|
88
88
|
// предустановленнный цветовой шаблон по имени логгера
|
|
89
89
|
case "critical":
|
|
90
|
-
dateStyle =
|
|
91
|
-
levelStyle =
|
|
92
|
-
nameStyle =
|
|
90
|
+
dateStyle = "color: ".concat(levelColors.ERROR, ";");
|
|
91
|
+
levelStyle = "color: ".concat(levelColors.ERROR, ";");
|
|
92
|
+
nameStyle = "color: ".concat(levelColors.ERROR, ";");
|
|
93
93
|
break;
|
|
94
94
|
default:
|
|
95
|
-
dateStyle =
|
|
96
|
-
levelStyle =
|
|
97
|
-
nameStyle =
|
|
95
|
+
dateStyle = "color: #6C757D;";
|
|
96
|
+
levelStyle = "color: ".concat(levelColors[level], ";");
|
|
97
|
+
nameStyle = "color: ".concat(stringToColorCode(name), ";");
|
|
98
98
|
break;
|
|
99
99
|
}
|
|
100
100
|
return [
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
"%c[".concat(date, "] %c[").concat(level, "] %c[").concat(name, "] %c•"),
|
|
102
|
+
"".concat(baseStyle, " ").concat(dateStyle),
|
|
103
|
+
"".concat(baseStyle, " ").concat(levelStyle),
|
|
104
|
+
"".concat(baseStyle, " ").concat(nameStyle),
|
|
105
|
+
"color: white"
|
|
106
106
|
];
|
|
107
107
|
}
|
|
108
108
|
const environment = {
|
|
@@ -158,7 +158,7 @@ function createHierarchicalLogger(originalGetLogger, fullName, parent) {
|
|
|
158
158
|
return this.name;
|
|
159
159
|
}
|
|
160
160
|
const parentFullName = this.parent.getFullName();
|
|
161
|
-
return parentFullName ?
|
|
161
|
+
return parentFullName ? "".concat(parentFullName, ":").concat(this.name) : this.name;
|
|
162
162
|
},
|
|
163
163
|
getLogger(name2) {
|
|
164
164
|
for (const child of this.children) {
|
|
@@ -166,7 +166,7 @@ function createHierarchicalLogger(originalGetLogger, fullName, parent) {
|
|
|
166
166
|
return child;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
const childLogger = createHierarchicalLogger(originalGetLogger,
|
|
169
|
+
const childLogger = createHierarchicalLogger(originalGetLogger, "".concat(fullName, ":").concat(name2), this);
|
|
170
170
|
this.children.add(childLogger);
|
|
171
171
|
return childLogger;
|
|
172
172
|
},
|
|
@@ -186,8 +186,8 @@ function createHierarchicalLogger(originalGetLogger, fullName, parent) {
|
|
|
186
186
|
previousLevels.set(this.id, baseLogger.getLevel());
|
|
187
187
|
}
|
|
188
188
|
baseLogger.setLevel(log.levels.TRACE, false);
|
|
189
|
-
if (!currentPatterns.some((pattern) => fullName2 === pattern ||
|
|
190
|
-
const childrenPatterns = currentPatterns.filter((pattern) => pattern.startsWith(
|
|
189
|
+
if (!currentPatterns.some((pattern) => fullName2 === pattern || "".concat(fullName2, ":*") === pattern)) {
|
|
190
|
+
const childrenPatterns = currentPatterns.filter((pattern) => pattern.startsWith("".concat(fullName2, ":")));
|
|
191
191
|
childrenPatterns.forEach((pattern) => {
|
|
192
192
|
const index = currentPatterns.indexOf(pattern);
|
|
193
193
|
if (index !== -1) {
|
|
@@ -205,7 +205,7 @@ function createHierarchicalLogger(originalGetLogger, fullName, parent) {
|
|
|
205
205
|
}
|
|
206
206
|
baseLogger.setLevel(newLevel, false);
|
|
207
207
|
previousLevels.delete(this.id);
|
|
208
|
-
const index = currentPatterns.findIndex((pattern) => pattern === fullName2 || pattern ===
|
|
208
|
+
const index = currentPatterns.findIndex((pattern) => pattern === fullName2 || pattern === "".concat(fullName2, ":*"));
|
|
209
209
|
if (index !== -1) {
|
|
210
210
|
currentPatterns.splice(index, 1);
|
|
211
211
|
}
|
|
@@ -317,7 +317,7 @@ const hierarchicalPlugin = {
|
|
|
317
317
|
}
|
|
318
318
|
};
|
|
319
319
|
const defaultOptions = {
|
|
320
|
-
format: (level, name, timestamp) =>
|
|
320
|
+
format: (level, name, timestamp) => "[".concat(timestamp.toISOString(), "] [").concat(level, "] [").concat(name, "]")
|
|
321
321
|
};
|
|
322
322
|
function prefix(logger, options = {}) {
|
|
323
323
|
const mergedOptions = { ...defaultOptions, ...options };
|
package/browser.mjs
CHANGED
|
@@ -29,7 +29,7 @@ function generateHexByString(str) {
|
|
|
29
29
|
const rValue = r != null ? r : 0;
|
|
30
30
|
const gValue = g != null ? g : 0;
|
|
31
31
|
const bValue = b != null ? b : 0;
|
|
32
|
-
const color =
|
|
32
|
+
const color = "#".concat((rValue << 16 | gValue << 8 | bValue).toString(16).padStart(6, "0"));
|
|
33
33
|
return color;
|
|
34
34
|
}
|
|
35
35
|
const DEBUG_LC_KEY = "debug";
|
|
@@ -78,29 +78,29 @@ function setDebugValue(value) {
|
|
|
78
78
|
}
|
|
79
79
|
function formatter(level, name, timestamp) {
|
|
80
80
|
const baseStyle = "font-weight: bold;";
|
|
81
|
-
const date =
|
|
81
|
+
const date = "".concat(timestamp.toLocaleDateString(), " ").concat(timestamp.toLocaleTimeString());
|
|
82
82
|
let dateStyle;
|
|
83
83
|
let levelStyle;
|
|
84
84
|
let nameStyle;
|
|
85
85
|
switch (name) {
|
|
86
86
|
// предустановленнный цветовой шаблон по имени логгера
|
|
87
87
|
case "critical":
|
|
88
|
-
dateStyle =
|
|
89
|
-
levelStyle =
|
|
90
|
-
nameStyle =
|
|
88
|
+
dateStyle = "color: ".concat(levelColors.ERROR, ";");
|
|
89
|
+
levelStyle = "color: ".concat(levelColors.ERROR, ";");
|
|
90
|
+
nameStyle = "color: ".concat(levelColors.ERROR, ";");
|
|
91
91
|
break;
|
|
92
92
|
default:
|
|
93
|
-
dateStyle =
|
|
94
|
-
levelStyle =
|
|
95
|
-
nameStyle =
|
|
93
|
+
dateStyle = "color: #6C757D;";
|
|
94
|
+
levelStyle = "color: ".concat(levelColors[level], ";");
|
|
95
|
+
nameStyle = "color: ".concat(stringToColorCode(name), ";");
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
98
|
return [
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
"%c[".concat(date, "] %c[").concat(level, "] %c[").concat(name, "] %c•"),
|
|
100
|
+
"".concat(baseStyle, " ").concat(dateStyle),
|
|
101
|
+
"".concat(baseStyle, " ").concat(levelStyle),
|
|
102
|
+
"".concat(baseStyle, " ").concat(nameStyle),
|
|
103
|
+
"color: white"
|
|
104
104
|
];
|
|
105
105
|
}
|
|
106
106
|
const environment = {
|
|
@@ -156,7 +156,7 @@ function createHierarchicalLogger(originalGetLogger, fullName, parent) {
|
|
|
156
156
|
return this.name;
|
|
157
157
|
}
|
|
158
158
|
const parentFullName = this.parent.getFullName();
|
|
159
|
-
return parentFullName ?
|
|
159
|
+
return parentFullName ? "".concat(parentFullName, ":").concat(this.name) : this.name;
|
|
160
160
|
},
|
|
161
161
|
getLogger(name2) {
|
|
162
162
|
for (const child of this.children) {
|
|
@@ -164,7 +164,7 @@ function createHierarchicalLogger(originalGetLogger, fullName, parent) {
|
|
|
164
164
|
return child;
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
const childLogger = createHierarchicalLogger(originalGetLogger,
|
|
167
|
+
const childLogger = createHierarchicalLogger(originalGetLogger, "".concat(fullName, ":").concat(name2), this);
|
|
168
168
|
this.children.add(childLogger);
|
|
169
169
|
return childLogger;
|
|
170
170
|
},
|
|
@@ -184,8 +184,8 @@ function createHierarchicalLogger(originalGetLogger, fullName, parent) {
|
|
|
184
184
|
previousLevels.set(this.id, baseLogger.getLevel());
|
|
185
185
|
}
|
|
186
186
|
baseLogger.setLevel(log.levels.TRACE, false);
|
|
187
|
-
if (!currentPatterns.some((pattern) => fullName2 === pattern ||
|
|
188
|
-
const childrenPatterns = currentPatterns.filter((pattern) => pattern.startsWith(
|
|
187
|
+
if (!currentPatterns.some((pattern) => fullName2 === pattern || "".concat(fullName2, ":*") === pattern)) {
|
|
188
|
+
const childrenPatterns = currentPatterns.filter((pattern) => pattern.startsWith("".concat(fullName2, ":")));
|
|
189
189
|
childrenPatterns.forEach((pattern) => {
|
|
190
190
|
const index = currentPatterns.indexOf(pattern);
|
|
191
191
|
if (index !== -1) {
|
|
@@ -203,7 +203,7 @@ function createHierarchicalLogger(originalGetLogger, fullName, parent) {
|
|
|
203
203
|
}
|
|
204
204
|
baseLogger.setLevel(newLevel, false);
|
|
205
205
|
previousLevels.delete(this.id);
|
|
206
|
-
const index = currentPatterns.findIndex((pattern) => pattern === fullName2 || pattern ===
|
|
206
|
+
const index = currentPatterns.findIndex((pattern) => pattern === fullName2 || pattern === "".concat(fullName2, ":*"));
|
|
207
207
|
if (index !== -1) {
|
|
208
208
|
currentPatterns.splice(index, 1);
|
|
209
209
|
}
|
|
@@ -315,7 +315,7 @@ const hierarchicalPlugin = {
|
|
|
315
315
|
}
|
|
316
316
|
};
|
|
317
317
|
const defaultOptions = {
|
|
318
|
-
format: (level, name, timestamp) =>
|
|
318
|
+
format: (level, name, timestamp) => "[".concat(timestamp.toISOString(), "] [").concat(level, "] [").concat(name, "]")
|
|
319
319
|
};
|
|
320
320
|
function prefix(logger, options = {}) {
|
|
321
321
|
const mergedOptions = { ...defaultOptions, ...options };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foxford/logger",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Foxford logger",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"foxford",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"bugs": "https://github.com/foxford/frontend-platform/issues",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/foxford/frontend-platform.git"
|
|
13
|
+
"url": "git+https://github.com/foxford/frontend-platform.git",
|
|
14
|
+
"directory": "packages/logger"
|
|
14
15
|
},
|
|
15
16
|
"license": "MIT",
|
|
16
17
|
"author": "Foxford Co",
|
|
@@ -52,6 +53,6 @@
|
|
|
52
53
|
],
|
|
53
54
|
"peerDependencies": {},
|
|
54
55
|
"sideEffects": false,
|
|
55
|
-
"sha": "
|
|
56
|
+
"sha": "6bf9ff8",
|
|
56
57
|
"scripts": {}
|
|
57
58
|
}
|