@theholocron/logger 3.54.0 → 3.55.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 CHANGED
@@ -17,15 +17,8 @@ pnpm add @theholocron/logger
17
17
  ```ts
18
18
  import { createLogger } from "@theholocron/logger";
19
19
 
20
- const { logger, runId } = createLogger({
21
- level: "info",
22
- axiom: process.env.HOLOCRON_AXIOM_TOKEN
23
- ? {
24
- dataset: process.env.HOLOCRON_AXIOM_DATASET!,
25
- token: process.env.HOLOCRON_AXIOM_TOKEN,
26
- }
27
- : undefined,
28
- });
20
+ // Axiom credentials are picked up from the environment automatically.
21
+ const { logger, runId } = createLogger({ level: "info" });
29
22
 
30
23
  const log = logger.child({ command: "sync-github", repo: "theholocron/configs" });
31
24
  log.info({ branch: "main" }, "opening PR");
@@ -63,11 +56,17 @@ The overloads mirror Pino: object-first for structured lines, bare string for si
63
56
 
64
57
  Returns `{ logger, runId }`. `runId` is a UUID bound to every line the logger and its children emit — surface it via `print` when `--debug` or `--verbose` is set so a whole run can be pulled back out of Axiom.
65
58
 
66
- | `config` field | Type | Notes |
67
- | --------------- | ---------------------------------------- | ---------------------------------------------------------- |
68
- | `level` | `"debug" \| "info" \| "warn" \| "error"` | Highest-priority level source. Optional. |
69
- | `axiom.dataset` | `string` | Axiom dataset name. Supply from env vars only. |
70
- | `axiom.token` | `string` | Axiom API token. Supply from env vars only never config. |
59
+ | `config` field | Type | Notes |
60
+ | --------------- | ---------------------------------------- | ----------------------------------------------------------------------- |
61
+ | `level` | `"debug" \| "info" \| "warn" \| "error"` | Highest-priority level source. Optional. |
62
+ | `axiom.dataset` | `string` | Axiom dataset. Optional — resolved from env by default (see below). |
63
+ | `axiom.token` | `string` | Axiom API token. Optional — resolved from env by default. Never config. |
64
+
65
+ `createLogger` reads Axiom credentials from the environment automatically when
66
+ `config.axiom` is omitted — `HOLOCRON_AXIOM_TOKEN` / `AXIOM_TOKEN` +
67
+ `HOLOCRON_AXIOM_DATASET` / `AXIOM_DATASET`, both required. The same logic is
68
+ exported as `resolveAxiomFromEnv(env?)`. Credentials come only from env vars,
69
+ never a config file.
71
70
 
72
71
  ### Level resolution
73
72
 
@@ -79,13 +78,13 @@ An unrecognised value at any tier is ignored and resolution falls through. The r
79
78
 
80
79
  ## Transports
81
80
 
82
- | Environment | Output |
83
- | ----------------------- | --------------------------------------------- |
84
- | Local, TTY | `pino-pretty` — colourised, human-readable |
85
- | CI (`CI` truthy) | Newline-delimited JSON to stdout |
86
- | `config.axiom` supplied | Axiom, in a Pino worker thread (non-blocking) |
81
+ | Environment | Output |
82
+ | -------------------- | --------------------------------------------- |
83
+ | Local, TTY | `pino-pretty` — colourised, human-readable |
84
+ | CI (`CI` truthy) | Newline-delimited JSON to stdout |
85
+ | Axiom creds resolved | Axiom, in a Pino worker thread (non-blocking) |
87
86
 
88
- The Axiom transport is added only when `config.axiom` is supplied **and** `HOLOCRON_TELEMETRY` is not `"false"`. When Axiom is the only non-console transport, console JSON is kept alongside it so CI logs stay readable.
87
+ The Axiom transport is added only when credentials resolve (from `config.axiom` or the env) **and** `HOLOCRON_TELEMETRY` is not `"false"`. When Axiom is the only non-console transport, console JSON is kept alongside it so CI logs stay readable.
89
88
 
90
89
  ### Axiom datasets
91
90
 
package/dist/index.d.mts CHANGED
@@ -71,6 +71,21 @@ declare function parseLogLevel(value: string | undefined): LogLevel | undefined;
71
71
  declare function resolveLevel(explicit?: LogLevel, env?: NodeJS.ProcessEnv): LogLevel;
72
72
  /** True when the Axiom transport must be suppressed via `HOLOCRON_TELEMETRY=false`. */
73
73
  declare function isTelemetryDisabled(env?: NodeJS.ProcessEnv): boolean;
74
+ /**
75
+ * Resolve Axiom credentials from the environment — the canonical fallback
76
+ * chain from ADR-0007. `createLogger` calls this when no explicit
77
+ * `config.axiom` is supplied, so every consumer of `@theholocron/logger`
78
+ * gets Axiom activation from env vars alone. Credentials are read here and
79
+ * only here — never from a config file.
80
+ *
81
+ * Returns `undefined` unless BOTH a token and a dataset are present.
82
+ *
83
+ * | Value | Primary | Fallback |
84
+ * | -------- | ------------------------ | --------------- |
85
+ * | token | `HOLOCRON_AXIOM_TOKEN` | `AXIOM_TOKEN` |
86
+ * | dataset | `HOLOCRON_AXIOM_DATASET` | `AXIOM_DATASET` |
87
+ */
88
+ declare function resolveAxiomFromEnv(env?: NodeJS.ProcessEnv): AxiomTransportConfig | undefined;
74
89
  //#endregion
75
90
  //#region src/redact.d.ts
76
91
  /**
@@ -96,9 +111,11 @@ interface LoggerConfig {
96
111
  */
97
112
  level?: LogLevel;
98
113
  /**
99
- * Axiom credentials. Supply only from env vars (`HOLOCRON_AXIOM_TOKEN` /
100
- * `HOLOCRON_AXIOM_DATASET`) never from config files. Omit to skip the
101
- * Axiom transport. Also skipped when `HOLOCRON_TELEMETRY=false`.
114
+ * Axiom credentials. Resolved from env vars by default
115
+ * (`HOLOCRON_AXIOM_TOKEN` / `AXIOM_TOKEN` + `HOLOCRON_AXIOM_DATASET` /
116
+ * `AXIOM_DATASET`) pass this only to override, and only from env vars,
117
+ * never from a config file. The transport is also skipped entirely when
118
+ * `HOLOCRON_TELEMETRY=false`.
102
119
  */
103
120
  axiom?: AxiomTransportConfig;
104
121
  }
@@ -125,4 +142,4 @@ interface CreateLoggerResult {
125
142
  */
126
143
  declare function createLogger(config?: LoggerConfig): CreateLoggerResult;
127
144
  //#endregion
128
- export { type AxiomTransportConfig, CreateLoggerResult, LOG_LEVELS, type LogEnv, type LogLevel, type Logger, LoggerConfig, REDACTED_PATHS, REDACT_CENSOR, createLogger, detectEnv, generateRunId, isCI, isTelemetryDisabled, parseLogLevel, resolveLevel };
145
+ export { type AxiomTransportConfig, CreateLoggerResult, LOG_LEVELS, type LogEnv, type LogLevel, type Logger, LoggerConfig, REDACTED_PATHS, REDACT_CENSOR, createLogger, detectEnv, generateRunId, isCI, isTelemetryDisabled, parseLogLevel, resolveAxiomFromEnv, resolveLevel };
package/dist/index.mjs CHANGED
@@ -53,6 +53,28 @@ function resolveLevel(explicit, env = process.env) {
53
53
  function isTelemetryDisabled(env = process.env) {
54
54
  return env.HOLOCRON_TELEMETRY === "false";
55
55
  }
56
+ /**
57
+ * Resolve Axiom credentials from the environment — the canonical fallback
58
+ * chain from ADR-0007. `createLogger` calls this when no explicit
59
+ * `config.axiom` is supplied, so every consumer of `@theholocron/logger`
60
+ * gets Axiom activation from env vars alone. Credentials are read here and
61
+ * only here — never from a config file.
62
+ *
63
+ * Returns `undefined` unless BOTH a token and a dataset are present.
64
+ *
65
+ * | Value | Primary | Fallback |
66
+ * | -------- | ------------------------ | --------------- |
67
+ * | token | `HOLOCRON_AXIOM_TOKEN` | `AXIOM_TOKEN` |
68
+ * | dataset | `HOLOCRON_AXIOM_DATASET` | `AXIOM_DATASET` |
69
+ */
70
+ function resolveAxiomFromEnv(env = process.env) {
71
+ const token = env.HOLOCRON_AXIOM_TOKEN ?? env.AXIOM_TOKEN;
72
+ const dataset = env.HOLOCRON_AXIOM_DATASET ?? env.AXIOM_DATASET;
73
+ return token && dataset ? {
74
+ token,
75
+ dataset
76
+ } : void 0;
77
+ }
56
78
  //#endregion
57
79
  //#region src/redact.ts
58
80
  /**
@@ -219,7 +241,7 @@ function createLogger(config = {}) {
219
241
  return {
220
242
  logger: new PinoLogger(createPinoInstance({
221
243
  level: resolveLevel(config.level),
222
- axiom: config.axiom,
244
+ axiom: config.axiom ?? resolveAxiomFromEnv(),
223
245
  ci: isCI(),
224
246
  tty: Boolean(process.stdout.isTTY),
225
247
  telemetryDisabled: isTelemetryDisabled(),
@@ -232,4 +254,4 @@ function createLogger(config = {}) {
232
254
  };
233
255
  }
234
256
  //#endregion
235
- export { LOG_LEVELS, REDACTED_PATHS, REDACT_CENSOR, createLogger, detectEnv, generateRunId, isCI, isTelemetryDisabled, parseLogLevel, resolveLevel };
257
+ export { LOG_LEVELS, REDACTED_PATHS, REDACT_CENSOR, createLogger, detectEnv, generateRunId, isCI, isTelemetryDisabled, parseLogLevel, resolveAxiomFromEnv, resolveLevel };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/logger",
3
- "version": "3.54.0",
3
+ "version": "3.55.0",
4
4
  "description": "Structured logging for Holocron — a Pino-backed Logger adapter interface with pino-pretty, CI JSON, and Axiom transports.",
5
5
  "keywords": [
6
6
  "axiom",