@wild-framework/logging-pino 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 +21 -0
- package/README.md +31 -2
- package/dist/driver.d.ts +16 -0
- package/dist/driver.d.ts.map +1 -0
- package/dist/driver.js +42 -0
- package/dist/driver.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.d.ts +17 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +23 -0
- package/dist/provider.js.map +1 -0
- package/package.json +44 -3
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,32 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @wild-framework/logging-pino
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Pino driver for [Wild Framework](https://github.com/KhandaSoftware/wild-framework)'s logging package.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @wild-framework/logging-pino
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { PinoLoggerProvider } from "@wild-framework/logging-pino";
|
|
15
|
+
|
|
16
|
+
PinoLoggerProvider.level = "info";
|
|
17
|
+
app.register(PinoLoggerProvider);
|
|
18
|
+
|
|
19
|
+
const logger = app.resolve(Logger);
|
|
20
|
+
logger.info("order placed", { orderId: 42 });
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Emits fast, structured NDJSON via [pino](https://getpino.io/). Pipe through
|
|
24
|
+
`pino-pretty` in development:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pnpm dev | pino-pretty
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## License
|
|
31
|
+
|
|
32
|
+
MIT
|
package/dist/driver.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Logger as PinoLogger } from "pino";
|
|
2
|
+
import type { LoggerDriver, LogLevel } from "@wild-framework/logging";
|
|
3
|
+
/**
|
|
4
|
+
* Pino-backed logging driver implementing `LoggerDriver`.
|
|
5
|
+
*
|
|
6
|
+
* Maps the Wild Framework levels onto Pino's `trace…fatal` methods and
|
|
7
|
+
* `child()` onto `pino.child()` — so structured bindings are native.
|
|
8
|
+
*/
|
|
9
|
+
export declare class PinoLoggerDriver implements LoggerDriver {
|
|
10
|
+
private logger;
|
|
11
|
+
constructor(logger?: PinoLogger);
|
|
12
|
+
log(level: LogLevel, message: string, context?: Record<string, unknown>): void;
|
|
13
|
+
child(bindings: Record<string, unknown>): LoggerDriver;
|
|
14
|
+
private writer;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=driver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAAA,OAAa,EAAE,KAAK,MAAM,IAAI,UAAU,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEtE;;;;;GAKG;AACH,qBAAa,gBAAiB,YAAW,YAAY;IACrC,OAAO,CAAC,MAAM;gBAAN,MAAM,GAAE,UAAmB;IAE/C,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAS9E,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY;IAItD,OAAO,CAAC,MAAM;CAgBjB"}
|
package/dist/driver.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import pino, {} from "pino";
|
|
2
|
+
/**
|
|
3
|
+
* Pino-backed logging driver implementing `LoggerDriver`.
|
|
4
|
+
*
|
|
5
|
+
* Maps the Wild Framework levels onto Pino's `trace…fatal` methods and
|
|
6
|
+
* `child()` onto `pino.child()` — so structured bindings are native.
|
|
7
|
+
*/
|
|
8
|
+
export class PinoLoggerDriver {
|
|
9
|
+
logger;
|
|
10
|
+
constructor(logger = pino()) {
|
|
11
|
+
this.logger = logger;
|
|
12
|
+
}
|
|
13
|
+
log(level, message, context) {
|
|
14
|
+
const write = this.writer(level);
|
|
15
|
+
if (context) {
|
|
16
|
+
write(context, message);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
write(message);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
child(bindings) {
|
|
23
|
+
return new PinoLoggerDriver(this.logger.child(bindings));
|
|
24
|
+
}
|
|
25
|
+
writer(level) {
|
|
26
|
+
switch (level) {
|
|
27
|
+
case "trace":
|
|
28
|
+
return (o, m) => (m === undefined ? this.logger.trace(o) : this.logger.trace(o, m));
|
|
29
|
+
case "debug":
|
|
30
|
+
return (o, m) => (m === undefined ? this.logger.debug(o) : this.logger.debug(o, m));
|
|
31
|
+
case "info":
|
|
32
|
+
return (o, m) => (m === undefined ? this.logger.info(o) : this.logger.info(o, m));
|
|
33
|
+
case "warn":
|
|
34
|
+
return (o, m) => (m === undefined ? this.logger.warn(o) : this.logger.warn(o, m));
|
|
35
|
+
case "error":
|
|
36
|
+
return (o, m) => (m === undefined ? this.logger.error(o) : this.logger.error(o, m));
|
|
37
|
+
case "fatal":
|
|
38
|
+
return (o, m) => (m === undefined ? this.logger.fatal(o) : this.logger.fatal(o, m));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=driver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAA6B,MAAM,MAAM,CAAC;AAGvD;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IACL;IAApB,YAAoB,SAAqB,IAAI,EAAE;QAA3B,WAAM,GAAN,MAAM,CAAqB;IAAG,CAAC;IAEnD,GAAG,CAAC,KAAe,EAAE,OAAe,EAAE,OAAiC;QACnE,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,OAAO,EAAE,CAAC;YACV,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5B,CAAC;aAAM,CAAC;Y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CAAC,CAAC,CAAC,CAAC;YACtF,KAAK,OAAO;gBACR,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YACxF,KAAK,OAAO;gBACR,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC5F,CAAC;IACL,CAAC;CACJ"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Provider, Application } from "@wild-framework/core";
|
|
2
|
+
import { type LogLevel } from "@wild-framework/logging";
|
|
3
|
+
/**
|
|
4
|
+
* Registers a Pino-backed logger with the application.
|
|
5
|
+
*
|
|
6
|
+
* Static configuration (no-arg constructor requirement):
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* PinoLoggerProvider.level = "info";
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare class PinoLoggerProvider implements Provider {
|
|
13
|
+
/** Minimum level to emit. Defaults to `"info"`. */
|
|
14
|
+
static level: LogLevel;
|
|
15
|
+
register(app: Application): void;
|
|
16
|
+
}
|
|
17
|
+
//# 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;AAElE,OAAO,EAAU,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAIhE;;;;;;;;GAQG;AACH,qBAAa,kBAAmB,YAAW,QAAQ;IAC/C,mDAAmD;IACnD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAU;IAEhC,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;CAKnC"}
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Container } from "@wild-framework/container";
|
|
2
|
+
import { Logger } from "@wild-framework/logging";
|
|
3
|
+
import pino from "pino";
|
|
4
|
+
import { PinoLoggerDriver } from "./driver.js";
|
|
5
|
+
/**
|
|
6
|
+
* Registers a Pino-backed logger with the application.
|
|
7
|
+
*
|
|
8
|
+
* Static configuration (no-arg constructor requirement):
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* PinoLoggerProvider.level = "info";
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export class PinoLoggerProvider {
|
|
15
|
+
/** Minimum level to emit. Defaults to `"info"`. */
|
|
16
|
+
static level = "info";
|
|
17
|
+
register(app) {
|
|
18
|
+
const container = app.resolve(Container);
|
|
19
|
+
const logger = new Logger(new PinoLoggerDriver(pino({ level: PinoLoggerProvider.level })));
|
|
20
|
+
container.singleton(Logger, () => logger);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# 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,EAAiB,MAAM,yBAAyB,CAAC;AAChE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAAkB;IAC3B,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,gBAAgB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3F,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wild-framework/logging-pino",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
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": "Pino logging driver for Wild Framework's logging package.",
|
|
26
|
+
"keywords": [
|
|
27
|
+
"wild",
|
|
28
|
+
"framework",
|
|
29
|
+
"logging",
|
|
30
|
+
"logger",
|
|
31
|
+
"pino"
|
|
32
|
+
],
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"pino": "^9.0.0",
|
|
35
|
+
"@wild-framework/core": "0.2.0",
|
|
36
|
+
"@wild-framework/logging": "0.2.0",
|
|
37
|
+
"@wild-framework/container": "0.2.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"pino-pretty": "^11.0.0"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc",
|
|
44
|
+
"clean": "rm -rf dist",
|
|
45
|
+
"test": "vitest run"
|
|
46
|
+
}
|
|
6
47
|
}
|