@holz/console-backend 0.9.2-rc.61.sha-3eaf26e → 0.9.2-rc.62.sha-e65b918
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.
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import { LogProcessor } from
|
|
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
|
+
type MinimalConsole = Pick<Console, "trace" | "debug" | "info" | "warn" | "error">;
|
|
18
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holz/console-backend",
|
|
3
|
-
"version": "0.9.2-rc.
|
|
3
|
+
"version": "0.9.2-rc.62.sha-e65b918",
|
|
4
4
|
"description": "A console backend for Holz",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
".": {
|
|
13
13
|
"source": "./src/index.ts",
|
|
14
14
|
"types": "./dist/holz-console-backend.d.ts",
|
|
15
|
-
"
|
|
16
|
-
"import": "./dist/holz-console-backend.js"
|
|
15
|
+
"default": "./dist/holz-console-backend.js"
|
|
17
16
|
}
|
|
18
17
|
},
|
|
19
18
|
"publishConfig": {
|
|
@@ -43,14 +42,13 @@
|
|
|
43
42
|
"@holz/core": "^0.8.0 || ^0.9.0"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
|
-
"@holz/core": "^0.9.2-rc.
|
|
47
|
-
"@microsoft/api-extractor": "^7.58.8",
|
|
45
|
+
"@holz/core": "^0.9.2-rc.62.sha-e65b918",
|
|
48
46
|
"@types/node": "^26.0.0",
|
|
49
47
|
"@vitest/coverage-v8": "^5.0.0",
|
|
48
|
+
"rolldown-plugin-dts": "^0.28.8",
|
|
50
49
|
"typescript": "^6.0.0",
|
|
51
|
-
"unplugin-dts": "^1.1.2",
|
|
52
50
|
"vite": "^8.0.0",
|
|
53
51
|
"vitest": "^5.0.0"
|
|
54
52
|
},
|
|
55
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "e65b91827b38ec984286272eceb2d97296260ed1"
|
|
56
54
|
}
|
package/src/console-backend.ts
CHANGED
package/src/time-delta.ts
CHANGED
|
@@ -8,7 +8,7 @@ const day = 24 * hour;
|
|
|
8
8
|
*
|
|
9
9
|
* Inspired by the `ms` package. Thanks TJ.
|
|
10
10
|
*/
|
|
11
|
-
export const timeDelta = (now: Date, then: Date = now) => {
|
|
11
|
+
export const timeDelta = (now: Date, then: Date = now): string => {
|
|
12
12
|
const offset = now.getTime() - then.getTime();
|
|
13
13
|
const distance = Math.abs(offset);
|
|
14
14
|
const sign = offset < 0 ? '' : '+';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@holz/core");var t=1e3,n=60*t,r=60*n,i=24*r,a=(e,a=e)=>{let o=e.getTime()-a.getTime(),s=Math.abs(o),c=o<0?``:`+`;return s>=i?`${c}${Math.round(o/i)}d`:s>=r?`${c}${Math.round(o/r)}h`:s>=n?`${c}${Math.round(o/n)}m`:s>=t?`${c}${Math.round(o/t)}s`:`${c}${o}ms`},o=(e={})=>{let t=e.console??console,n;return e=>{let r=new Date(e.timestamp),{error:i,...o}=e.context,c=[{include:!0,format:`%s`,values:[e.message]},{include:Object.keys(o).length>0,format:`%o`,values:[o]},{include:!0,format:`%c%s`,values:[`color: gray`,a(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=c.map(e=>e.format).join(` `),u=c.flatMap(e=>e.values);t[s[e.level]](l,...u),n=r}},s={[e.level.trace]:`trace`,[e.level.debug]:`debug`,[e.level.info]:`info`,[e.level.warn]:`warn`,[e.level.error]:`error`,[e.level.fatal]:`error`};exports.createConsoleBackend=o;
|