@theholocron/observability 0.4.0 → 0.5.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
|
|
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),
|
|
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
|
-
|
|
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
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -3,5 +3,5 @@ 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-
|
|
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-Bt_d5W1e.mjs";
|
|
7
7
|
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-
|
|
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,3 @@
|
|
|
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-
|
|
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-Bt_d5W1e.mjs";
|
|
3
3
|
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-
|
|
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 };
|
|
@@ -47,6 +47,17 @@ interface BuildTransportInput {
|
|
|
47
47
|
tty: boolean;
|
|
48
48
|
/** `true` when `HOLOCRON_TELEMETRY=false` — suppresses the Axiom transport only. */
|
|
49
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;
|
|
50
61
|
}
|
|
51
62
|
/**
|
|
52
63
|
* Build the Pino `transport` option for the current environment.
|
|
@@ -57,6 +68,8 @@ interface BuildTransportInput {
|
|
|
57
68
|
* | CI, no Axiom | `undefined` — Pino's default NDJSON to stdout |
|
|
58
69
|
* | Local, TTY, with Axiom | `pino-pretty` + Axiom |
|
|
59
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 |
|
|
60
73
|
*
|
|
61
74
|
* The Axiom transport is dropped entirely when `telemetryDisabled` is set,
|
|
62
75
|
* regardless of whether credentials were supplied. Every transport runs on
|
|
@@ -65,6 +78,10 @@ interface BuildTransportInput {
|
|
|
65
78
|
* Returning `undefined` lets `createLogger` fall back to a plain
|
|
66
79
|
* `pino({ ... })` with no worker thread — the cheapest path, and exactly
|
|
67
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.
|
|
68
85
|
*/
|
|
69
86
|
declare function buildTransport(input: BuildTransportInput): TransportSingleOptions | TransportMultiOptions | undefined;
|
|
70
87
|
//#endregion
|
|
@@ -130,6 +147,15 @@ interface LoggerConfig {
|
|
|
130
147
|
* `HOLOCRON_TELEMETRY=false`.
|
|
131
148
|
*/
|
|
132
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;
|
|
133
159
|
}
|
|
134
160
|
interface CreateLoggerResult {
|
|
135
161
|
/** The logger to thread through modules via `child()`. */
|
|
@@ -202,6 +228,12 @@ interface CreatePinoInstanceInput {
|
|
|
202
228
|
* output synchronously; never set in production.
|
|
203
229
|
*/
|
|
204
230
|
destination?: DestinationStream;
|
|
231
|
+
/**
|
|
232
|
+
* `false` suppresses all human-visible console output regardless of
|
|
233
|
+
* `ci`/`tty`/level — Axiom (if wired) is unaffected. See
|
|
234
|
+
* `buildTransport`'s doc for the full behavior matrix.
|
|
235
|
+
*/
|
|
236
|
+
consoleOutput?: boolean;
|
|
205
237
|
}
|
|
206
238
|
/**
|
|
207
239
|
* Assemble the Pino `LoggerOptions`: resolved level, `runId` / `env` on every
|
|
@@ -212,7 +244,10 @@ interface CreatePinoInstanceInput {
|
|
|
212
244
|
declare function buildPinoOptions(input: CreatePinoInstanceInput): LoggerOptions;
|
|
213
245
|
/**
|
|
214
246
|
* Construct the underlying Pino instance. Writes to `destination` when one is
|
|
215
|
-
* supplied (tests),
|
|
247
|
+
* supplied (tests), to a null destination when the caller explicitly
|
|
248
|
+
* suppressed console output and no transport ended up wired (nothing else to
|
|
249
|
+
* write to — see {@link nullDestination}), otherwise to the transports
|
|
250
|
+
* {@link buildPinoOptions} wired.
|
|
216
251
|
*/
|
|
217
252
|
declare function createPinoInstance(input: CreatePinoInstanceInput): Logger;
|
|
218
253
|
//#endregion
|