@vllnt/logger 0.1.2 → 0.1.3-canary.1b2dbd3

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/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  createLogger,
6
6
  formatLogEntry,
7
7
  parseLogLevel
8
- } from "./chunk-5GDAMA7T.js";
8
+ } from "./chunk-OROSOSC5.js";
9
9
 
10
10
  // src/backend.ts
11
11
  var HAS_PROCESS = typeof process !== "undefined";
package/dist/posthog.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { c as LogOutput } from './core-BKAGZb-m.js';
1
+ import { LogOutput } from './index.js';
2
2
 
3
3
  /**
4
4
  * @vllnt/logger — PostHog output adapter.
@@ -8,11 +8,13 @@ import { c as LogOutput } from './core-BKAGZb-m.js';
8
8
  */
9
9
 
10
10
  /** PostHog-compatible capture function signature */
11
- type PostHogCapture = (event: string, properties?: Record<string, unknown>) => void;
11
+ type PostHogCapture = (event: string, properties?: Record<string, unknown>) => unknown;
12
12
  /**
13
13
  * Create a LogOutput that forwards entries to PostHog.
14
- * Swallows errors from the capture function — logging must not break the app.
14
+ * Swallows errors from the capture function, including rejected promises it
15
+ * returns — logging must not break the app.
15
16
  */
16
17
  declare function createPostHogOutput(capture: PostHogCapture): LogOutput;
17
18
 
18
- export { type PostHogCapture, createPostHogOutput };
19
+ export { createPostHogOutput };
20
+ export type { PostHogCapture };
package/dist/posthog.js CHANGED
@@ -1,9 +1,16 @@
1
1
  // src/posthog.ts
2
+ function isThenable(value) {
3
+ return typeof value === "object" && value !== null && typeof value.then === "function";
4
+ }
2
5
  function createPostHogOutput(capture) {
3
6
  return (entry) => {
4
7
  try {
5
8
  const { event, ...properties } = entry;
6
- capture(event, properties);
9
+ const result = capture(event, properties);
10
+ if (isThenable(result)) {
11
+ Promise.resolve(result).catch(() => {
12
+ });
13
+ }
7
14
  } catch {
8
15
  }
9
16
  };
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as LogEntry, c as LogOutput } from './core-BKAGZb-m.js';
1
+ import { LogEntry, LogOutput } from './index.js';
2
2
 
3
3
  /**
4
4
  * @vllnt/logger — Test utilities.
@@ -14,4 +14,5 @@ type TestOutput = {
14
14
  /** Create a test output that captures entries into an array for assertion. */
15
15
  declare function createTestOutput(): TestOutput;
16
16
 
17
- export { type TestOutput, createTestOutput };
17
+ export { createTestOutput };
18
+ export type { TestOutput };
package/docs/API.md ADDED
@@ -0,0 +1,242 @@
1
+ # @vllnt/logger API
2
+
3
+ Reference for every public export. This file ships in the npm package, so the copy at
4
+ `node_modules/@vllnt/logger/docs/API.md` matches the installed version. The TypeScript sources
5
+ ship in `node_modules/@vllnt/logger/src/`.
6
+
7
+ ## Entry points
8
+
9
+ The package is ESM only (`import`; there is no `require` condition). Every entry point ships
10
+ its own type declarations.
11
+
12
+ | Import | Exports |
13
+ | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
14
+ | `@vllnt/logger` | `createBackendLogger`, `createLogger`, `createExtendedLogger`, `consoleOutput`, `composeOutputs`, `formatLogEntry`, `parseLogLevel`; types `LogLevel`, `LogData`, `LogEntry`, `LogOutput`, `Logger`, `ExtendedLogger`, `LoggerConfig` |
15
+ | `@vllnt/logger/convex` | `createConvexLogger` |
16
+ | `@vllnt/logger/posthog` | `createPostHogOutput`; type `PostHogCapture` |
17
+ | `@vllnt/logger/testing` | `createTestOutput`; type `TestOutput` |
18
+
19
+ Shared types (`LogEntry`, `LogLevel`, …) are exported only from `@vllnt/logger`.
20
+
21
+ Examples use placeholders (`posthog` for a posthog-js instance, `apiKey`, `distinctId`,
22
+ `fetchRows`, `orderId`) and Vitest's `expect`.
23
+
24
+ ## Behaviour shared by every logger
25
+
26
+ - The emitted `event` is `<scope>.<event>`: `createLogger("auth", …).info("login")` emits
27
+ `auth.login`.
28
+ - Levels by severity: `debug` < `info` < `warn` < `error`. An entry is emitted when its level is
29
+ at or above the configured level.
30
+ - `getLogLevel` runs on every log call. Its result goes through `parseLogLevel`; an invalid value
31
+ or a throw falls back to `info`.
32
+ - Log calls never throw. A throwing `getLogLevel`, output or data getter is swallowed.
33
+ - Data is spread first, then `event`, `level` and `timestamp` (ISO 8601), so data cannot
34
+ overwrite those three fields.
35
+ - Outputs are synchronous. There is no built-in redaction.
36
+
37
+ ## `@vllnt/logger`
38
+
39
+ ### `createBackendLogger(scope: string): ExtendedLogger`
40
+
41
+ Node.js preset. Reads `LOG_LEVEL` from `process.env` on each call, parsed with
42
+ `parseLogLevel(value, "warn")`, so the default is `warn`. Without `process` it uses `warn`.
43
+ Writes with `consoleOutput`.
44
+
45
+ ```ts
46
+ import { createBackendLogger } from "@vllnt/logger";
47
+
48
+ const logger = createBackendLogger("payments");
49
+ logger.warn("charge.declined", { amount: 99 });
50
+ // console.warn: {"amount":99,"event":"payments.charge.declined","level":"warn","timestamp":"2026-11-27T12:00:00.000Z"}
51
+ ```
52
+
53
+ ### `createLogger(scope: string, config: LoggerConfig): Logger`
54
+
55
+ Core factory with your own level source and output.
56
+
57
+ ```ts
58
+ import { consoleOutput, createLogger } from "@vllnt/logger";
59
+
60
+ const logger = createLogger("api", {
61
+ getLogLevel: () => "debug",
62
+ output: consoleOutput,
63
+ });
64
+ logger.debug("request", { path: "/health" });
65
+ ```
66
+
67
+ ### `createExtendedLogger(scope: string, config: LoggerConfig): ExtendedLogger`
68
+
69
+ `createLogger` plus `withTiming` and `withTimingSync`:
70
+
71
+ - `withTiming<T>(label: string, execute: () => Promise<T>, extraData?: LogData): Promise<T>`
72
+ - `withTimingSync<T>(label: string, execute: () => T, extraData?: LogData): T`
73
+
74
+ Both log `info` `<scope>.<label>.start` with `extraData`, then `info` `<scope>.<label>.complete`
75
+ with `extraData` and `durationMs`. If `execute` throws, they log `error` `<scope>.<label>.error`
76
+ with `extraData`, `durationMs` and `error` (the `Error` message, otherwise `String(value)`, or
77
+ `"[unprintable error]"`), then rethrow the original error. The message is logged verbatim.
78
+ An entry whose `extraData` cannot be read (for example a throwing getter) is dropped; the helpers
79
+ still return the result or rethrow the original error.
80
+
81
+ ```ts
82
+ import { consoleOutput, createExtendedLogger } from "@vllnt/logger";
83
+
84
+ const logger = createExtendedLogger("db", {
85
+ getLogLevel: () => "info",
86
+ output: consoleOutput,
87
+ });
88
+ const rows = await logger.withTiming("query", () => fetchRows(), { table: "users" });
89
+ // db.query.start, then db.query.complete with durationMs
90
+ ```
91
+
92
+ ### `consoleOutput(entry: LogEntry): void`
93
+
94
+ Default output. Writes `JSON.stringify(entry)` to `console.debug`, `console.info`,
95
+ `console.warn` or `console.error` by level. `BigInt` is written as a string, `Error` as
96
+ `{ name, message, stack }`, a circular reference as `"[Circular]"`. If serialization still fails
97
+ (a throwing `toJSON` or getter) it writes `[logger:serialize-error] event=<event> level=<level>`.
98
+ A throwing `console` method is swallowed.
99
+
100
+ ```ts
101
+ import { consoleOutput, formatLogEntry } from "@vllnt/logger";
102
+
103
+ consoleOutput(formatLogEntry("error", "job.failed", { error: new Error("timeout") }));
104
+ ```
105
+
106
+ ### `composeOutputs(...outputs: LogOutput[]): LogOutput`
107
+
108
+ Returns one output that calls each output in order. A throwing output does not stop the others.
109
+
110
+ ```ts
111
+ import { composeOutputs, consoleOutput } from "@vllnt/logger";
112
+ import { createPostHogOutput } from "@vllnt/logger/posthog";
113
+
114
+ const output = composeOutputs(consoleOutput, createPostHogOutput(posthog.capture.bind(posthog)));
115
+ ```
116
+
117
+ ### `formatLogEntry(level: LogLevel, event: string, data?: LogData): LogEntry`
118
+
119
+ Builds an entry: `{ ...data, event, level, timestamp }`. It does not add a scope prefix.
120
+
121
+ ```ts
122
+ import { formatLogEntry } from "@vllnt/logger";
123
+
124
+ formatLogEntry("info", "cache.hit", { key: "user:1" });
125
+ // { key: "user:1", event: "cache.hit", level: "info", timestamp: "2026-11-27T12:00:00.000Z" }
126
+ ```
127
+
128
+ ### `parseLogLevel(value: string | undefined, defaultLevel?: LogLevel): LogLevel`
129
+
130
+ Trims and lowercases `value`. Returns it when it is `debug`, `info`, `warn` or `error`, otherwise
131
+ `defaultLevel` (default `info`).
132
+
133
+ ```ts
134
+ import { parseLogLevel } from "@vllnt/logger";
135
+
136
+ parseLogLevel(" WARN "); // "warn"
137
+ parseLogLevel("verbose", "error"); // "error"
138
+ ```
139
+
140
+ ### Types
141
+
142
+ ```ts
143
+ type LogLevel = "debug" | "error" | "info" | "warn";
144
+ type LogData = Record<string, unknown>;
145
+ type LogEntry = { event: string; level: LogLevel; timestamp: string } & Record<string, unknown>;
146
+ type LogOutput = (entry: LogEntry) => void;
147
+
148
+ type Logger = {
149
+ debug: (event: string, data?: LogData) => void;
150
+ error: (event: string, data?: LogData) => void;
151
+ info: (event: string, data?: LogData) => void;
152
+ warn: (event: string, data?: LogData) => void;
153
+ };
154
+
155
+ type ExtendedLogger = Logger & {
156
+ withTiming: <T>(label: string, execute: () => Promise<T>, extraData?: LogData) => Promise<T>;
157
+ withTimingSync: <T>(label: string, execute: () => T, extraData?: LogData) => T;
158
+ };
159
+
160
+ type LoggerConfig = {
161
+ /** Called on every log call. */
162
+ getLogLevel: () => LogLevel;
163
+ output: LogOutput;
164
+ };
165
+ ```
166
+
167
+ ## `@vllnt/logger/convex`
168
+
169
+ ### `createConvexLogger(scope: string, level?: LogLevel): ExtendedLogger`
170
+
171
+ Logger for Convex queries, mutations and actions. Uses the fixed `level` (default `info`) and
172
+ `consoleOutput`. It does not read `process.env`.
173
+
174
+ ```ts
175
+ import { createConvexLogger } from "@vllnt/logger/convex";
176
+
177
+ const logger = createConvexLogger("orders", "debug");
178
+ logger.info("created", { orderId });
179
+ ```
180
+
181
+ ## `@vllnt/logger/posthog`
182
+
183
+ ### `createPostHogOutput(capture: PostHogCapture): LogOutput`
184
+
185
+ Calls `capture(entry.event, properties)`, where `properties` is the entry without `event`
186
+ (`level`, `timestamp` and your data). Errors thrown by `capture`, and rejections of a promise it
187
+ returns, are swallowed. No PostHog SDK dependency: pass your own function. posthog-js
188
+ `capture(event, properties)` takes the same parameters; the arrow wrapper keeps its `this` bound:
189
+
190
+ ```ts
191
+ import { createLogger } from "@vllnt/logger";
192
+ import { createPostHogOutput } from "@vllnt/logger/posthog";
193
+
194
+ const logger = createLogger("billing", {
195
+ getLogLevel: () => "info",
196
+ output: createPostHogOutput((event, properties) => posthog.capture(event, properties)),
197
+ });
198
+ ```
199
+
200
+ posthog-node `capture` takes one object, so wrap it. The `= {}` default keeps the wrapper valid
201
+ under `exactOptionalPropertyTypes`, where posthog-node's `properties` does not accept `undefined`:
202
+
203
+ ```ts
204
+ import { createPostHogOutput } from "@vllnt/logger/posthog";
205
+ import { PostHog } from "posthog-node";
206
+
207
+ const client = new PostHog(apiKey);
208
+ const output = createPostHogOutput((event, properties = {}) =>
209
+ client.capture({ distinctId, event, properties }),
210
+ );
211
+ ```
212
+
213
+ ### `PostHogCapture`
214
+
215
+ ```ts
216
+ type PostHogCapture = (event: string, properties?: Record<string, unknown>) => unknown;
217
+ ```
218
+
219
+ ## `@vllnt/logger/testing`
220
+
221
+ ### `createTestOutput(): TestOutput`
222
+
223
+ An output that stores every entry in `entries`, for assertions.
224
+
225
+ ```ts
226
+ import { createLogger } from "@vllnt/logger";
227
+ import { createTestOutput } from "@vllnt/logger/testing";
228
+
229
+ const { entries, output } = createTestOutput();
230
+ const logger = createLogger("test", { getLogLevel: () => "debug", output });
231
+ logger.info("hello", { a: 1 });
232
+ expect(entries[0]).toMatchObject({ event: "test.hello", level: "info", a: 1 });
233
+ ```
234
+
235
+ ### `TestOutput`
236
+
237
+ ```ts
238
+ type TestOutput = {
239
+ entries: readonly LogEntry[];
240
+ output: LogOutput;
241
+ };
242
+ ```
package/llms.txt ADDED
@@ -0,0 +1,51 @@
1
+ # @vllnt/logger
2
+
3
+ > Zero-dependency structured JSON logger for TypeScript with scoped events, log levels, timing, and console, PostHog and test outputs for Node.js and Convex.
4
+
5
+ Scoped events (`auth.login`), levels `debug`, `info`, `warn`, `error`, and pluggable synchronous outputs. Log calls never throw. The Node.js preset `createBackendLogger` reads `LOG_LEVEL` from `process.env` on each call and defaults to `warn`. There is no built-in redaction. ESM only; TypeScript `moduleResolution` must be `nodenext`, `node16` or `bundler`.
6
+
7
+ ## For coding agents
8
+
9
+ The docs are bundled in the package at `node_modules/@vllnt/logger/docs/`, with the TypeScript sources in `node_modules/@vllnt/logger/src/`. They match the installed version. Read them before writing code.
10
+
11
+ ## When to use
12
+
13
+ - Use it when you want one JSON line per event, with a scoped event name, from TypeScript.
14
+ - Use it when the same logger API must run in Node.js and in Convex queries, mutations and actions.
15
+ - Use it when log entries should go to several outputs, such as the console and PostHog.
16
+ - Use it when tests should assert on log entries instead of console output.
17
+ - Do not use it when you need log transports, files, rotation, redaction or async batching: use pino or winston.
18
+ - Do not use it when entries must be stored and queried later: use [`@vllnt/convex-events`](https://oss.vllnt.com/packages/convex-events).
19
+ - Do not use it for product analytics with consent: use [`@vllnt/analytics`](https://oss.vllnt.com/packages/analytics).
20
+
21
+ ## Docs
22
+
23
+ - [API Reference](./docs/API.md): Every public export, its signature and an example, per entry point
24
+ - [Errors and fixes](./README.md#errors-and-fixes): Every error message and marker, its cause and the fix
25
+ - [Limits and gotchas](./README.md#limits-and-gotchas): Defaults and calls that silently do nothing
26
+ - [README](./README.md): Install, quick start, API table, common tasks and compatibility
27
+ - [Changelog](./CHANGELOG.md): Version history and release notes
28
+ - [Links](./README.md#links): Package page, release feed, source, issues, npm and community links
29
+
30
+ ## Entry points
31
+
32
+ - `@vllnt/logger`: core API and Node.js preset (`createBackendLogger`)
33
+ - `@vllnt/logger/convex`: `createConvexLogger`, no `process.env` access
34
+ - `@vllnt/logger/posthog`: `createPostHogOutput`
35
+ - `@vllnt/logger/testing`: `createTestOutput`
36
+
37
+ ## Optional
38
+
39
+ - [Contributing](https://github.com/vllnt/logger/blob/main/CONTRIBUTING.md): Development setup and release flow
40
+ - [AGENTS](https://github.com/vllnt/logger/blob/main/AGENTS.md): Agent instructions for working on this repository (not shipped in the package)
41
+ - [Security Policy](https://github.com/vllnt/logger/blob/main/SECURITY.md): Vulnerability reporting
42
+ - [License](./LICENSE): MIT
43
+
44
+ ## Ecosystem
45
+
46
+ - [Package page](https://oss.vllnt.com/packages/logger)
47
+ - [Release feed](https://oss.vllnt.com/packages/logger/rss.xml)
48
+ - [All @vllnt packages](https://oss.vllnt.com/llms.txt)
49
+ - [Search vllnt packages and docs](https://index.vllnt.com)
50
+ - [vllnt](https://vllnt.com/llms.txt)
51
+ - [Author](https://bntvllnt.com)
package/package.json CHANGED
@@ -1,56 +1,103 @@
1
1
  {
2
2
  "name": "@vllnt/logger",
3
- "version": "0.1.2",
3
+ "version": "0.1.3-canary.1b2dbd3",
4
4
  "type": "module",
5
- "description": "Structured logging for the @vllnt ecosystem",
5
+ "description": "Zero-dependency structured JSON logger for TypeScript with scoped events, log levels, timing, and console, PostHog and test outputs for Node.js and Convex.",
6
6
  "license": "MIT",
7
- "author": "bntvllnt",
7
+ "author": {
8
+ "name": "bntvllnt",
9
+ "url": "https://bntvllnt.com"
10
+ },
11
+ "funding": {
12
+ "type": "github",
13
+ "url": "https://github.com/sponsors/bntvllnt"
14
+ },
15
+ "homepage": "https://oss.vllnt.com/packages/logger",
8
16
  "repository": {
9
17
  "type": "git",
10
18
  "url": "https://github.com/vllnt/logger"
11
19
  },
20
+ "bugs": {
21
+ "url": "https://github.com/vllnt/logger/issues"
22
+ },
23
+ "keywords": [
24
+ "logger",
25
+ "logging",
26
+ "structured-logging",
27
+ "json-logger",
28
+ "log-levels",
29
+ "typescript",
30
+ "nodejs",
31
+ "convex",
32
+ "posthog",
33
+ "zero-dependency",
34
+ "esm"
35
+ ],
12
36
  "sideEffects": false,
13
37
  "exports": {
14
38
  ".": {
15
- "import": "./dist/index.js",
16
- "types": "./dist/index.d.ts"
39
+ "types": "./dist/index.d.ts",
40
+ "import": "./dist/index.js"
17
41
  },
18
42
  "./convex": {
19
- "import": "./dist/convex.js",
20
- "types": "./dist/convex.d.ts"
43
+ "types": "./dist/convex.d.ts",
44
+ "import": "./dist/convex.js"
21
45
  },
22
46
  "./posthog": {
23
- "import": "./dist/posthog.js",
24
- "types": "./dist/posthog.d.ts"
47
+ "types": "./dist/posthog.d.ts",
48
+ "import": "./dist/posthog.js"
25
49
  },
26
50
  "./testing": {
27
- "import": "./dist/testing.js",
28
- "types": "./dist/testing.d.ts"
51
+ "types": "./dist/testing.d.ts",
52
+ "import": "./dist/testing.js"
29
53
  }
30
54
  },
31
55
  "files": [
32
- "dist"
56
+ "dist",
57
+ "src",
58
+ "docs/API.md",
59
+ "CHANGELOG.md",
60
+ "llms.txt"
33
61
  ],
62
+ "scripts": {
63
+ "build": "tsup",
64
+ "check-types": "tsc --noEmit -p tsconfig.check.json --incremental --tsBuildInfoFile node_modules/.cache/tsc/check-types.tsbuildinfo",
65
+ "lint": "eslint --cache --cache-location node_modules/.cache/eslint/ --max-warnings 0",
66
+ "lint:fix": "eslint --cache --cache-location node_modules/.cache/eslint/ --fix",
67
+ "test": "vitest run",
68
+ "test:coverage": "vitest run --coverage --coverage.include=src --coverage.reporter=text",
69
+ "test:package": "bash scripts/test-package.sh",
70
+ "test:watch": "vitest"
71
+ },
34
72
  "publishConfig": {
35
73
  "access": "public",
36
74
  "registry": "https://registry.npmjs.org/"
37
75
  },
38
76
  "devDependencies": {
39
- "@types/node": "^22.15.3",
40
- "@vllnt/eslint-config": "^1.0.0",
41
- "@vllnt/typescript": "^1.0.0",
42
- "eslint": "^9.39.4",
43
- "prettier": "^3.8.1",
44
- "tsup": "^8.4.0",
45
- "typescript": "^5.9.3",
46
- "vitest": "^3.1.1"
77
+ "@types/node": "^26.6.6",
78
+ "@vitest/coverage-v8": "^5.1.1",
79
+ "@vllnt/eslint-config": "^2.1.0",
80
+ "@vllnt/typescript": "^3.0.0",
81
+ "eslint": "^9.39.5",
82
+ "posthog-node": "^6.0.5",
83
+ "prettier": "^3.10.1",
84
+ "tsup": "^9.0.0",
85
+ "typescript": "^6.0.3",
86
+ "vitest": "^5.1.1"
47
87
  },
48
- "scripts": {
49
- "build": "tsup",
50
- "check-types": "tsc --noEmit",
51
- "lint": "eslint --max-warnings 0",
52
- "lint:fix": "eslint --fix",
53
- "test": "vitest run",
54
- "test:watch": "vitest"
88
+ "packageManager": "pnpm@10.34.8",
89
+ "pnpm": {
90
+ "minimumReleaseAge": 10080,
91
+ "minimumReleaseAgeExclude": [
92
+ "@vllnt/*"
93
+ ],
94
+ "ignoredBuiltDependencies": [
95
+ "esbuild"
96
+ ],
97
+ "overrides": {
98
+ "minimatch@>=7.0.0 <11.0.1": "11.0.5",
99
+ "deepmerge-ts@<8.0.0": "^8.0.0",
100
+ "handlebars@<4.7.10": "^4.7.10"
101
+ }
55
102
  }
56
- }
103
+ }
package/src/backend.ts ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @vllnt/logger — Backend preset.
3
+ *
4
+ * Pre-configured logger for Node.js backends.
5
+ * Reads LOG_LEVEL from process.env on each call (no module-level side effects).
6
+ */
7
+
8
+ import {
9
+ consoleOutput,
10
+ createExtendedLogger,
11
+ type ExtendedLogger,
12
+ type LogLevel,
13
+ parseLogLevel,
14
+ } from "./core.js";
15
+
16
+ const HAS_PROCESS = typeof process !== "undefined";
17
+
18
+ function getEnvironmentVariable(key: string): string | undefined {
19
+ if (HAS_PROCESS && process.env) {
20
+ return process.env[key];
21
+ }
22
+ return undefined;
23
+ }
24
+
25
+ function getBackendLogLevel(): LogLevel {
26
+ return parseLogLevel(getEnvironmentVariable("LOG_LEVEL"), "warn");
27
+ }
28
+
29
+ /**
30
+ * Create a scoped Node.js logger that writes with `consoleOutput`. Reads
31
+ * `LOG_LEVEL` from `process.env` on each call; the default is `warn`.
32
+ *
33
+ * @see https://oss.vllnt.com/packages/logger
34
+ */
35
+ export function createBackendLogger(scope: string): ExtendedLogger {
36
+ return createExtendedLogger(scope, {
37
+ getLogLevel: getBackendLogLevel,
38
+ output: consoleOutput,
39
+ });
40
+ }
package/src/convex.ts ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @vllnt/logger — Convex-safe logger.
3
+ *
4
+ * Imports from core.ts (no process.env, no crypto).
5
+ * Works in Convex queries, mutations, and actions.
6
+ */
7
+
8
+ import {
9
+ consoleOutput,
10
+ createExtendedLogger,
11
+ type ExtendedLogger,
12
+ type LogLevel,
13
+ } from "./core.js";
14
+
15
+ /**
16
+ * Create a logger for Convex functions.
17
+ * Pass the level explicitly; this logger never reads `process.env`.
18
+ * Defaults to "info".
19
+ */
20
+ export function createConvexLogger(
21
+ scope: string,
22
+ level: LogLevel = "info",
23
+ ): ExtendedLogger {
24
+ return createExtendedLogger(scope, {
25
+ getLogLevel: () => level,
26
+ output: consoleOutput,
27
+ });
28
+ }