@holz/log-collector 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-log-collector.cjs +1 -1
- package/dist/holz-log-collector.js +13 -15
- package/dist/src/__tests__/log-collector.test.d.ts +1 -0
- package/dist/{holz-log-collector.d.ts → src/global.d.ts} +27 -37
- package/dist/src/index.d.ts +2 -0
- package/dist/src/log-collector.d.ts +9 -0
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=()=>!0,t=({processor:t,condition:n=e})=>{r[i]={processor:t,condition:n}},n=()=>{delete r[i]},r=globalThis,i=Symbol.for(`@holz/log-collector`),a=e=>t=>{let n=r[i];n?.condition(t)?n.processor(t):e.fallback(t)};exports.createLogCollector=a,exports.setGlobalLogCollector=t,exports.unsetGlobalLogCollector=n;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
i as createLogCollector,
|
|
14
|
-
s as setGlobalLogCollector,
|
|
15
|
-
r as unsetGlobalLogCollector
|
|
1
|
+
//#region src/global.ts
|
|
2
|
+
var e = () => !0, t = ({ processor: t, condition: n = e }) => {
|
|
3
|
+
r[i] = {
|
|
4
|
+
processor: t,
|
|
5
|
+
condition: n
|
|
6
|
+
};
|
|
7
|
+
}, n = () => {
|
|
8
|
+
delete r[i];
|
|
9
|
+
}, r = globalThis, i = Symbol.for("@holz/log-collector"), a = (e) => (t) => {
|
|
10
|
+
let n = r[i];
|
|
11
|
+
n?.condition(t) ? n.processor(t) : e.fallback(t);
|
|
16
12
|
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { a as createLogCollector, t as setGlobalLogCollector, n as unsetGlobalLogCollector };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,37 +1,27 @@
|
|
|
1
|
-
import { Log } from '@holz/core';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
export declare const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*/
|
|
29
|
-
export declare const setGlobalLogCollector: ({ processor, condition: match, }: InterceptorConfig) => void;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Remove the global log collector restoring defaults. Safe to call regardless
|
|
33
|
-
* of whether one is set.
|
|
34
|
-
*/
|
|
35
|
-
export declare const unsetGlobalLogCollector: () => void;
|
|
36
|
-
|
|
37
|
-
export { }
|
|
1
|
+
import { Log, LogProcessor } from '@holz/core';
|
|
2
|
+
/**
|
|
3
|
+
* Overrides the default log destination for all loggers in the app. Call this
|
|
4
|
+
* early on startup. If logs are sent before registering the collector, they
|
|
5
|
+
* will be lost.
|
|
6
|
+
*/
|
|
7
|
+
export declare const setGlobalLogCollector: ({ processor, condition: match, }: InterceptorConfig) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Remove the global log collector restoring defaults. Safe to call regardless
|
|
10
|
+
* of whether one is set.
|
|
11
|
+
*/
|
|
12
|
+
export declare const unsetGlobalLogCollector: () => void;
|
|
13
|
+
interface InterceptorConfig {
|
|
14
|
+
/** Plugin handling all logs captured by the interceptor. */
|
|
15
|
+
processor: LogProcessor;
|
|
16
|
+
/**
|
|
17
|
+
* Only capture logs matching this function. Return `false` to use the
|
|
18
|
+
* default log destination. Defaults to capture all logs.
|
|
19
|
+
*/
|
|
20
|
+
condition?: (log: Log) => boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare const globalScope: GlobalContext;
|
|
23
|
+
export declare const COLLECTOR_SYMBOL: unique symbol;
|
|
24
|
+
interface GlobalContext {
|
|
25
|
+
[COLLECTOR_SYMBOL]?: Required<InterceptorConfig>;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LogProcessor } from '@holz/core';
|
|
2
|
+
/**
|
|
3
|
+
* Redirects logs to a global collector if one is configured. This is designed
|
|
4
|
+
* with apps in mind, which may want to aggregate logs from multiple sources.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createLogCollector: (config: Config) => LogProcessor;
|
|
7
|
+
export interface Config {
|
|
8
|
+
fallback: LogProcessor;
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holz/log-collector",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3-rc.154+3f5148e",
|
|
4
4
|
"description": "Send all logs to a central collector",
|
|
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
|
}
|