@theholocron/observability 0.4.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.
@@ -170,6 +170,8 @@ const axiomTarget = (level, axiom) => ({
170
170
  * | CI, no Axiom | `undefined` — Pino's default NDJSON to stdout |
171
171
  * | Local, TTY, with Axiom | `pino-pretty` + Axiom |
172
172
  * | CI, with Axiom | NDJSON to stdout + Axiom |
173
+ * | `consoleOutput: false`, no Axiom | `undefined` — routed to a null destination |
174
+ * | `consoleOutput: false`, with Axiom | Axiom only |
173
175
  *
174
176
  * The Axiom transport is dropped entirely when `telemetryDisabled` is set,
175
177
  * regardless of whether credentials were supplied. Every transport runs on
@@ -178,15 +180,20 @@ const axiomTarget = (level, axiom) => ({
178
180
  * Returning `undefined` lets `createLogger` fall back to a plain
179
181
  * `pino({ ... })` with no worker thread — the cheapest path, and exactly
180
182
  * what CI wants.
183
+ *
184
+ * `consoleOutput: false` opts out of all of the above: no pretty, no NDJSON,
185
+ * regardless of `ci`/`tty`. Axiom (when configured) still gets its own
186
+ * target, untouched by the override.
181
187
  */
182
188
  function buildTransport(input) {
183
- const { level, axiom, ci, tty, telemetryDisabled } = input;
184
- const pretty = !ci && tty;
189
+ const { level, axiom, ci, tty, telemetryDisabled, consoleOutput } = input;
190
+ const consoleEnabled = consoleOutput ?? true;
191
+ const pretty = consoleEnabled && !ci && tty;
185
192
  const targets = [];
186
193
  if (pretty) targets.push(prettyTarget(level));
187
194
  if (axiom && !telemetryDisabled) targets.push(axiomTarget(level, axiom));
188
195
  if (targets.length === 0) return void 0;
189
- if (!pretty) targets.unshift(stdoutJsonTarget(level));
196
+ if (consoleEnabled && !pretty) targets.unshift(stdoutJsonTarget(level));
190
197
  if (targets.length === 1) return targets[0];
191
198
  return { targets };
192
199
  }
@@ -235,6 +242,19 @@ var PinoLogger = class PinoLogger {
235
242
  }
236
243
  };
237
244
  /**
245
+ * Platform-appropriate "write nowhere" destination. Used only when the
246
+ * caller explicitly suppressed console output (`consoleOutput: false`) and
247
+ * no other transport (Axiom) is wired either — the one case where falling
248
+ * back to a bare `pino(options)` would be wrong, since Pino's own default
249
+ * with no transport configured is raw NDJSON to stdout, not silence.
250
+ */
251
+ function nullDestination() {
252
+ return pino.destination({
253
+ dest: process.platform === "win32" ? "\\\\.\\NUL" : "/dev/null",
254
+ sync: false
255
+ });
256
+ }
257
+ /**
238
258
  * Assemble the Pino `LoggerOptions`: resolved level, `runId` / `env` on every
239
259
  * line, ISO timestamps, sensitive-field redaction, and — unless a capture
240
260
  * `destination` is in play — the environment-appropriate transport from
@@ -257,11 +277,16 @@ function buildPinoOptions(input) {
257
277
  }
258
278
  /**
259
279
  * Construct the underlying Pino instance. Writes to `destination` when one is
260
- * supplied (tests), otherwise to the transports {@link buildPinoOptions} wired.
280
+ * supplied (tests), to a null destination when the caller explicitly
281
+ * suppressed console output and no transport ended up wired (nothing else to
282
+ * write to — see {@link nullDestination}), otherwise to the transports
283
+ * {@link buildPinoOptions} wired.
261
284
  */
262
285
  function createPinoInstance(input) {
263
286
  const options = buildPinoOptions(input);
264
- return input.destination ? pino(options, input.destination) : pino(options);
287
+ if (input.destination) return pino(options, input.destination);
288
+ if (input.consoleOutput === false && !options.transport) return pino(options, nullDestination());
289
+ return pino(options);
265
290
  }
266
291
  //#endregion
267
292
  //#region src/logger/create.ts
@@ -292,7 +317,8 @@ function createLogger(config = {}) {
292
317
  base: {
293
318
  runId,
294
319
  env
295
- }
320
+ },
321
+ ...config.consoleOutput !== void 0 ? { consoleOutput: config.consoleOutput } : {}
296
322
  })),
297
323
  runId
298
324
  };
@@ -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 { _ as buildTransport, a as CreateLoggerResult, c as detectEnv, d as isTelemetryDisabled, f as parseLogLevel, g as BuildTransportInput, h as AxiomTransportConfig, i as createPinoInstance, l as generateRunId, m as resolveLevel, n as PinoLogger, o as LoggerConfig, p as resolveAxiomFromEnv, r as buildPinoOptions, s as createLogger, t as CreatePinoInstanceInput, u as isCI, v as ConsoleLogger } from "./pino-qixKLPJa.mjs";
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/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { n as NoopLogger, t as LOG_LEVELS } from "./logger-DIvYoEp9.mjs";
2
2
  import { a as redactOptions, i as redactObject, n as REDACT_CENSOR, r as redact, t as REDACTED_PATHS } from "./redact-BMWG62k9.mjs";
3
3
  import { n as NoopErrorSink, t as NoopAnalyticsSink } from "./sinks-scWbkOMp.mjs";
4
4
  import "./core.mjs";
5
- import { a as buildTransport, c as isCI, d as resolveAxiomFromEnv, f as resolveLevel, i as createPinoInstance, l as isTelemetryDisabled, n as PinoLogger, o as detectEnv, p as ConsoleLogger, r as buildPinoOptions, s as generateRunId, t as createLogger, u as parseLogLevel } from "./create-Ct1aNBBE.mjs";
5
+ import { a as buildTransport, c as isCI, d as resolveAxiomFromEnv, f as resolveLevel, i as createPinoInstance, l as isTelemetryDisabled, n as PinoLogger, o as detectEnv, p as ConsoleLogger, r as buildPinoOptions, s as generateRunId, t as createLogger, u as parseLogLevel } from "./create-BLYkMD-k.mjs";
6
6
  import { n as scrubError, t as SentrySink } from "./sentry-sink-BOuueung.mjs";
7
7
  import { t as PostHogSink } from "./posthog-sink-ClNks-Le.mjs";
8
8
  export { ConsoleLogger, LOG_LEVELS, 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 { _ as buildTransport, a as CreateLoggerResult, c as detectEnv, d as isTelemetryDisabled, f as parseLogLevel, g as BuildTransportInput, h as AxiomTransportConfig, i as createPinoInstance, l as generateRunId, m as resolveLevel, n as PinoLogger, o as LoggerConfig, p as resolveAxiomFromEnv, r as buildPinoOptions, s as createLogger, t as CreatePinoInstanceInput, u as isCI, v as ConsoleLogger } from "./pino-qixKLPJa.mjs";
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 };
package/dist/logger.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  import { t as LOG_LEVELS } from "./logger-DIvYoEp9.mjs";
2
- import { a as buildTransport, c as isCI, d as resolveAxiomFromEnv, f as resolveLevel, i as createPinoInstance, l as isTelemetryDisabled, n as PinoLogger, o as detectEnv, p as ConsoleLogger, r as buildPinoOptions, s as generateRunId, t as createLogger, u as parseLogLevel } from "./create-Ct1aNBBE.mjs";
2
+ import { a as buildTransport, c as isCI, d as resolveAxiomFromEnv, f as resolveLevel, i as createPinoInstance, l as isTelemetryDisabled, n as PinoLogger, o as detectEnv, p as ConsoleLogger, r as buildPinoOptions, s as generateRunId, t as createLogger, u as parseLogLevel } from "./create-BLYkMD-k.mjs";
3
3
  export { ConsoleLogger, LOG_LEVELS, 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 { DestinationStream, Logger, LoggerOptions, TransportMultiOptions, TransportSingleOptions } from "pino";
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,45 +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
- /**
52
- * Build the Pino `transport` option for the current environment.
53
- *
54
- * | Environment | Output |
55
- * | -------------------------- | --------------------------------------------------- |
56
- * | Local, TTY, no Axiom | `pino-pretty` only |
57
- * | CI, no Axiom | `undefined` — Pino's default NDJSON to stdout |
58
- * | Local, TTY, with Axiom | `pino-pretty` + Axiom |
59
- * | CI, with Axiom | NDJSON to stdout + Axiom |
60
- *
61
- * The Axiom transport is dropped entirely when `telemetryDisabled` is set,
62
- * regardless of whether credentials were supplied. Every transport runs on
63
- * the same resolved `level` — there is no Axiom-only gate.
64
- *
65
- * Returning `undefined` lets `createLogger` fall back to a plain
66
- * `pino({ ... })` with no worker thread — the cheapest path, and exactly
67
- * what CI wants.
68
- */
69
- declare function buildTransport(input: BuildTransportInput): TransportSingleOptions | TransportMultiOptions | undefined;
70
- //#endregion
71
33
  //#region src/logger/context.d.ts
72
34
  /**
73
35
  * A fresh correlation id for one invocation. Every log line from a single run
@@ -113,50 +75,6 @@ declare function isTelemetryDisabled(env?: NodeJS.ProcessEnv): boolean;
113
75
  */
114
76
  declare function resolveAxiomFromEnv(env?: NodeJS.ProcessEnv): AxiomTransportConfig | undefined;
115
77
  //#endregion
116
- //#region src/logger/create.d.ts
117
- interface LoggerConfig {
118
- /**
119
- * Explicit level — the highest-priority source. The caller passes the
120
- * resolved `--verbose` / `--quiet` flag or a config field here. Falls
121
- * through to `HOLOCRON_LOG_LEVEL`, then `"info"`.
122
- */
123
- level?: LogLevel;
124
- /**
125
- * Axiom credentials. Resolved from env vars by default
126
- * (`HOLOCRON_AXIOM_TOKEN` / `AXIOM_TOKEN` + `HOLOCRON_AXIOM_DATASET` /
127
- * `AXIOM_DATASET`). Pass this only to override — e.g. to pair an OS-keyring
128
- * token with a config-file dataset. The **token** must never come from a
129
- * committed config file. The transport is also skipped entirely when
130
- * `HOLOCRON_TELEMETRY=false`.
131
- */
132
- axiom?: AxiomTransportConfig;
133
- }
134
- interface CreateLoggerResult {
135
- /** The logger to thread through modules via `child()`. */
136
- logger: Logger$1;
137
- /**
138
- * Correlation id bound to every line this logger (and its children) emit.
139
- * Surface it to the user (e.g. on `--debug`) so they can pull the run out
140
- * of Axiom.
141
- */
142
- runId: string;
143
- }
144
- /**
145
- * The single entry point for building a Pino-backed logger. Generates a
146
- * `runId`, detects the environment, resolves the level, wires the right
147
- * transports, and returns a ready {@link Logger}.
148
- *
149
- * ```ts
150
- * const { logger, runId } = createLogger({ level, axiom });
151
- * const log = logger.child({ command: "sync-github", repo });
152
- * log.info({ branch }, "opening PR");
153
- * ```
154
- *
155
- * For a browser / edge / React Native context, construct a `ConsoleLogger`
156
- * directly instead — it needs no `createLogger`.
157
- */
158
- declare function createLogger(config?: LoggerConfig): CreateLoggerResult;
159
- //#endregion
160
78
  //#region src/logger/pino.d.ts
161
79
  /**
162
80
  * The Pino-backed {@link Logger}. Nothing outside this package should name it —
@@ -202,6 +120,12 @@ interface CreatePinoInstanceInput {
202
120
  * output synchronously; never set in production.
203
121
  */
204
122
  destination?: DestinationStream;
123
+ /**
124
+ * `false` suppresses all human-visible console output regardless of
125
+ * `ci`/`tty`/level — Axiom (if wired) is unaffected. See
126
+ * `buildTransport`'s doc for the full behavior matrix.
127
+ */
128
+ consoleOutput?: boolean;
205
129
  }
206
130
  /**
207
131
  * Assemble the Pino `LoggerOptions`: resolved level, `runId` / `env` on every
@@ -212,8 +136,11 @@ interface CreatePinoInstanceInput {
212
136
  declare function buildPinoOptions(input: CreatePinoInstanceInput): LoggerOptions;
213
137
  /**
214
138
  * Construct the underlying Pino instance. Writes to `destination` when one is
215
- * supplied (tests), otherwise to the transports {@link buildPinoOptions} wired.
139
+ * supplied (tests), to a null destination when the caller explicitly
140
+ * suppressed console output and no transport ended up wired (nothing else to
141
+ * write to — see {@link nullDestination}), otherwise to the transports
142
+ * {@link buildPinoOptions} wired.
216
143
  */
217
144
  declare function createPinoInstance(input: CreatePinoInstanceInput): Logger;
218
145
  //#endregion
219
- export { buildTransport as _, CreateLoggerResult as a, detectEnv as c, isTelemetryDisabled as d, parseLogLevel as f, BuildTransportInput as g, AxiomTransportConfig as h, createPinoInstance as i, generateRunId as l, resolveLevel as m, PinoLogger as n, LoggerConfig as o, resolveAxiomFromEnv as p, buildPinoOptions as r, createLogger as s, CreatePinoInstanceInput as t, isCI as u, ConsoleLogger as v };
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 };
@@ -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
- export { fakeAnalyticsSink, fakeErrorSink, fakeLogger };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/observability",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Logging, error tracking, and analytics — one interface, swappable backends.",
5
5
  "keywords": [
6
6
  "typescript",