@wild-framework/logging 0.0.0-stage → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Wild Framework contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,35 @@
1
- # Temporary Holding Version
1
+ # @wild-framework/logging
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Structured logging abstraction for [Wild Framework](https://github.com/KhandaSoftware/wild-framework).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @wild-framework/logging
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { Logger, LoggerProvider } from "@wild-framework/logging";
15
+
16
+ LoggerProvider.level = "info";
17
+ app.register(LoggerProvider);
18
+
19
+ const logger = app.resolve(Logger);
20
+ logger.info("order placed", { orderId: 42 });
21
+ logger.error("payment failed", { orderId: 42, reason: "declined" });
22
+
23
+ const child = logger.child({ module: "orders" });
24
+ child.warn("low stock", { productId: 1 });
25
+ ```
26
+
27
+ Every line automatically carries the current request context (e.g.
28
+ `requestId`) when running inside a request.
29
+
30
+ Ships with a zero-dependency console driver. For structured JSON + fast
31
+ output, use `@wild-framework/logging-pino`.
32
+
33
+ ## License
34
+
35
+ MIT
@@ -0,0 +1,16 @@
1
+ import { type LoggerDriver, type LogLevel } from "./driver.js";
2
+ /**
3
+ * Zero-dependency console driver.
4
+ *
5
+ * Emits one JSON line per entry (structured, greppable) to stdout, or
6
+ * stderr for `error`/`fatal`. The default driver — no external logger
7
+ * required.
8
+ */
9
+ export declare class ConsoleLoggerDriver implements LoggerDriver {
10
+ private readonly minLevel;
11
+ private readonly bindings;
12
+ constructor(minLevel?: LogLevel, bindings?: Record<string, unknown>);
13
+ log(level: LogLevel, message: string, context?: Record<string, unknown>): void;
14
+ child(bindings: Record<string, unknown>): LoggerDriver;
15
+ }
16
+ //# sourceMappingURL=console-driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console-driver.d.ts","sourceRoot":"","sources":["../src/console-driver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEhF;;;;;;GAMG;AACH,qBAAa,mBAAoB,YAAW,YAAY;IAEhD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBADR,QAAQ,GAAE,QAAiB,EAC3B,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IAG3D,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAmB9E,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY;CAGzD"}
@@ -0,0 +1,38 @@
1
+ import { LOG_LEVEL_ORDER } from "./driver.js";
2
+ /**
3
+ * Zero-dependency console driver.
4
+ *
5
+ * Emits one JSON line per entry (structured, greppable) to stdout, or
6
+ * stderr for `error`/`fatal`. The default driver — no external logger
7
+ * required.
8
+ */
9
+ export class ConsoleLoggerDriver {
10
+ minLevel;
11
+ bindings;
12
+ constructor(minLevel = "info", bindings = {}) {
13
+ this.minLevel = minLevel;
14
+ this.bindings = bindings;
15
+ }
16
+ log(level, message, context) {
17
+ if (LOG_LEVEL_ORDER[level] < LOG_LEVEL_ORDER[this.minLevel])
18
+ return;
19
+ const entry = {
20
+ level,
21
+ time: new Date().toISOString(),
22
+ msg: message,
23
+ ...this.bindings,
24
+ ...context,
25
+ };
26
+ const line = JSON.stringify(entry);
27
+ if (level === "error" || level === "fatal") {
28
+ console.error(line);
29
+ }
30
+ else {
31
+ console.log(line);
32
+ }
33
+ }
34
+ child(bindings) {
35
+ return new ConsoleLoggerDriver(this.minLevel, { ...this.bindings, ...bindings });
36
+ }
37
+ }
38
+ //# sourceMappingURL=console-driver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console-driver.js","sourceRoot":"","sources":["../src/console-driver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAoC,MAAM,aAAa,CAAC;AAEhF;;;;;;GAMG;AACH,MAAM,OAAO,mBAAmB;IAEP;IACA;IAFrB,YACqB,WAAqB,MAAM,EAC3B,WAAoC,EAAE;QADtC,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,aAAQ,GAAR,QAAQ,CAA8B;IACxD,CAAC;IAEJ,GAAG,CAAC,KAAe,EAAE,OAAe,EAAE,OAAiC;QACnE,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC;YAAE,OAAO;QAEpE,MAAM,KAAK,GAA4B;YACnC,KAAK;YACL,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YAC9B,GAAG,EAAE,OAAO;YACZ,GAAG,IAAI,CAAC,QAAQ;YAChB,GAAG,OAAO;SACb,CAAC;QACF,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAEnC,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC;YACzC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;IACL,CAAC;IAED,KAAK,CAAC,QAAiC;QACnC,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAAC,CAAC;IACrF,CAAC;CACJ"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Run `fn` with `bindings` available via `currentRequestContext()`.
3
+ * The context propagates through any async work started inside `fn`.
4
+ */
5
+ export declare function withRequestContext<T>(bindings: Record<string, unknown>, fn: () => T): T;
6
+ /**
7
+ * The current request context, or `undefined` when outside a request.
8
+ */
9
+ export declare function currentRequestContext(): Record<string, unknown> | undefined;
10
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEvF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAE3E"}
@@ -0,0 +1,23 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ /**
3
+ * Per-request context storage.
4
+ *
5
+ * Request-scoped bindings (e.g. `requestId`) are stored in
6
+ * `AsyncLocalStorage` so they can be read from anywhere — including
7
+ * async callbacks — without threading them through every function.
8
+ */
9
+ const store = new AsyncLocalStorage();
10
+ /**
11
+ * Run `fn` with `bindings` available via `currentRequestContext()`.
12
+ * The context propagates through any async work started inside `fn`.
13
+ */
14
+ export function withRequestContext(bindings, fn) {
15
+ return store.run(bindings, fn);
16
+ }
17
+ /**
18
+ * The current request context, or `undefined` when outside a request.
19
+ */
20
+ export function currentRequestContext() {
21
+ return store.getStore();
22
+ }
23
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,KAAK,GAAG,IAAI,iBAAiB,EAA2B,CAAC;AAE/D;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAI,QAAiC,EAAE,EAAW;IAChF,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACjC,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,17 @@
1
+ /** Standard log levels, from most to least verbose. */
2
+ export type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "fatal";
3
+ /** Numeric severity ordering — used to filter by a minimum level. */
4
+ export declare const LOG_LEVEL_ORDER: Record<LogLevel, number>;
5
+ /**
6
+ * Logger driver contract.
7
+ *
8
+ * Implement this for Pino, Winston, or any backend. App code depends on
9
+ * `Logger`, never on a driver directly.
10
+ */
11
+ export interface LoggerDriver {
12
+ /** Emit a log line. `context` is optional structured data. */
13
+ log(level: LogLevel, message: string, context?: Record<string, unknown>): void;
14
+ /** Return a child driver that inherits these bindings. */
15
+ child(bindings: Record<string, unknown>): LoggerDriver;
16
+ }
17
+ //# sourceMappingURL=driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAE/E,qEAAqE;AACrE,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAOpD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IACzB,8DAA8D;IAC9D,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC/E,0DAA0D;IAC1D,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,CAAC;CAC1D"}
package/dist/driver.js ADDED
@@ -0,0 +1,10 @@
1
+ /** Numeric severity ordering — used to filter by a minimum level. */
2
+ export const LOG_LEVEL_ORDER = {
3
+ trace: 10,
4
+ debug: 20,
5
+ info: 30,
6
+ warn: 40,
7
+ error: 50,
8
+ fatal: 60,
9
+ };
10
+ //# sourceMappingURL=driver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"driver.js","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAGA,qEAAqE;AACrE,MAAM,CAAC,MAAM,eAAe,GAA6B;IACrD,KAAK,EAAE,EAAE;IACT,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,EAAE;IACT,KAAK,EAAE,EAAE;CACZ,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { Logger } from "./logger.js";
2
+ export { ConsoleLoggerDriver } from "./console-driver.js";
3
+ export { NullLoggerDriver } from "./null-driver.js";
4
+ export { LoggerProvider } from "./provider.js";
5
+ export { withRequestContext, currentRequestContext } from "./context.js";
6
+ export { LOG_LEVEL_ORDER } from "./driver.js";
7
+ export type { LoggerDriver, LogLevel } from "./driver.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export { Logger } from "./logger.js";
2
+ export { ConsoleLoggerDriver } from "./console-driver.js";
3
+ export { NullLoggerDriver } from "./null-driver.js";
4
+ export { LoggerProvider } from "./provider.js";
5
+ export { withRequestContext, currentRequestContext } from "./context.js";
6
+ export { LOG_LEVEL_ORDER } from "./driver.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { LoggerDriver } from "./driver.js";
2
+ /**
3
+ * Logging facade.
4
+ *
5
+ * Wraps a `LoggerDriver` and exposes a consistent API.
6
+ * Resolved from the container: `app.resolve(Logger)`.
7
+ *
8
+ * Every log line automatically carries the current request context
9
+ * (e.g. `requestId`), so business code logs stay correlated without
10
+ * passing the request id around.
11
+ */
12
+ export declare class Logger {
13
+ private driver;
14
+ constructor(driver: LoggerDriver);
15
+ trace(message: string, context?: Record<string, unknown>): void;
16
+ debug(message: string, context?: Record<string, unknown>): void;
17
+ info(message: string, context?: Record<string, unknown>): void;
18
+ warn(message: string, context?: Record<string, unknown>): void;
19
+ error(message: string, context?: Record<string, unknown>): void;
20
+ fatal(message: string, context?: Record<string, unknown>): void;
21
+ /** A child logger that always carries the given bindings. */
22
+ child(bindings: Record<string, unknown>): Logger;
23
+ private log;
24
+ }
25
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAY,MAAM,aAAa,CAAC;AAG1D;;;;;;;;;GASG;AACH,qBAAa,MAAM;IACH,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAExC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI/D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI/D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI9D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI9D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI/D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI/D,6DAA6D;IAC7D,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;IAIhD,OAAO,CAAC,GAAG;CAKd"}
package/dist/logger.js ADDED
@@ -0,0 +1,45 @@
1
+ import { currentRequestContext } from "./context.js";
2
+ /**
3
+ * Logging facade.
4
+ *
5
+ * Wraps a `LoggerDriver` and exposes a consistent API.
6
+ * Resolved from the container: `app.resolve(Logger)`.
7
+ *
8
+ * Every log line automatically carries the current request context
9
+ * (e.g. `requestId`), so business code logs stay correlated without
10
+ * passing the request id around.
11
+ */
12
+ export class Logger {
13
+ driver;
14
+ constructor(driver) {
15
+ this.driver = driver;
16
+ }
17
+ trace(message, context) {
18
+ this.log("trace", message, context);
19
+ }
20
+ debug(message, context) {
21
+ this.log("debug", message, context);
22
+ }
23
+ info(message, context) {
24
+ this.log("info", message, context);
25
+ }
26
+ warn(message, context) {
27
+ this.log("warn", message, context);
28
+ }
29
+ error(message, context) {
30
+ this.log("error", message, context);
31
+ }
32
+ fatal(message, context) {
33
+ this.log("fatal", message, context);
34
+ }
35
+ /** A child logger that always carries the given bindings. */
36
+ child(bindings) {
37
+ return new Logger(this.driver.child(bindings));
38
+ }
39
+ log(level, message, context) {
40
+ const request = currentRequestContext();
41
+ const merged = request ? { ...request, ...context } : context;
42
+ this.driver.log(level, message, merged);
43
+ }
44
+ }
45
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD;;;;;;;;;GASG;AACH,MAAM,OAAO,MAAM;IACK;IAApB,YAAoB,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAE5C,KAAK,CAAC,OAAe,EAAE,OAAiC;QACpD,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,OAAiC;QACpD,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,OAAiC;QACnD,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,OAAiC;QACnD,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,OAAiC;QACpD,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,OAAiC;QACpD,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,QAAiC;QACnC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IACnD,CAAC;IAEO,GAAG,CAAC,KAAe,EAAE,OAAe,EAAE,OAAiC;QAC3E,MAAM,OAAO,GAAG,qBAAqB,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;QAC9D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;CACJ"}
@@ -0,0 +1,9 @@
1
+ import type { LoggerDriver } from "./driver.js";
2
+ /**
3
+ * No-op logger. Discards everything. Useful in tests.
4
+ */
5
+ export declare class NullLoggerDriver implements LoggerDriver {
6
+ log(): void;
7
+ child(): LoggerDriver;
8
+ }
9
+ //# sourceMappingURL=null-driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"null-driver.d.ts","sourceRoot":"","sources":["../src/null-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;GAEG;AACH,qBAAa,gBAAiB,YAAW,YAAY;IACjD,GAAG,IAAI,IAAI;IAIX,KAAK,IAAI,YAAY;CAGxB"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * No-op logger. Discards everything. Useful in tests.
3
+ */
4
+ export class NullLoggerDriver {
5
+ log() {
6
+ // intentionally empty
7
+ }
8
+ child() {
9
+ return this;
10
+ }
11
+ }
12
+ //# sourceMappingURL=null-driver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"null-driver.js","sourceRoot":"","sources":["../src/null-driver.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACzB,GAAG;QACC,sBAAsB;IAC1B,CAAC;IAED,KAAK;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ"}
@@ -0,0 +1,21 @@
1
+ import type { Provider, Application } from "@wild-framework/core";
2
+ import type { LogLevel } from "./driver.js";
3
+ /**
4
+ * Registers the logger with the application.
5
+ *
6
+ * Static configuration (no-arg constructor requirement):
7
+ *
8
+ * ```ts
9
+ * LoggerProvider.level = "debug";
10
+ * ```
11
+ *
12
+ * Binds a `Logger` backed by the console driver. Swap drivers by
13
+ * implementing `LoggerDriver` and binding a new `Logger` (e.g.
14
+ * `PinoLoggerProvider` from `@wild-framework/logging-pino`).
15
+ */
16
+ export declare class LoggerProvider implements Provider {
17
+ /** Minimum level to emit. Defaults to `"info"`. */
18
+ static level: LogLevel;
19
+ register(app: Application): void;
20
+ }
21
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIlE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAe,YAAW,QAAQ;IAC3C,mDAAmD;IACnD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAU;IAEhC,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;CAKnC"}
@@ -0,0 +1,26 @@
1
+ import { Container } from "@wild-framework/container";
2
+ import { Logger } from "./logger.js";
3
+ import { ConsoleLoggerDriver } from "./console-driver.js";
4
+ /**
5
+ * Registers the logger with the application.
6
+ *
7
+ * Static configuration (no-arg constructor requirement):
8
+ *
9
+ * ```ts
10
+ * LoggerProvider.level = "debug";
11
+ * ```
12
+ *
13
+ * Binds a `Logger` backed by the console driver. Swap drivers by
14
+ * implementing `LoggerDriver` and binding a new `Logger` (e.g.
15
+ * `PinoLoggerProvider` from `@wild-framework/logging-pino`).
16
+ */
17
+ export class LoggerProvider {
18
+ /** Minimum level to emit. Defaults to `"info"`. */
19
+ static level = "info";
20
+ register(app) {
21
+ const container = app.resolve(Container);
22
+ const logger = new Logger(new ConsoleLoggerDriver(LoggerProvider.level));
23
+ container.singleton(Logger, () => logger);
24
+ }
25
+ }
26
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG1D;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,cAAc;IACvB,mDAAmD;IACnD,MAAM,CAAC,KAAK,GAAa,MAAM,CAAC;IAEhC,QAAQ,CAAC,GAAgB;QACrB,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACzC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,mBAAmB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QACzE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@wild-framework/logging",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "license": "MIT",
20
+ "author": "Sphah",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/KhandaSoftware/wild-framework.git"
24
+ },
25
+ "description": "Structured logging abstraction for Wild Framework (facade + drivers).",
26
+ "keywords": [
27
+ "wild",
28
+ "framework",
29
+ "logging",
30
+ "logger",
31
+ "pino"
32
+ ],
33
+ "dependencies": {
34
+ "@wild-framework/core": "0.2.0",
35
+ "@wild-framework/container": "0.2.0"
36
+ },
37
+ "scripts": {
38
+ "build": "tsc",
39
+ "clean": "rm -rf dist",
40
+ "test": "vitest run"
41
+ }
6
42
  }