@holz/console-backend 0.8.2 → 0.8.3-rc.154
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/holz-console-backend.cjs +1 -1
- package/dist/holz-console-backend.js +85 -63
- package/dist/src/__tests__/console-backend.test.d.ts +1 -0
- package/dist/src/__tests__/time-delta.test.d.ts +1 -0
- package/dist/{holz-console-backend.d.ts → src/console-backend.d.ts} +18 -22
- package/dist/src/index.d.ts +1 -0
- package/dist/src/time-delta.d.ts +6 -0
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e={fatal:60,error:50,warn:40,info:30,debug:20,trace:10},t=(n,r)=>{let i=(e,t,i={})=>{n({timestamp:Date.now(),message:t,level:e,origin:r,context:i})},a={owner:r,trace:i.bind(null,e.trace),debug:i.bind(null,e.debug),info:i.bind(null,e.info),warn:i.bind(null,e.warn),error:i.bind(null,e.error),fatal:i.bind(null,e.fatal),namespace:e=>t(n,r.concat(e)),withMiddleware:e=>t(e(n),r)},o={configurable:!1,enumerable:!1};return Object.defineProperties(a,{withMiddleware:o,namespace:o,trace:o,debug:o,info:o,warn:o,error:o,fatal:o})},n=1e3,r=60*n,i=60*r,a=24*i,o=(e,t=e)=>{let o=e.getTime()-t.getTime(),s=Math.abs(o),c=o<0?``:`+`;return s>=a?`${c}${Math.round(o/a)}d`:s>=i?`${c}${Math.round(o/i)}h`:s>=r?`${c}${Math.round(o/r)}m`:s>=n?`${c}${Math.round(o/n)}s`:`${c}${o}ms`},s=(e={})=>{let t=e.console??console,n;return e=>{let r=new Date(e.timestamp),{error:i,...a}=e.context,s=[{include:!0,format:`%s`,values:[e.message]},{include:Object.keys(a).length>0,format:`%o`,values:[a]},{include:!0,format:`%c%s`,values:[`color: gray`,o(r,n)]},{include:e.origin.length>0,format:`%c%s`,values:[`color: rgba(128, 128, 128, 0.6); font-style: italic`,e.origin.join(`:`)]},{include:i,format:`%o`,values:[i]}].filter(e=>e.include),l=s.map(e=>e.format).join(` `),u=s.flatMap(e=>e.values);t[c[e.level]](l,...u),n=r}},c={[e.trace]:`trace`,[e.debug]:`debug`,[e.info]:`info`,[e.warn]:`warn`,[e.error]:`error`,[e.fatal]:`error`};exports.createConsoleBackend=s;
|
|
@@ -1,64 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
1
|
+
//#region ../holz-core/dist/holz-core.js
|
|
2
|
+
var e = {
|
|
3
|
+
fatal: 60,
|
|
4
|
+
error: 50,
|
|
5
|
+
warn: 40,
|
|
6
|
+
info: 30,
|
|
7
|
+
debug: 20,
|
|
8
|
+
trace: 10
|
|
9
|
+
}, t = (n, r) => {
|
|
10
|
+
let i = (e, t, i = {}) => {
|
|
11
|
+
n({
|
|
12
|
+
timestamp: Date.now(),
|
|
13
|
+
message: t,
|
|
14
|
+
level: e,
|
|
15
|
+
origin: r,
|
|
16
|
+
context: i
|
|
17
|
+
});
|
|
18
|
+
}, a = {
|
|
19
|
+
owner: r,
|
|
20
|
+
trace: i.bind(null, e.trace),
|
|
21
|
+
debug: i.bind(null, e.debug),
|
|
22
|
+
info: i.bind(null, e.info),
|
|
23
|
+
warn: i.bind(null, e.warn),
|
|
24
|
+
error: i.bind(null, e.error),
|
|
25
|
+
fatal: i.bind(null, e.fatal),
|
|
26
|
+
namespace: (e) => t(n, r.concat(e)),
|
|
27
|
+
withMiddleware: (e) => t(e(n), r)
|
|
28
|
+
}, o = {
|
|
29
|
+
configurable: !1,
|
|
30
|
+
enumerable: !1
|
|
31
|
+
};
|
|
32
|
+
return Object.defineProperties(a, {
|
|
33
|
+
withMiddleware: o,
|
|
34
|
+
namespace: o,
|
|
35
|
+
trace: o,
|
|
36
|
+
debug: o,
|
|
37
|
+
info: o,
|
|
38
|
+
warn: o,
|
|
39
|
+
error: o,
|
|
40
|
+
fatal: o
|
|
41
|
+
});
|
|
42
|
+
}, n = 1e3, r = 60 * n, i = 60 * r, a = 24 * i, o = (e, t = e) => {
|
|
43
|
+
let o = e.getTime() - t.getTime(), s = Math.abs(o), c = o < 0 ? "" : "+";
|
|
44
|
+
return s >= a ? `${c}${Math.round(o / a)}d` : s >= i ? `${c}${Math.round(o / i)}h` : s >= r ? `${c}${Math.round(o / r)}m` : s >= n ? `${c}${Math.round(o / n)}s` : `${c}${o}ms`;
|
|
45
|
+
}, s = (e = {}) => {
|
|
46
|
+
let t = e.console ?? console, n;
|
|
47
|
+
return (e) => {
|
|
48
|
+
let r = new Date(e.timestamp), { error: i, ...a } = e.context, s = [
|
|
49
|
+
{
|
|
50
|
+
include: !0,
|
|
51
|
+
format: "%s",
|
|
52
|
+
values: [e.message]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
include: Object.keys(a).length > 0,
|
|
56
|
+
format: "%o",
|
|
57
|
+
values: [a]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
include: !0,
|
|
61
|
+
format: "%c%s",
|
|
62
|
+
values: ["color: gray", o(r, n)]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
include: e.origin.length > 0,
|
|
66
|
+
format: "%c%s",
|
|
67
|
+
values: ["color: rgba(128, 128, 128, 0.6); font-style: italic", e.origin.join(":")]
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
include: i,
|
|
71
|
+
format: "%o",
|
|
72
|
+
values: [i]
|
|
73
|
+
}
|
|
74
|
+
].filter((e) => e.include), l = s.map((e) => e.format).join(" "), u = s.flatMap((e) => e.values);
|
|
75
|
+
t[c[e.level]](l, ...u), n = r;
|
|
76
|
+
};
|
|
77
|
+
}, c = {
|
|
78
|
+
[e.trace]: "trace",
|
|
79
|
+
[e.debug]: "debug",
|
|
80
|
+
[e.info]: "info",
|
|
81
|
+
[e.warn]: "warn",
|
|
82
|
+
[e.error]: "error",
|
|
83
|
+
[e.fatal]: "error"
|
|
64
84
|
};
|
|
85
|
+
//#endregion
|
|
86
|
+
export { s as createConsoleBackend };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import { LogProcessor } from '@holz/core';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
console?: MinimalConsole;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { }
|
|
1
|
+
import { LogProcessor } from '@holz/core';
|
|
2
|
+
/**
|
|
3
|
+
* A backend that pretty-prints logs to a browser console, or any
|
|
4
|
+
* remote-attached console.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createConsoleBackend: (options?: Options) => LogProcessor;
|
|
7
|
+
interface Options {
|
|
8
|
+
console?: MinimalConsole;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A subset of the Console interface. Must support printf-style interpolation.
|
|
12
|
+
* @see https://console.spec.whatwg.org/#formatting-specifiers
|
|
13
|
+
*
|
|
14
|
+
* Note that `fatal` has no corresponding equivalent. It will be downgraded to
|
|
15
|
+
* `error` when printed.
|
|
16
|
+
*/
|
|
17
|
+
export type MinimalConsole = Pick<Console, 'trace' | 'debug' | 'info' | 'warn' | 'error'>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createConsoleBackend } from './console-backend';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holz/console-backend",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3-rc.154+3f5148e",
|
|
4
4
|
"description": "A console backend for Holz",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -32,21 +32,21 @@
|
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
34
|
"prepack": "vite build",
|
|
35
|
-
"test:unit": "vitest --color --passWithNoTests",
|
|
35
|
+
"test:unit": "vitest run --color --passWithNoTests",
|
|
36
36
|
"test:types": "tsc"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@holz/core": "^0.8.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@holz/core": "^0.8.
|
|
43
|
-
"@types/node": "^
|
|
44
|
-
"@vitest/coverage-v8": "^
|
|
45
|
-
"typescript": "^
|
|
46
|
-
"vite": "^
|
|
47
|
-
"vite-plugin-dts": "^
|
|
48
|
-
"vite-tsconfig-paths": "^
|
|
49
|
-
"vitest": "^
|
|
42
|
+
"@holz/core": "^0.8.3-rc.154+3f5148e",
|
|
43
|
+
"@types/node": "^24.0.0",
|
|
44
|
+
"@vitest/coverage-v8": "^4.0.0",
|
|
45
|
+
"typescript": "^6.0.0",
|
|
46
|
+
"vite": "^8.0.0",
|
|
47
|
+
"vite-plugin-dts": "^5.0.0",
|
|
48
|
+
"vite-tsconfig-paths": "^6.0.0",
|
|
49
|
+
"vitest": "^4.0.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "3f5148eb94bb1d7200d4b4993c95ea30db76b0c4"
|
|
52
52
|
}
|