@theholocron/observability 0.5.0 → 0.6.0
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/create-CEY3e4NQ.d.mts +112 -0
- package/dist/index.d.mts +2 -1
- package/dist/logger.d.mts +2 -1
- package/dist/{pino-Bt_d5W1e.d.mts → pino-Dx8yblcl.d.mts} +3 -111
- package/dist/testing.d.mts +28 -0
- package/dist/testing.mjs +34 -1
- package/package.json +1 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { i as Logger$1, r as LogLevel } from "./logger-CxGXigv1.mjs";
|
|
2
|
+
import { TransportMultiOptions, TransportSingleOptions } from "pino";
|
|
3
|
+
//#region src/logger/transports.d.ts
|
|
4
|
+
/** Axiom credentials. The token comes from env vars or the OS keyring — never
|
|
5
|
+
* a committed config file; the dataset name may come from config. */
|
|
6
|
+
interface AxiomTransportConfig {
|
|
7
|
+
dataset: string;
|
|
8
|
+
token: string;
|
|
9
|
+
}
|
|
10
|
+
interface BuildTransportInput {
|
|
11
|
+
/** Resolved log level — applied uniformly to every transport. */
|
|
12
|
+
level: LogLevel;
|
|
13
|
+
/** Axiom credentials. When absent, no Axiom transport is wired. */
|
|
14
|
+
axiom?: AxiomTransportConfig;
|
|
15
|
+
/** `true` inside CI — suppresses pino-pretty. */
|
|
16
|
+
ci: boolean;
|
|
17
|
+
/** `process.stdout.isTTY` — pino-pretty only makes sense on a TTY. */
|
|
18
|
+
tty: boolean;
|
|
19
|
+
/** `true` when `HOLOCRON_TELEMETRY=false` — suppresses the Axiom transport only. */
|
|
20
|
+
telemetryDisabled: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Explicit override for whether human-visible console output (pretty or
|
|
23
|
+
* NDJSON) runs at all, independent of `level`. `undefined` (default)
|
|
24
|
+
* preserves the existing `ci`/`tty` auto-detection below. `false`
|
|
25
|
+
* suppresses console output entirely, regardless of `ci`/`tty` — Axiom
|
|
26
|
+
* (if configured) is unaffected. When nothing else is wired either,
|
|
27
|
+
* {@link createPinoInstance} routes to a null destination instead of
|
|
28
|
+
* falling back to Pino's own default stdout — see its doc for why that
|
|
29
|
+
* distinction matters.
|
|
30
|
+
*/
|
|
31
|
+
consoleOutput?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Build the Pino `transport` option for the current environment.
|
|
35
|
+
*
|
|
36
|
+
* | Environment | Output |
|
|
37
|
+
* | -------------------------- | --------------------------------------------------- |
|
|
38
|
+
* | Local, TTY, no Axiom | `pino-pretty` only |
|
|
39
|
+
* | CI, no Axiom | `undefined` — Pino's default NDJSON to stdout |
|
|
40
|
+
* | Local, TTY, with Axiom | `pino-pretty` + Axiom |
|
|
41
|
+
* | CI, with Axiom | NDJSON to stdout + Axiom |
|
|
42
|
+
* | `consoleOutput: false`, no Axiom | `undefined` — routed to a null destination |
|
|
43
|
+
* | `consoleOutput: false`, with Axiom | Axiom only |
|
|
44
|
+
*
|
|
45
|
+
* The Axiom transport is dropped entirely when `telemetryDisabled` is set,
|
|
46
|
+
* regardless of whether credentials were supplied. Every transport runs on
|
|
47
|
+
* the same resolved `level` — there is no Axiom-only gate.
|
|
48
|
+
*
|
|
49
|
+
* Returning `undefined` lets `createLogger` fall back to a plain
|
|
50
|
+
* `pino({ ... })` with no worker thread — the cheapest path, and exactly
|
|
51
|
+
* what CI wants.
|
|
52
|
+
*
|
|
53
|
+
* `consoleOutput: false` opts out of all of the above: no pretty, no NDJSON,
|
|
54
|
+
* regardless of `ci`/`tty`. Axiom (when configured) still gets its own
|
|
55
|
+
* target, untouched by the override.
|
|
56
|
+
*/
|
|
57
|
+
declare function buildTransport(input: BuildTransportInput): TransportSingleOptions | TransportMultiOptions | undefined;
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/logger/create.d.ts
|
|
60
|
+
interface LoggerConfig {
|
|
61
|
+
/**
|
|
62
|
+
* Explicit level — the highest-priority source. The caller passes the
|
|
63
|
+
* resolved `--verbose` / `--quiet` flag or a config field here. Falls
|
|
64
|
+
* through to `HOLOCRON_LOG_LEVEL`, then `"info"`.
|
|
65
|
+
*/
|
|
66
|
+
level?: LogLevel;
|
|
67
|
+
/**
|
|
68
|
+
* Axiom credentials. Resolved from env vars by default
|
|
69
|
+
* (`HOLOCRON_AXIOM_TOKEN` / `AXIOM_TOKEN` + `HOLOCRON_AXIOM_DATASET` /
|
|
70
|
+
* `AXIOM_DATASET`). Pass this only to override — e.g. to pair an OS-keyring
|
|
71
|
+
* token with a config-file dataset. The **token** must never come from a
|
|
72
|
+
* committed config file. The transport is also skipped entirely when
|
|
73
|
+
* `HOLOCRON_TELEMETRY=false`.
|
|
74
|
+
*/
|
|
75
|
+
axiom?: AxiomTransportConfig;
|
|
76
|
+
/**
|
|
77
|
+
* Explicit override for whether human-visible console output (pretty or
|
|
78
|
+
* NDJSON) runs at all, independent of `level`. `undefined` (default)
|
|
79
|
+
* preserves the existing `ci`/`tty` auto-detection — every consumer that
|
|
80
|
+
* doesn't pass this is unaffected. Pass `false` to suppress console
|
|
81
|
+
* output entirely (e.g. a CLI's quiet-by-default interactive mode);
|
|
82
|
+
* Axiom (if configured) still receives everything.
|
|
83
|
+
*/
|
|
84
|
+
consoleOutput?: boolean;
|
|
85
|
+
}
|
|
86
|
+
interface CreateLoggerResult {
|
|
87
|
+
/** The logger to thread through modules via `child()`. */
|
|
88
|
+
logger: Logger$1;
|
|
89
|
+
/**
|
|
90
|
+
* Correlation id bound to every line this logger (and its children) emit.
|
|
91
|
+
* Surface it to the user (e.g. on `--debug`) so they can pull the run out
|
|
92
|
+
* of Axiom.
|
|
93
|
+
*/
|
|
94
|
+
runId: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The single entry point for building a Pino-backed logger. Generates a
|
|
98
|
+
* `runId`, detects the environment, resolves the level, wires the right
|
|
99
|
+
* transports, and returns a ready {@link Logger}.
|
|
100
|
+
*
|
|
101
|
+
* ```ts
|
|
102
|
+
* const { logger, runId } = createLogger({ level, axiom });
|
|
103
|
+
* const log = logger.child({ command: "sync-github", repo });
|
|
104
|
+
* log.info({ branch }, "opening PR");
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* For a browser / edge / React Native context, construct a `ConsoleLogger`
|
|
108
|
+
* directly instead — it needs no `createLogger`.
|
|
109
|
+
*/
|
|
110
|
+
declare function createLogger(config?: LoggerConfig): CreateLoggerResult;
|
|
111
|
+
//#endregion
|
|
112
|
+
export { BuildTransportInput as a, AxiomTransportConfig as i, LoggerConfig as n, buildTransport as o, createLogger as r, CreateLoggerResult as t };
|
package/dist/index.d.mts
CHANGED
|
@@ -3,5 +3,6 @@ import { t as PostHogSink } from "./posthog-sink-BvVIQrGy.mjs";
|
|
|
3
3
|
import { a as NoopLogger, i as Logger, n as LogEnv, r as LogLevel, t as LOG_LEVELS } from "./logger-CxGXigv1.mjs";
|
|
4
4
|
import { a as redactOptions, i as redactObject, n as REDACT_CENSOR, r as redact, t as REDACTED_PATHS } from "./core-jXa8qbEx.mjs";
|
|
5
5
|
import { n as scrubError, t as SentrySink } from "./sentry-sink-Dk0H3MG5.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { a as detectEnv, c as isTelemetryDisabled, d as resolveLevel, f as ConsoleLogger, i as createPinoInstance, l as parseLogLevel, n as PinoLogger, o as generateRunId, r as buildPinoOptions, s as isCI, t as CreatePinoInstanceInput, u as resolveAxiomFromEnv } from "./pino-Dx8yblcl.mjs";
|
|
7
|
+
import { a as BuildTransportInput, i as AxiomTransportConfig, n as LoggerConfig, o as buildTransport, r as createLogger, t as CreateLoggerResult } from "./create-CEY3e4NQ.mjs";
|
|
7
8
|
export { type AnalyticsSink, type AxiomTransportConfig, type BuildTransportInput, type CommandSpan, ConsoleLogger, type CreateLoggerResult, type CreatePinoInstanceInput, type ErrorSink, LOG_LEVELS, type LogEnv, type LogLevel, type Logger, type LoggerConfig, NoopAnalyticsSink, NoopErrorSink, NoopLogger, PinoLogger, PostHogSink, REDACTED_PATHS, REDACT_CENSOR, SentrySink, buildPinoOptions, buildTransport, createLogger, createPinoInstance, detectEnv, generateRunId, isCI, isTelemetryDisabled, parseLogLevel, redact, redactObject, redactOptions, resolveAxiomFromEnv, resolveLevel, scrubError };
|
package/dist/logger.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { i as Logger, n as LogEnv, r as LogLevel, t as LOG_LEVELS } from "./logger-CxGXigv1.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { a as detectEnv, c as isTelemetryDisabled, d as resolveLevel, f as ConsoleLogger, i as createPinoInstance, l as parseLogLevel, n as PinoLogger, o as generateRunId, r as buildPinoOptions, s as isCI, t as CreatePinoInstanceInput, u as resolveAxiomFromEnv } from "./pino-Dx8yblcl.mjs";
|
|
3
|
+
import { a as BuildTransportInput, i as AxiomTransportConfig, n as LoggerConfig, o as buildTransport, r as createLogger, t as CreateLoggerResult } from "./create-CEY3e4NQ.mjs";
|
|
3
4
|
export { type AxiomTransportConfig, type BuildTransportInput, ConsoleLogger, type CreateLoggerResult, type CreatePinoInstanceInput, LOG_LEVELS, type LogEnv, type LogLevel, type Logger, type LoggerConfig, PinoLogger, buildPinoOptions, buildTransport, createLogger, createPinoInstance, detectEnv, generateRunId, isCI, isTelemetryDisabled, parseLogLevel, resolveAxiomFromEnv, resolveLevel };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { i as Logger$1, n as LogEnv, r as LogLevel } from "./logger-CxGXigv1.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { i as AxiomTransportConfig } from "./create-CEY3e4NQ.mjs";
|
|
3
|
+
import { DestinationStream, Logger, LoggerOptions } from "pino";
|
|
3
4
|
//#region src/logger/console.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* A zero-dependency {@link Logger} over the platform `console` — no Pino, no
|
|
@@ -29,62 +30,6 @@ declare class ConsoleLogger implements Logger$1 {
|
|
|
29
30
|
flush(): Promise<void>;
|
|
30
31
|
}
|
|
31
32
|
//#endregion
|
|
32
|
-
//#region src/logger/transports.d.ts
|
|
33
|
-
/** Axiom credentials. The token comes from env vars or the OS keyring — never
|
|
34
|
-
* a committed config file; the dataset name may come from config. */
|
|
35
|
-
interface AxiomTransportConfig {
|
|
36
|
-
dataset: string;
|
|
37
|
-
token: string;
|
|
38
|
-
}
|
|
39
|
-
interface BuildTransportInput {
|
|
40
|
-
/** Resolved log level — applied uniformly to every transport. */
|
|
41
|
-
level: LogLevel;
|
|
42
|
-
/** Axiom credentials. When absent, no Axiom transport is wired. */
|
|
43
|
-
axiom?: AxiomTransportConfig;
|
|
44
|
-
/** `true` inside CI — suppresses pino-pretty. */
|
|
45
|
-
ci: boolean;
|
|
46
|
-
/** `process.stdout.isTTY` — pino-pretty only makes sense on a TTY. */
|
|
47
|
-
tty: boolean;
|
|
48
|
-
/** `true` when `HOLOCRON_TELEMETRY=false` — suppresses the Axiom transport only. */
|
|
49
|
-
telemetryDisabled: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Explicit override for whether human-visible console output (pretty or
|
|
52
|
-
* NDJSON) runs at all, independent of `level`. `undefined` (default)
|
|
53
|
-
* preserves the existing `ci`/`tty` auto-detection below. `false`
|
|
54
|
-
* suppresses console output entirely, regardless of `ci`/`tty` — Axiom
|
|
55
|
-
* (if configured) is unaffected. When nothing else is wired either,
|
|
56
|
-
* {@link createPinoInstance} routes to a null destination instead of
|
|
57
|
-
* falling back to Pino's own default stdout — see its doc for why that
|
|
58
|
-
* distinction matters.
|
|
59
|
-
*/
|
|
60
|
-
consoleOutput?: boolean;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Build the Pino `transport` option for the current environment.
|
|
64
|
-
*
|
|
65
|
-
* | Environment | Output |
|
|
66
|
-
* | -------------------------- | --------------------------------------------------- |
|
|
67
|
-
* | Local, TTY, no Axiom | `pino-pretty` only |
|
|
68
|
-
* | CI, no Axiom | `undefined` — Pino's default NDJSON to stdout |
|
|
69
|
-
* | Local, TTY, with Axiom | `pino-pretty` + Axiom |
|
|
70
|
-
* | CI, with Axiom | NDJSON to stdout + Axiom |
|
|
71
|
-
* | `consoleOutput: false`, no Axiom | `undefined` — routed to a null destination |
|
|
72
|
-
* | `consoleOutput: false`, with Axiom | Axiom only |
|
|
73
|
-
*
|
|
74
|
-
* The Axiom transport is dropped entirely when `telemetryDisabled` is set,
|
|
75
|
-
* regardless of whether credentials were supplied. Every transport runs on
|
|
76
|
-
* the same resolved `level` — there is no Axiom-only gate.
|
|
77
|
-
*
|
|
78
|
-
* Returning `undefined` lets `createLogger` fall back to a plain
|
|
79
|
-
* `pino({ ... })` with no worker thread — the cheapest path, and exactly
|
|
80
|
-
* what CI wants.
|
|
81
|
-
*
|
|
82
|
-
* `consoleOutput: false` opts out of all of the above: no pretty, no NDJSON,
|
|
83
|
-
* regardless of `ci`/`tty`. Axiom (when configured) still gets its own
|
|
84
|
-
* target, untouched by the override.
|
|
85
|
-
*/
|
|
86
|
-
declare function buildTransport(input: BuildTransportInput): TransportSingleOptions | TransportMultiOptions | undefined;
|
|
87
|
-
//#endregion
|
|
88
33
|
//#region src/logger/context.d.ts
|
|
89
34
|
/**
|
|
90
35
|
* A fresh correlation id for one invocation. Every log line from a single run
|
|
@@ -130,59 +75,6 @@ declare function isTelemetryDisabled(env?: NodeJS.ProcessEnv): boolean;
|
|
|
130
75
|
*/
|
|
131
76
|
declare function resolveAxiomFromEnv(env?: NodeJS.ProcessEnv): AxiomTransportConfig | undefined;
|
|
132
77
|
//#endregion
|
|
133
|
-
//#region src/logger/create.d.ts
|
|
134
|
-
interface LoggerConfig {
|
|
135
|
-
/**
|
|
136
|
-
* Explicit level — the highest-priority source. The caller passes the
|
|
137
|
-
* resolved `--verbose` / `--quiet` flag or a config field here. Falls
|
|
138
|
-
* through to `HOLOCRON_LOG_LEVEL`, then `"info"`.
|
|
139
|
-
*/
|
|
140
|
-
level?: LogLevel;
|
|
141
|
-
/**
|
|
142
|
-
* Axiom credentials. Resolved from env vars by default
|
|
143
|
-
* (`HOLOCRON_AXIOM_TOKEN` / `AXIOM_TOKEN` + `HOLOCRON_AXIOM_DATASET` /
|
|
144
|
-
* `AXIOM_DATASET`). Pass this only to override — e.g. to pair an OS-keyring
|
|
145
|
-
* token with a config-file dataset. The **token** must never come from a
|
|
146
|
-
* committed config file. The transport is also skipped entirely when
|
|
147
|
-
* `HOLOCRON_TELEMETRY=false`.
|
|
148
|
-
*/
|
|
149
|
-
axiom?: AxiomTransportConfig;
|
|
150
|
-
/**
|
|
151
|
-
* Explicit override for whether human-visible console output (pretty or
|
|
152
|
-
* NDJSON) runs at all, independent of `level`. `undefined` (default)
|
|
153
|
-
* preserves the existing `ci`/`tty` auto-detection — every consumer that
|
|
154
|
-
* doesn't pass this is unaffected. Pass `false` to suppress console
|
|
155
|
-
* output entirely (e.g. a CLI's quiet-by-default interactive mode);
|
|
156
|
-
* Axiom (if configured) still receives everything.
|
|
157
|
-
*/
|
|
158
|
-
consoleOutput?: boolean;
|
|
159
|
-
}
|
|
160
|
-
interface CreateLoggerResult {
|
|
161
|
-
/** The logger to thread through modules via `child()`. */
|
|
162
|
-
logger: Logger$1;
|
|
163
|
-
/**
|
|
164
|
-
* Correlation id bound to every line this logger (and its children) emit.
|
|
165
|
-
* Surface it to the user (e.g. on `--debug`) so they can pull the run out
|
|
166
|
-
* of Axiom.
|
|
167
|
-
*/
|
|
168
|
-
runId: string;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* The single entry point for building a Pino-backed logger. Generates a
|
|
172
|
-
* `runId`, detects the environment, resolves the level, wires the right
|
|
173
|
-
* transports, and returns a ready {@link Logger}.
|
|
174
|
-
*
|
|
175
|
-
* ```ts
|
|
176
|
-
* const { logger, runId } = createLogger({ level, axiom });
|
|
177
|
-
* const log = logger.child({ command: "sync-github", repo });
|
|
178
|
-
* log.info({ branch }, "opening PR");
|
|
179
|
-
* ```
|
|
180
|
-
*
|
|
181
|
-
* For a browser / edge / React Native context, construct a `ConsoleLogger`
|
|
182
|
-
* directly instead — it needs no `createLogger`.
|
|
183
|
-
*/
|
|
184
|
-
declare function createLogger(config?: LoggerConfig): CreateLoggerResult;
|
|
185
|
-
//#endregion
|
|
186
78
|
//#region src/logger/pino.d.ts
|
|
187
79
|
/**
|
|
188
80
|
* The Pino-backed {@link Logger}. Nothing outside this package should name it —
|
|
@@ -251,4 +143,4 @@ declare function buildPinoOptions(input: CreatePinoInstanceInput): LoggerOptions
|
|
|
251
143
|
*/
|
|
252
144
|
declare function createPinoInstance(input: CreatePinoInstanceInput): Logger;
|
|
253
145
|
//#endregion
|
|
254
|
-
export {
|
|
146
|
+
export { detectEnv as a, isTelemetryDisabled as c, resolveLevel as d, ConsoleLogger as f, createPinoInstance as i, parseLogLevel as l, PinoLogger as n, generateRunId as o, buildPinoOptions as r, isCI as s, CreatePinoInstanceInput as t, resolveAxiomFromEnv as u };
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { n as CommandSpan, r as ErrorSink, t as AnalyticsSink } from "./sinks-CSEolKcN.mjs";
|
|
2
2
|
import { i as Logger } from "./logger-CxGXigv1.mjs";
|
|
3
|
+
import { r as createLogger } from "./create-CEY3e4NQ.mjs";
|
|
3
4
|
import { Mock } from "vitest";
|
|
4
5
|
//#region src/testing/fake-analytics-sink.d.ts
|
|
5
6
|
/** An {@link AnalyticsSink} whose methods are spies. */
|
|
@@ -69,4 +70,31 @@ interface FakeLogger extends Logger {
|
|
|
69
70
|
*/
|
|
70
71
|
export declare function fakeLogger(): FakeLogger;
|
|
71
72
|
//#endregion
|
|
73
|
+
//#region src/testing/silence-logger.d.ts
|
|
74
|
+
/**
|
|
75
|
+
* Replace `createLogger` in the `/logger` module with one that returns a
|
|
76
|
+
* {@link NoopLogger}, so code under test that builds a real Pino logger stops
|
|
77
|
+
* writing NDJSON to stdout. Everything else the module exports passes through.
|
|
78
|
+
*
|
|
79
|
+
* The replacement is a plain function, not a `vi.fn`, so a consumer's
|
|
80
|
+
* `resetMocks` / `restoreMocks` setting cannot wipe its implementation.
|
|
81
|
+
*
|
|
82
|
+
* `vi.mock` only takes effect in the consumer's own file, so call this from a
|
|
83
|
+
* vitest setup file:
|
|
84
|
+
*
|
|
85
|
+
* ```ts
|
|
86
|
+
* import { vi } from "vitest";
|
|
87
|
+
*
|
|
88
|
+
* vi.mock("@theholocron/observability/logger", async (importOriginal) => {
|
|
89
|
+
* const { silenceLogger } = await import("@theholocron/observability/testing");
|
|
90
|
+
* return silenceLogger(await importOriginal());
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare function silenceLogger<T extends {
|
|
95
|
+
createLogger: unknown;
|
|
96
|
+
}>(actual: T): Omit<T, "createLogger"> & {
|
|
97
|
+
createLogger: typeof createLogger;
|
|
98
|
+
};
|
|
99
|
+
//#endregion
|
|
72
100
|
export type { FakeAnalyticsSink, FakeErrorSink, FakeLogger, FakeSpan };
|
package/dist/testing.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as NoopLogger } from "./logger-DIvYoEp9.mjs";
|
|
1
2
|
import { vi } from "vitest";
|
|
2
3
|
//#region src/testing/fake-analytics-sink.ts
|
|
3
4
|
/**
|
|
@@ -67,4 +68,36 @@ function fakeLogger() {
|
|
|
67
68
|
return log;
|
|
68
69
|
}
|
|
69
70
|
//#endregion
|
|
70
|
-
|
|
71
|
+
//#region src/testing/silence-logger.ts
|
|
72
|
+
const SILENT_RUN_ID = "00000000-0000-4000-8000-000000000000";
|
|
73
|
+
/**
|
|
74
|
+
* Replace `createLogger` in the `/logger` module with one that returns a
|
|
75
|
+
* {@link NoopLogger}, so code under test that builds a real Pino logger stops
|
|
76
|
+
* writing NDJSON to stdout. Everything else the module exports passes through.
|
|
77
|
+
*
|
|
78
|
+
* The replacement is a plain function, not a `vi.fn`, so a consumer's
|
|
79
|
+
* `resetMocks` / `restoreMocks` setting cannot wipe its implementation.
|
|
80
|
+
*
|
|
81
|
+
* `vi.mock` only takes effect in the consumer's own file, so call this from a
|
|
82
|
+
* vitest setup file:
|
|
83
|
+
*
|
|
84
|
+
* ```ts
|
|
85
|
+
* import { vi } from "vitest";
|
|
86
|
+
*
|
|
87
|
+
* vi.mock("@theholocron/observability/logger", async (importOriginal) => {
|
|
88
|
+
* const { silenceLogger } = await import("@theholocron/observability/testing");
|
|
89
|
+
* return silenceLogger(await importOriginal());
|
|
90
|
+
* });
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
function silenceLogger(actual) {
|
|
94
|
+
return {
|
|
95
|
+
...actual,
|
|
96
|
+
createLogger: () => ({
|
|
97
|
+
logger: new NoopLogger(),
|
|
98
|
+
runId: SILENT_RUN_ID
|
|
99
|
+
})
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { fakeAnalyticsSink, fakeErrorSink, fakeLogger, silenceLogger };
|