@fend/firo 0.0.3 → 0.0.4
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 +7 -0
- package/dist/index.cjs +8 -6
- package/dist/index.js +8 -6
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# firo 🌲
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@fend/firo)
|
|
4
|
+
[](https://jsr.io/@fend/firo)
|
|
5
|
+
[](https://jsr.io/@fend/firo/score)
|
|
6
|
+
[](https://github.com/fend25/firo/blob/main/README.md)
|
|
7
|
+
[](https://github.com/fend25/firo/actions/workflows/publish.yml)
|
|
8
|
+
[](https://github.com/fend25/firo)
|
|
9
|
+
|
|
3
10
|
**Spruce up your logs!**
|
|
4
11
|
|
|
5
12
|
The logger for Node.js, Bun and Deno you've been looking for.
|
package/dist/index.cjs
CHANGED
|
@@ -82,9 +82,9 @@ var COLORS_LIST = Object.values(FIRO_COLORS);
|
|
|
82
82
|
var SAFE_COLORS_COUNT = 10;
|
|
83
83
|
var getColorIndex = (str, useAllColors = false) => {
|
|
84
84
|
let hash = 0;
|
|
85
|
-
str.
|
|
86
|
-
hash =
|
|
87
|
-
}
|
|
85
|
+
for (let i = 0, len = str.length; i < len; i++) {
|
|
86
|
+
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
|
87
|
+
}
|
|
88
88
|
const range = useAllColors ? COLORS_LIST.length : SAFE_COLORS_COUNT;
|
|
89
89
|
return Math.abs(hash % range);
|
|
90
90
|
};
|
|
@@ -154,9 +154,10 @@ var createDevTransport = (config = {}) => {
|
|
|
154
154
|
};
|
|
155
155
|
return transport;
|
|
156
156
|
};
|
|
157
|
+
var jsonReplacer = (_key, value) => typeof value === "bigint" ? value.toString() : value;
|
|
157
158
|
var safeStringify = (obj) => {
|
|
158
159
|
try {
|
|
159
|
-
return JSON.stringify(obj);
|
|
160
|
+
return JSON.stringify(obj, jsonReplacer);
|
|
160
161
|
} catch {
|
|
161
162
|
return (0, import_node_util.inspect)(obj);
|
|
162
163
|
}
|
|
@@ -211,11 +212,11 @@ var createJsonTransport = () => {
|
|
|
211
212
|
const record = buildRecord(level, context, msg, data);
|
|
212
213
|
let line;
|
|
213
214
|
try {
|
|
214
|
-
line = JSON.stringify(record) + "\n";
|
|
215
|
+
line = JSON.stringify(record, jsonReplacer) + "\n";
|
|
215
216
|
} catch {
|
|
216
217
|
if (record.data) record.data = (0, import_node_util.inspect)(record.data);
|
|
217
218
|
try {
|
|
218
|
-
line = JSON.stringify(record) + "\n";
|
|
219
|
+
line = JSON.stringify(record, jsonReplacer) + "\n";
|
|
219
220
|
} catch {
|
|
220
221
|
line = JSON.stringify({
|
|
221
222
|
timestamp: record.timestamp,
|
|
@@ -306,6 +307,7 @@ var createLoggerInternal = (config, parentContext) => {
|
|
|
306
307
|
child,
|
|
307
308
|
addContext,
|
|
308
309
|
getContext,
|
|
310
|
+
hasInContext,
|
|
309
311
|
removeFromContext: removeKeyFromContext
|
|
310
312
|
});
|
|
311
313
|
};
|
package/dist/index.js
CHANGED
|
@@ -43,9 +43,9 @@ var COLORS_LIST = Object.values(FIRO_COLORS);
|
|
|
43
43
|
var SAFE_COLORS_COUNT = 10;
|
|
44
44
|
var getColorIndex = (str, useAllColors = false) => {
|
|
45
45
|
let hash = 0;
|
|
46
|
-
str.
|
|
47
|
-
hash =
|
|
48
|
-
}
|
|
46
|
+
for (let i = 0, len = str.length; i < len; i++) {
|
|
47
|
+
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
|
48
|
+
}
|
|
49
49
|
const range = useAllColors ? COLORS_LIST.length : SAFE_COLORS_COUNT;
|
|
50
50
|
return Math.abs(hash % range);
|
|
51
51
|
};
|
|
@@ -115,9 +115,10 @@ var createDevTransport = (config = {}) => {
|
|
|
115
115
|
};
|
|
116
116
|
return transport;
|
|
117
117
|
};
|
|
118
|
+
var jsonReplacer = (_key, value) => typeof value === "bigint" ? value.toString() : value;
|
|
118
119
|
var safeStringify = (obj) => {
|
|
119
120
|
try {
|
|
120
|
-
return JSON.stringify(obj);
|
|
121
|
+
return JSON.stringify(obj, jsonReplacer);
|
|
121
122
|
} catch {
|
|
122
123
|
return inspect(obj);
|
|
123
124
|
}
|
|
@@ -172,11 +173,11 @@ var createJsonTransport = () => {
|
|
|
172
173
|
const record = buildRecord(level, context, msg, data);
|
|
173
174
|
let line;
|
|
174
175
|
try {
|
|
175
|
-
line = JSON.stringify(record) + "\n";
|
|
176
|
+
line = JSON.stringify(record, jsonReplacer) + "\n";
|
|
176
177
|
} catch {
|
|
177
178
|
if (record.data) record.data = inspect(record.data);
|
|
178
179
|
try {
|
|
179
|
-
line = JSON.stringify(record) + "\n";
|
|
180
|
+
line = JSON.stringify(record, jsonReplacer) + "\n";
|
|
180
181
|
} catch {
|
|
181
182
|
line = JSON.stringify({
|
|
182
183
|
timestamp: record.timestamp,
|
|
@@ -267,6 +268,7 @@ var createLoggerInternal = (config, parentContext) => {
|
|
|
267
268
|
child,
|
|
268
269
|
addContext,
|
|
269
270
|
getContext,
|
|
271
|
+
hasInContext,
|
|
270
272
|
removeFromContext: removeKeyFromContext
|
|
271
273
|
});
|
|
272
274
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fend/firo",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Elegant logger for Node.js, Bun and Deno with brilliant DX.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"firo",
|
|
@@ -37,13 +37,6 @@
|
|
|
37
37
|
"files": [
|
|
38
38
|
"dist"
|
|
39
39
|
],
|
|
40
|
-
"scripts": {
|
|
41
|
-
"build": "tsup",
|
|
42
|
-
"test": "node --import tsx --test test/*.test.ts",
|
|
43
|
-
"check": "tsc --noEmit && node --import tsx --test test/*.test.ts",
|
|
44
|
-
"typecheck": "tsc --noEmit",
|
|
45
|
-
"demo": "tsx demo.ts"
|
|
46
|
-
},
|
|
47
40
|
"engines": {
|
|
48
41
|
"node": ">=16"
|
|
49
42
|
},
|
|
@@ -52,5 +45,12 @@
|
|
|
52
45
|
"tsup": "^8.5.1",
|
|
53
46
|
"tsx": "^4.0.0",
|
|
54
47
|
"typescript": "^5.9.3"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsup",
|
|
51
|
+
"test": "node --import tsx --test test/*.test.ts",
|
|
52
|
+
"check": "tsc --noEmit && node --import tsx --test test/*.test.ts",
|
|
53
|
+
"typecheck": "tsc --noEmit",
|
|
54
|
+
"demo": "tsx demo.ts"
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
}
|