@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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=()=>!0,s=({processor:t,condition:o=n})=>{e[c]={processor:t,condition:o}},r=()=>{delete e[c]},e=globalThis,c=Symbol.for("@holz/log-collector"),a=t=>o=>{const l=e[c];l!=null&&l.condition(o)?l.processor(o):t.fallback(o)};exports.createLogCollector=a;exports.setGlobalLogCollector=s;exports.unsetGlobalLogCollector=r;
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
- const n = () => !0, s = ({
2
- processor: t,
3
- condition: o = n
4
- }) => {
5
- c[e] = { processor: t, condition: o };
6
- }, r = () => {
7
- delete c[e];
8
- }, c = globalThis, e = Symbol.for("@holz/log-collector"), i = (t) => (o) => {
9
- const l = c[e];
10
- l != null && l.condition(o) ? l.processor(o) : t.fallback(o);
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
- import { LogProcessor } from '@holz/core';
3
-
4
- declare interface Config {
5
- fallback: LogProcessor;
6
- }
7
-
8
- /**
9
- * Redirects logs to a global collector if one is configured. This is designed
10
- * with apps in mind, which may want to aggregate logs from multiple sources.
11
- */
12
- export declare const createLogCollector: (config: Config) => LogProcessor;
13
-
14
- declare interface InterceptorConfig {
15
- /** Plugin handling all logs captured by the interceptor. */
16
- processor: LogProcessor;
17
- /**
18
- * Only capture logs matching this function. Return `false` to use the
19
- * default log destination. Defaults to capture all logs.
20
- */
21
- condition?: (log: Log) => boolean;
22
- }
23
-
24
- /**
25
- * Overrides the default log destination for all loggers in the app. Call this
26
- * early on startup. If logs are sent before registering the collector, they
27
- * will be lost.
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,2 @@
1
+ export { createLogCollector } from './log-collector';
2
+ export { setGlobalLogCollector, unsetGlobalLogCollector } from './global';
@@ -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.2",
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.2",
43
- "@types/node": "^22.0.0",
44
- "@vitest/coverage-v8": "^3.0.8",
45
- "typescript": "^5.8.2",
46
- "vite": "^6.0.0",
47
- "vite-plugin-dts": "^4.5.3",
48
- "vite-tsconfig-paths": "^5.1.4",
49
- "vitest": "^3.0.8"
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": "f099a09cd01834de9bc1714908183cbb7b828c85"
51
+ "gitHead": "3f5148eb94bb1d7200d4b4993c95ea30db76b0c4"
52
52
  }