kerium 1.3.5 → 1.3.7
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/dist/log.js +10 -18
- package/package.json +4 -4
package/dist/log.js
CHANGED
|
@@ -87,16 +87,8 @@ export function deprecated(symbol) {
|
|
|
87
87
|
function ansi(text, format) {
|
|
88
88
|
return `\x1b[${format}m${text}\x1b[0m`;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
91
|
-
|
|
92
|
-
switch (style) {
|
|
93
|
-
case 'ansi':
|
|
94
|
-
return [ansi(text, '2;37')];
|
|
95
|
-
case 'css':
|
|
96
|
-
return ['%c' + text, 'opacity: 0.8; color: white;'];
|
|
97
|
-
default:
|
|
98
|
-
return [text];
|
|
99
|
-
}
|
|
90
|
+
function timestamp(entry) {
|
|
91
|
+
return '[' + (entry.elapsedMs / 1000).toFixed(3).padStart(10) + '] ';
|
|
100
92
|
}
|
|
101
93
|
const levelColor = {
|
|
102
94
|
ansi: {
|
|
@@ -148,26 +140,26 @@ const messageColor = {
|
|
|
148
140
|
*/
|
|
149
141
|
export function fancy({ style, colorize }) {
|
|
150
142
|
return function* (entry) {
|
|
151
|
-
|
|
143
|
+
if (style == 'css')
|
|
144
|
+
yield colorize == 'level' ? '%c%s %c%s' : '%c%s %c%s%s %c%s';
|
|
145
|
+
yield* style == 'ansi' ? [ansi(timestamp(entry), '2;37')] : ['opacity: 0.8; color: white;', timestamp(entry)];
|
|
152
146
|
const levelText = style == 'ansi'
|
|
153
147
|
? [ansi(levels[entry.level].toUpperCase(), levelColor.ansi[entry.level])]
|
|
154
|
-
: [
|
|
148
|
+
: [levelColor.css[entry.level], levels[entry.level].toUpperCase()];
|
|
155
149
|
if (colorize == 'level') {
|
|
156
150
|
yield* levelText;
|
|
157
151
|
yield entry.message;
|
|
158
152
|
return;
|
|
159
153
|
}
|
|
160
|
-
if (entry.level < Level.CRIT)
|
|
154
|
+
if (entry.level < Level.CRIT)
|
|
161
155
|
yield* levelText;
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
if (colorize == 'message')
|
|
156
|
+
if (style == 'ansi')
|
|
165
157
|
yield ansi(entry.message, messageColor.ansi[entry.level]);
|
|
166
158
|
else
|
|
167
|
-
yield* [
|
|
159
|
+
yield* [messageColor.css[entry.level], entry.message];
|
|
168
160
|
};
|
|
169
161
|
}
|
|
170
|
-
let _format = (entry) => [
|
|
162
|
+
let _format = (entry) => [timestamp(entry), entry.message];
|
|
171
163
|
export function format(entry) {
|
|
172
164
|
const formatted = _format(entry);
|
|
173
165
|
return typeof formatted == 'string' ? [formatted] : Array.from(formatted);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kerium",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.7",
|
|
4
4
|
"description": "POSIX-style errors, logging, and more",
|
|
5
5
|
"author": "James Prevett <jp@jamespre.dev> (https://jamespre.dev)",
|
|
6
6
|
"repository": {
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"eslint": "^9.12.0",
|
|
40
40
|
"prettier": "^3.2.5",
|
|
41
41
|
"tsx": "^4.19.1",
|
|
42
|
-
"typedoc": "^0.
|
|
43
|
-
"typescript": "^5.
|
|
44
|
-
"typescript-eslint": "^8.
|
|
42
|
+
"typedoc": "^0.28.14",
|
|
43
|
+
"typescript": "^5.9.3",
|
|
44
|
+
"typescript-eslint": "^8.46.1"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"utilium": "^2.0.0"
|