@theholocron/observability 0.3.2 → 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.
- package/README.md +24 -8
- package/dist/core.d.mts +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{create-f88HLYhg.mjs → create-BLYkMD-k.mjs} +47 -7
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{logger-CIRNGqYs.d.mts → logger-CxGXigv1.d.mts} +14 -0
- package/dist/{logger-BJJRLMAe.mjs → logger-DIvYoEp9.mjs} +3 -0
- package/dist/logger.d.mts +2 -2
- package/dist/logger.mjs +2 -2
- package/dist/{pino-DwMkjUai.d.mts → pino-Bt_d5W1e.d.mts} +45 -2
- package/dist/testing.d.mts +2 -1
- package/dist/testing.mjs +2 -1
- package/package.json +21 -13
package/README.md
CHANGED
|
@@ -6,6 +6,20 @@ Logging, error tracking, and analytics — one interface, swappable backends.
|
|
|
6
6
|
|
|
7
7
|
<!-- /holocron:description -->
|
|
8
8
|
|
|
9
|
+
<!-- holocron:installation -->
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm install @theholocron/observability
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
See the [documentation](https://docs.theholocron.dev/observability/) for the API.
|
|
20
|
+
|
|
21
|
+
<!-- /holocron:installation -->
|
|
22
|
+
|
|
9
23
|
## Installation
|
|
10
24
|
|
|
11
25
|
```bash
|
|
@@ -85,13 +99,14 @@ full API.
|
|
|
85
99
|
|
|
86
100
|
<!-- holocron:development -->
|
|
87
101
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
pnpm build
|
|
91
|
-
pnpm
|
|
92
|
-
pnpm
|
|
93
|
-
pnpm
|
|
94
|
-
|
|
102
|
+
| Script | Command |
|
|
103
|
+
| -------------------- | ------------------------ |
|
|
104
|
+
| `pnpm build` | `tsdown` |
|
|
105
|
+
| `pnpm lint` | `holocron run lint` |
|
|
106
|
+
| `pnpm test` | `holocron run test` |
|
|
107
|
+
| `pnpm test:coverage` | `vitest run --coverage` |
|
|
108
|
+
| `pnpm typecheck` | `holocron run typecheck` |
|
|
109
|
+
| `pnpm audit` | `knip` |
|
|
95
110
|
|
|
96
111
|
<!-- /holocron:development -->
|
|
97
112
|
|
|
@@ -99,6 +114,7 @@ pnpm lint # eslint
|
|
|
99
114
|
|
|
100
115
|
<!-- holocron:releases -->
|
|
101
116
|
|
|
102
|
-
|
|
117
|
+
Automated via [semantic-release](https://semantic-release.gitbook.io/semantic-release/).
|
|
118
|
+
See the [releases page](https://docs.theholocron.dev/observability/releases) and [CHANGELOG.md](./CHANGELOG.md).
|
|
103
119
|
|
|
104
120
|
<!-- /holocron:releases -->
|
package/dist/core.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { a as NoopErrorSink, i as NoopAnalyticsSink, n as CommandSpan, r as ErrorSink, t as AnalyticsSink } from "./sinks-CSEolKcN.mjs";
|
|
2
|
-
import { a as NoopLogger, i as Logger, n as LogEnv, r as LogLevel, t as LOG_LEVELS } from "./logger-
|
|
2
|
+
import { a as NoopLogger, i as Logger, n as LogEnv, r as LogLevel, t as LOG_LEVELS } from "./logger-CxGXigv1.mjs";
|
|
3
3
|
import { a as redactOptions, i as redactObject, n as REDACT_CENSOR, r as redact, t as REDACTED_PATHS } from "./core-jXa8qbEx.mjs";
|
|
4
4
|
export { type AnalyticsSink, type CommandSpan, type ErrorSink, LOG_LEVELS, type LogEnv, type LogLevel, type Logger, NoopAnalyticsSink, NoopErrorSink, NoopLogger, REDACTED_PATHS, REDACT_CENSOR, redact, redactObject, redactOptions };
|
package/dist/core.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as NoopLogger, t as LOG_LEVELS } from "./logger-
|
|
1
|
+
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
|
export { LOG_LEVELS, NoopAnalyticsSink, NoopErrorSink, NoopLogger, REDACTED_PATHS, REDACT_CENSOR, redact, redactObject, redactOptions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as LOG_LEVELS } from "./logger-
|
|
1
|
+
import { t as LOG_LEVELS } from "./logger-DIvYoEp9.mjs";
|
|
2
2
|
import { a as redactOptions } from "./redact-BMWG62k9.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import pino from "pino";
|
|
@@ -53,6 +53,9 @@ var ConsoleLogger = class ConsoleLogger {
|
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
|
+
flush() {
|
|
57
|
+
return Promise.resolve();
|
|
58
|
+
}
|
|
56
59
|
#emit(level, objOrMsg, msg) {
|
|
57
60
|
if (RANK[level] < this.#level) return;
|
|
58
61
|
if (typeof objOrMsg === "string") {
|
|
@@ -167,6 +170,8 @@ const axiomTarget = (level, axiom) => ({
|
|
|
167
170
|
* | CI, no Axiom | `undefined` — Pino's default NDJSON to stdout |
|
|
168
171
|
* | Local, TTY, with Axiom | `pino-pretty` + Axiom |
|
|
169
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 |
|
|
170
175
|
*
|
|
171
176
|
* The Axiom transport is dropped entirely when `telemetryDisabled` is set,
|
|
172
177
|
* regardless of whether credentials were supplied. Every transport runs on
|
|
@@ -175,15 +180,20 @@ const axiomTarget = (level, axiom) => ({
|
|
|
175
180
|
* Returning `undefined` lets `createLogger` fall back to a plain
|
|
176
181
|
* `pino({ ... })` with no worker thread — the cheapest path, and exactly
|
|
177
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.
|
|
178
187
|
*/
|
|
179
188
|
function buildTransport(input) {
|
|
180
|
-
const { level, axiom, ci, tty, telemetryDisabled } = input;
|
|
181
|
-
const
|
|
189
|
+
const { level, axiom, ci, tty, telemetryDisabled, consoleOutput } = input;
|
|
190
|
+
const consoleEnabled = consoleOutput ?? true;
|
|
191
|
+
const pretty = consoleEnabled && !ci && tty;
|
|
182
192
|
const targets = [];
|
|
183
193
|
if (pretty) targets.push(prettyTarget(level));
|
|
184
194
|
if (axiom && !telemetryDisabled) targets.push(axiomTarget(level, axiom));
|
|
185
195
|
if (targets.length === 0) return void 0;
|
|
186
|
-
if (!pretty) targets.unshift(stdoutJsonTarget(level));
|
|
196
|
+
if (consoleEnabled && !pretty) targets.unshift(stdoutJsonTarget(level));
|
|
187
197
|
if (targets.length === 1) return targets[0];
|
|
188
198
|
return { targets };
|
|
189
199
|
}
|
|
@@ -215,12 +225,36 @@ var PinoLogger = class PinoLogger {
|
|
|
215
225
|
child(bindings) {
|
|
216
226
|
return new PinoLogger(this.#pino.child(bindings));
|
|
217
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Wraps Pino's own callback-based `flush()` — for a worker-thread
|
|
230
|
+
* transport (Axiom) this sends a `flushSync` message to the worker and
|
|
231
|
+
* waits for its ack; for a plain destination (no transport) Pino resolves
|
|
232
|
+
* it immediately. See {@link Logger.flush}'s own doc for why this exists.
|
|
233
|
+
*/
|
|
234
|
+
flush() {
|
|
235
|
+
return new Promise((resolve, reject) => {
|
|
236
|
+
this.#pino.flush((err) => err ? reject(err) : resolve());
|
|
237
|
+
});
|
|
238
|
+
}
|
|
218
239
|
#emit(level, objOrMsg, msg) {
|
|
219
240
|
if (typeof objOrMsg === "string") this.#pino[level](objOrMsg);
|
|
220
241
|
else this.#pino[level](objOrMsg, msg);
|
|
221
242
|
}
|
|
222
243
|
};
|
|
223
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
|
+
/**
|
|
224
258
|
* Assemble the Pino `LoggerOptions`: resolved level, `runId` / `env` on every
|
|
225
259
|
* line, ISO timestamps, sensitive-field redaction, and — unless a capture
|
|
226
260
|
* `destination` is in play — the environment-appropriate transport from
|
|
@@ -243,11 +277,16 @@ function buildPinoOptions(input) {
|
|
|
243
277
|
}
|
|
244
278
|
/**
|
|
245
279
|
* Construct the underlying Pino instance. Writes to `destination` when one is
|
|
246
|
-
* 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.
|
|
247
284
|
*/
|
|
248
285
|
function createPinoInstance(input) {
|
|
249
286
|
const options = buildPinoOptions(input);
|
|
250
|
-
|
|
287
|
+
if (input.destination) return pino(options, input.destination);
|
|
288
|
+
if (input.consoleOutput === false && !options.transport) return pino(options, nullDestination());
|
|
289
|
+
return pino(options);
|
|
251
290
|
}
|
|
252
291
|
//#endregion
|
|
253
292
|
//#region src/logger/create.ts
|
|
@@ -278,7 +317,8 @@ function createLogger(config = {}) {
|
|
|
278
317
|
base: {
|
|
279
318
|
runId,
|
|
280
319
|
env
|
|
281
|
-
}
|
|
320
|
+
},
|
|
321
|
+
...config.consoleOutput !== void 0 ? { consoleOutput: config.consoleOutput } : {}
|
|
282
322
|
})),
|
|
283
323
|
runId
|
|
284
324
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as NoopErrorSink, i as NoopAnalyticsSink, n as CommandSpan, r as ErrorSink, t as AnalyticsSink } from "./sinks-CSEolKcN.mjs";
|
|
2
2
|
import { t as PostHogSink } from "./posthog-sink-BvVIQrGy.mjs";
|
|
3
|
-
import { a as NoopLogger, i as Logger, n as LogEnv, r as LogLevel, t as LOG_LEVELS } from "./logger-
|
|
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
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as NoopLogger, t as LOG_LEVELS } from "./logger-
|
|
1
|
+
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 };
|
|
@@ -26,6 +26,19 @@ interface Logger {
|
|
|
26
26
|
* without threading extra fields through every call.
|
|
27
27
|
*/
|
|
28
28
|
child(bindings: Record<string, unknown>): Logger;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve once every line logged so far has actually left the process.
|
|
31
|
+
*
|
|
32
|
+
* Matters specifically for a worker-thread transport (Axiom): the call
|
|
33
|
+
* that enqueues a line returns before that line reaches the network — the
|
|
34
|
+
* worker thread needs its own event-loop turn to flush the batch over
|
|
35
|
+
* HTTP. A short-lived process (a serverless function returning its
|
|
36
|
+
* response) can exit before that turn happens, silently dropping every
|
|
37
|
+
* buffered line. Call this before returning from such a handler; a
|
|
38
|
+
* synchronous sink (`ConsoleLogger`, `NoopLogger`, plain stdout NDJSON
|
|
39
|
+
* with no transport) has nothing to wait for and resolves immediately.
|
|
40
|
+
*/
|
|
41
|
+
flush(): Promise<void>;
|
|
29
42
|
}
|
|
30
43
|
/** Log levels, ordered least to most severe. */
|
|
31
44
|
type LogLevel = "debug" | "info" | "warn" | "error";
|
|
@@ -50,6 +63,7 @@ declare class NoopLogger implements Logger {
|
|
|
50
63
|
warn(_objOrMsg?: Record<string, unknown> | string, _msg?: string): void;
|
|
51
64
|
error(_objOrMsg?: Record<string, unknown> | string, _msg?: string): void;
|
|
52
65
|
child(_bindings?: Record<string, unknown>): Logger;
|
|
66
|
+
flush(): Promise<void>;
|
|
53
67
|
}
|
|
54
68
|
//#endregion
|
|
55
69
|
export { NoopLogger as a, Logger as i, LogEnv as n, LogLevel as r, LOG_LEVELS as t };
|
package/dist/logger.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as Logger, n as LogEnv, r as LogLevel, t as LOG_LEVELS } from "./logger-
|
|
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-
|
|
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-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
|
-
import { t as LOG_LEVELS } from "./logger-
|
|
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-
|
|
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-BLYkMD-k.mjs";
|
|
3
3
|
export { ConsoleLogger, LOG_LEVELS, PinoLogger, buildPinoOptions, buildTransport, createLogger, createPinoInstance, detectEnv, generateRunId, isCI, isTelemetryDisabled, parseLogLevel, resolveAxiomFromEnv, resolveLevel };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as Logger$1, n as LogEnv, r as LogLevel } from "./logger-
|
|
1
|
+
import { i as Logger$1, n as LogEnv, r as LogLevel } from "./logger-CxGXigv1.mjs";
|
|
2
2
|
import { DestinationStream, Logger, LoggerOptions, TransportMultiOptions, TransportSingleOptions } from "pino";
|
|
3
3
|
//#region src/logger/console.d.ts
|
|
4
4
|
/**
|
|
@@ -26,6 +26,7 @@ declare class ConsoleLogger implements Logger$1 {
|
|
|
26
26
|
error(obj: Record<string, unknown>, msg?: string): void;
|
|
27
27
|
error(msg: string): void;
|
|
28
28
|
child(bindings: Record<string, unknown>): Logger$1;
|
|
29
|
+
flush(): Promise<void>;
|
|
29
30
|
}
|
|
30
31
|
//#endregion
|
|
31
32
|
//#region src/logger/transports.d.ts
|
|
@@ -46,6 +47,17 @@ interface BuildTransportInput {
|
|
|
46
47
|
tty: boolean;
|
|
47
48
|
/** `true` when `HOLOCRON_TELEMETRY=false` — suppresses the Axiom transport only. */
|
|
48
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;
|
|
49
61
|
}
|
|
50
62
|
/**
|
|
51
63
|
* Build the Pino `transport` option for the current environment.
|
|
@@ -56,6 +68,8 @@ interface BuildTransportInput {
|
|
|
56
68
|
* | CI, no Axiom | `undefined` — Pino's default NDJSON to stdout |
|
|
57
69
|
* | Local, TTY, with Axiom | `pino-pretty` + Axiom |
|
|
58
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 |
|
|
59
73
|
*
|
|
60
74
|
* The Axiom transport is dropped entirely when `telemetryDisabled` is set,
|
|
61
75
|
* regardless of whether credentials were supplied. Every transport runs on
|
|
@@ -64,6 +78,10 @@ interface BuildTransportInput {
|
|
|
64
78
|
* Returning `undefined` lets `createLogger` fall back to a plain
|
|
65
79
|
* `pino({ ... })` with no worker thread — the cheapest path, and exactly
|
|
66
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.
|
|
67
85
|
*/
|
|
68
86
|
declare function buildTransport(input: BuildTransportInput): TransportSingleOptions | TransportMultiOptions | undefined;
|
|
69
87
|
//#endregion
|
|
@@ -129,6 +147,15 @@ interface LoggerConfig {
|
|
|
129
147
|
* `HOLOCRON_TELEMETRY=false`.
|
|
130
148
|
*/
|
|
131
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;
|
|
132
159
|
}
|
|
133
160
|
interface CreateLoggerResult {
|
|
134
161
|
/** The logger to thread through modules via `child()`. */
|
|
@@ -175,6 +202,13 @@ declare class PinoLogger implements Logger$1 {
|
|
|
175
202
|
error(obj: Record<string, unknown>, msg?: string): void;
|
|
176
203
|
error(msg: string): void;
|
|
177
204
|
child(bindings: Record<string, unknown>): Logger$1;
|
|
205
|
+
/**
|
|
206
|
+
* Wraps Pino's own callback-based `flush()` — for a worker-thread
|
|
207
|
+
* transport (Axiom) this sends a `flushSync` message to the worker and
|
|
208
|
+
* waits for its ack; for a plain destination (no transport) Pino resolves
|
|
209
|
+
* it immediately. See {@link Logger.flush}'s own doc for why this exists.
|
|
210
|
+
*/
|
|
211
|
+
flush(): Promise<void>;
|
|
178
212
|
}
|
|
179
213
|
interface CreatePinoInstanceInput {
|
|
180
214
|
/** Resolved log level. */
|
|
@@ -194,6 +228,12 @@ interface CreatePinoInstanceInput {
|
|
|
194
228
|
* output synchronously; never set in production.
|
|
195
229
|
*/
|
|
196
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;
|
|
197
237
|
}
|
|
198
238
|
/**
|
|
199
239
|
* Assemble the Pino `LoggerOptions`: resolved level, `runId` / `env` on every
|
|
@@ -204,7 +244,10 @@ interface CreatePinoInstanceInput {
|
|
|
204
244
|
declare function buildPinoOptions(input: CreatePinoInstanceInput): LoggerOptions;
|
|
205
245
|
/**
|
|
206
246
|
* Construct the underlying Pino instance. Writes to `destination` when one is
|
|
207
|
-
* 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.
|
|
208
251
|
*/
|
|
209
252
|
declare function createPinoInstance(input: CreatePinoInstanceInput): Logger;
|
|
210
253
|
//#endregion
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as CommandSpan, r as ErrorSink, t as AnalyticsSink } from "./sinks-CSEolKcN.mjs";
|
|
2
|
-
import { i as Logger } from "./logger-
|
|
2
|
+
import { i as Logger } from "./logger-CxGXigv1.mjs";
|
|
3
3
|
import { Mock } from "vitest";
|
|
4
4
|
//#region src/testing/fake-analytics-sink.d.ts
|
|
5
5
|
/** An {@link AnalyticsSink} whose methods are spies. */
|
|
@@ -55,6 +55,7 @@ interface FakeLogger extends Logger {
|
|
|
55
55
|
warn: Mock;
|
|
56
56
|
error: Mock;
|
|
57
57
|
child: Mock;
|
|
58
|
+
flush: Mock;
|
|
58
59
|
}
|
|
59
60
|
/**
|
|
60
61
|
* Build a spy {@link Logger} for asserting what a unit under test logged.
|
package/dist/testing.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/observability",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Logging, error tracking, and analytics — one interface, swappable backends.",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"typescript",
|
|
6
7
|
"observability",
|
|
7
|
-
"telemetry",
|
|
8
8
|
"logging",
|
|
9
|
-
"
|
|
10
|
-
"pino",
|
|
9
|
+
"telemetry",
|
|
11
10
|
"sentry",
|
|
12
11
|
"posthog",
|
|
13
|
-
"
|
|
14
|
-
"theholocron"
|
|
15
|
-
"typescript"
|
|
12
|
+
"pino",
|
|
13
|
+
"theholocron"
|
|
16
14
|
],
|
|
17
15
|
"homepage": "https://docs.theholocron.dev/observability/",
|
|
18
16
|
"bugs": "https://github.com/theholocron/observability/issues",
|
|
@@ -57,14 +55,21 @@
|
|
|
57
55
|
"dist"
|
|
58
56
|
],
|
|
59
57
|
"scripts": {
|
|
60
|
-
"audit": "knip",
|
|
61
58
|
"build": "tsdown",
|
|
62
|
-
"
|
|
59
|
+
"delivery.build": "tsdown",
|
|
60
|
+
"holocron": "holocron",
|
|
61
|
+
"knowledge.wiki": "holocron run knowledge.wiki --",
|
|
62
|
+
"platform.commitStandards": "holocron run platform.commitStandards --",
|
|
63
|
+
"platform.repoSync": "holocron run platform.repoSync --",
|
|
63
64
|
"prepare": "husky",
|
|
64
|
-
"
|
|
65
|
-
"
|
|
65
|
+
"security.secretDetection": "holocron run security.secretDetection --",
|
|
66
|
+
"sourceQuality.deadCodeAnalysis": "holocron run sourceQuality.deadCodeAnalysis --",
|
|
67
|
+
"sourceQuality.formatting": "holocron run sourceQuality.formatting --",
|
|
68
|
+
"sourceQuality.staticAnalysis": "eslint .",
|
|
69
|
+
"sourceQuality.structuredDataValidation": "holocron run sourceQuality.structuredDataValidation --",
|
|
66
70
|
"test:coverage": "vitest run --coverage",
|
|
67
|
-
"
|
|
71
|
+
"verification.typeSafety": "tsc --noEmit",
|
|
72
|
+
"verification.unitTests": "vitest run"
|
|
68
73
|
},
|
|
69
74
|
"devDependencies": {
|
|
70
75
|
"@astrojs/react": "catalog:",
|
|
@@ -79,11 +84,13 @@
|
|
|
79
84
|
"@semantic-release/github": "catalog:",
|
|
80
85
|
"@sentry/node": "catalog:",
|
|
81
86
|
"@theholocron/astro-config": "catalog:configs",
|
|
87
|
+
"@theholocron/astromech": "catalog:holocron",
|
|
82
88
|
"@theholocron/cli": "catalog:holocron",
|
|
83
89
|
"@theholocron/commitlint-config": "catalog:configs",
|
|
84
90
|
"@theholocron/docs-theme": "catalog:",
|
|
85
91
|
"@theholocron/eslint-config": "catalog:configs",
|
|
86
|
-
"@theholocron/holocron-
|
|
92
|
+
"@theholocron/holocron-plugin-cloudflare": "catalog:holocron",
|
|
93
|
+
"@theholocron/holocron-plugin-fern": "catalog:holocron",
|
|
87
94
|
"@theholocron/holocron-plugin-github": "catalog:holocron",
|
|
88
95
|
"@theholocron/lint-staged-config": "catalog:configs",
|
|
89
96
|
"@theholocron/prettier-config": "catalog:configs",
|
|
@@ -112,6 +119,7 @@
|
|
|
112
119
|
"semantic-release": "catalog:",
|
|
113
120
|
"sort-package-json": "catalog:",
|
|
114
121
|
"tsdown": "catalog:",
|
|
122
|
+
"turbo": "^2.10.12",
|
|
115
123
|
"typescript": "catalog:",
|
|
116
124
|
"typescript-eslint": "catalog:",
|
|
117
125
|
"vitest": "catalog:"
|