@kb-labs/adapters-pino 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/README.md +152 -0
- package/dist/index.d.ts +136 -0
- package/dist/index.js +351 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +13 -0
- package/dist/manifest.js +44 -0
- package/dist/manifest.js.map +1 -0
- package/package.json +49 -0
package/README.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# @kb-labs/adapters-pino
|
|
2
|
+
|
|
3
|
+
> Part of [KB Labs](https://github.com/KirillBaranov/kb-labs) ecosystem. Works exclusively within KB Labs platform.
|
|
4
|
+
|
|
5
|
+
Production-ready structured logger based on Pino with streaming and analytics integration.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
| Property | Value |
|
|
10
|
+
|----------|-------|
|
|
11
|
+
| **Implements** | `ILogger` |
|
|
12
|
+
| **Type** | `core` |
|
|
13
|
+
| **Requires** | None (optional: `analytics`) |
|
|
14
|
+
| **Category** | Logging |
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- **Structured Logging** - JSON-formatted logs with context
|
|
19
|
+
- **High Performance** - Built on Pino (fastest Node.js logger)
|
|
20
|
+
- **Log Levels** - trace, debug, info, warn, error, fatal
|
|
21
|
+
- **Pretty Printing** - Human-readable output for development
|
|
22
|
+
- **Streaming Support** - Buffered log streaming
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pnpm add @kb-labs/adapters-pino
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Configuration
|
|
31
|
+
|
|
32
|
+
Add to your `kb.config.json`:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"platform": {
|
|
37
|
+
"adapters": {
|
|
38
|
+
"logger": "@kb-labs/adapters-pino"
|
|
39
|
+
},
|
|
40
|
+
"adapterOptions": {
|
|
41
|
+
"logger": {
|
|
42
|
+
"level": "info",
|
|
43
|
+
"pretty": false,
|
|
44
|
+
"streaming": {
|
|
45
|
+
"enabled": true,
|
|
46
|
+
"bufferSize": 1000,
|
|
47
|
+
"bufferMaxAge": 3600000
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Options
|
|
56
|
+
|
|
57
|
+
| Option | Type | Default | Description |
|
|
58
|
+
|--------|------|---------|-------------|
|
|
59
|
+
| `level` | `string` | `"info"` | Minimum log level |
|
|
60
|
+
| `pretty` | `boolean` | `false` | Enable pretty printing for development |
|
|
61
|
+
| `streaming.enabled` | `boolean` | `false` | Enable log streaming/buffering |
|
|
62
|
+
| `streaming.bufferSize` | `number` | `1000` | Buffer size for streaming |
|
|
63
|
+
| `streaming.bufferMaxAge` | `number` | `3600000` | Max age of buffered logs (1 hour) |
|
|
64
|
+
|
|
65
|
+
## Usage
|
|
66
|
+
|
|
67
|
+
### Via Platform (Recommended)
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { usePlatform } from '@kb-labs/sdk';
|
|
71
|
+
|
|
72
|
+
const platform = usePlatform();
|
|
73
|
+
|
|
74
|
+
// Basic logging
|
|
75
|
+
platform.logger.info('Server started', { port: 3000 });
|
|
76
|
+
platform.logger.error('Request failed', { error, requestId });
|
|
77
|
+
|
|
78
|
+
// With child logger
|
|
79
|
+
const reqLogger = platform.logger.child({ requestId: 'req-123' });
|
|
80
|
+
reqLogger.info('Processing request');
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Standalone (Testing/Development)
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { createAdapter } from '@kb-labs/adapters-pino';
|
|
87
|
+
|
|
88
|
+
const logger = createAdapter({
|
|
89
|
+
level: 'debug',
|
|
90
|
+
pretty: true
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
logger.info('Hello, world!');
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Adapter Manifest
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
{
|
|
100
|
+
id: 'pino-logger',
|
|
101
|
+
name: 'Pino Logger',
|
|
102
|
+
version: '1.0.0',
|
|
103
|
+
implements: 'ILogger',
|
|
104
|
+
optional: {
|
|
105
|
+
adapters: ['analytics'],
|
|
106
|
+
},
|
|
107
|
+
capabilities: {
|
|
108
|
+
streaming: true,
|
|
109
|
+
},
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Log Levels
|
|
114
|
+
|
|
115
|
+
| Level | When to use |
|
|
116
|
+
|-------|-------------|
|
|
117
|
+
| `trace` | Very detailed debugging info |
|
|
118
|
+
| `debug` | Debugging information |
|
|
119
|
+
| `info` | General operational events |
|
|
120
|
+
| `warn` | Warning conditions |
|
|
121
|
+
| `error` | Error conditions |
|
|
122
|
+
| `fatal` | System is unusable |
|
|
123
|
+
|
|
124
|
+
## FAQ
|
|
125
|
+
|
|
126
|
+
<details>
|
|
127
|
+
<summary><strong>Q: How do I enable pretty printing in development?</strong></summary>
|
|
128
|
+
|
|
129
|
+
Set `pretty: true` in config or use environment:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
KB_LOG_PRETTY=true pnpm dev
|
|
133
|
+
```
|
|
134
|
+
</details>
|
|
135
|
+
|
|
136
|
+
<details>
|
|
137
|
+
<summary><strong>Q: How do I send logs to remote service?</strong></summary>
|
|
138
|
+
|
|
139
|
+
Use `@kb-labs/adapters-pino-http` as a transport to stream logs to REST API.
|
|
140
|
+
</details>
|
|
141
|
+
|
|
142
|
+
## Related Adapters
|
|
143
|
+
|
|
144
|
+
| Adapter | Use Case |
|
|
145
|
+
|---------|----------|
|
|
146
|
+
| `@kb-labs/adapters-pino-http` | HTTP transport for remote logging |
|
|
147
|
+
| `@kb-labs/adapters-log-ringbuffer` | In-memory log streaming |
|
|
148
|
+
| `@kb-labs/adapters-log-sqlite` | Persistent log storage |
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
[KB Public License v1.1](../../LICENSE) - KB Labs Team
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import pino from 'pino';
|
|
2
|
+
import { ILogBuffer, LogRecord, LogQuery, ILogger } from '@kb-labs/core-platform';
|
|
3
|
+
export { manifest } from './manifest.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @module @kb-labs/adapters-pino/log-ring-buffer
|
|
7
|
+
* Ring buffer for in-memory log storage with real-time streaming
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Ring buffer implementation for log storage
|
|
12
|
+
*/
|
|
13
|
+
declare class LogRingBuffer implements ILogBuffer {
|
|
14
|
+
private buffer;
|
|
15
|
+
private subscribers;
|
|
16
|
+
private readonly maxSize;
|
|
17
|
+
private readonly maxAge;
|
|
18
|
+
constructor(maxSize?: number, maxAge?: number);
|
|
19
|
+
/**
|
|
20
|
+
* Append log record to buffer
|
|
21
|
+
*/
|
|
22
|
+
append(record: LogRecord): void;
|
|
23
|
+
/**
|
|
24
|
+
* Query logs with filters
|
|
25
|
+
*/
|
|
26
|
+
query(query?: LogQuery): LogRecord[];
|
|
27
|
+
/**
|
|
28
|
+
* Subscribe to real-time log stream
|
|
29
|
+
*/
|
|
30
|
+
subscribe(callback: (record: LogRecord) => void): () => void;
|
|
31
|
+
/**
|
|
32
|
+
* Find log by ID in buffer
|
|
33
|
+
*/
|
|
34
|
+
findById(id: string): LogRecord | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Get buffer statistics
|
|
37
|
+
*/
|
|
38
|
+
getStats(): {
|
|
39
|
+
total: number;
|
|
40
|
+
bufferSize: number;
|
|
41
|
+
oldestTimestamp: number | null;
|
|
42
|
+
newestTimestamp: number | null;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @module @kb-labs/adapters-pino
|
|
48
|
+
* Pino adapter implementing ILogger interface.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* import { createAdapter } from '@kb-labs/adapters-pino';
|
|
53
|
+
*
|
|
54
|
+
* const logger = createAdapter({
|
|
55
|
+
* level: 'info',
|
|
56
|
+
* pretty: true,
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* logger.info('Server started', { port: 3000 });
|
|
60
|
+
* logger.error('Failed to connect', new Error('Connection timeout'));
|
|
61
|
+
*
|
|
62
|
+
* const childLogger = logger.child({ service: 'api' });
|
|
63
|
+
* childLogger.debug('Request received');
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Configuration for log streaming/buffering
|
|
69
|
+
*/
|
|
70
|
+
interface StreamingConfig {
|
|
71
|
+
/** Enable log buffering for streaming (default: false) */
|
|
72
|
+
enabled: boolean;
|
|
73
|
+
/** Maximum buffer size (number of log records, default: 1000) */
|
|
74
|
+
bufferSize?: number;
|
|
75
|
+
/** Maximum age of logs in buffer (milliseconds, default: 3600000 = 1 hour) */
|
|
76
|
+
bufferMaxAge?: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Configuration for Pino logger adapter.
|
|
80
|
+
*/
|
|
81
|
+
interface PinoLoggerConfig {
|
|
82
|
+
/** Log level (default: 'info') */
|
|
83
|
+
level?: "trace" | "debug" | "info" | "warn" | "error" | "fatal";
|
|
84
|
+
/** Enable pretty printing for development (default: false) */
|
|
85
|
+
pretty?: boolean;
|
|
86
|
+
/** Streaming configuration (optional) */
|
|
87
|
+
streaming?: StreamingConfig;
|
|
88
|
+
/** Additional pino options */
|
|
89
|
+
options?: pino.LoggerOptions;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Pino implementation of ILogger interface.
|
|
93
|
+
*/
|
|
94
|
+
declare class PinoLoggerAdapter implements ILogger {
|
|
95
|
+
private pino;
|
|
96
|
+
private logBuffer?;
|
|
97
|
+
private logCallbacks;
|
|
98
|
+
private bindings;
|
|
99
|
+
constructor(config?: PinoLoggerConfig);
|
|
100
|
+
/**
|
|
101
|
+
* Emit log record to all registered callbacks (extensions).
|
|
102
|
+
* Fire-and-forget - errors in callbacks don't block logging.
|
|
103
|
+
*/
|
|
104
|
+
private emitLog;
|
|
105
|
+
/**
|
|
106
|
+
* Internal constructor for child loggers.
|
|
107
|
+
*/
|
|
108
|
+
private constructor_child;
|
|
109
|
+
private mergeBindings;
|
|
110
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
111
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
112
|
+
error(message: string, error?: Error, meta?: Record<string, unknown>): void;
|
|
113
|
+
fatal(message: string, error?: Error, meta?: Record<string, unknown>): void;
|
|
114
|
+
debug(message: string, meta?: Record<string, unknown>): void;
|
|
115
|
+
trace(message: string, meta?: Record<string, unknown>): void;
|
|
116
|
+
child(bindings: Record<string, unknown>): ILogger;
|
|
117
|
+
/**
|
|
118
|
+
* Get log buffer for streaming/querying (ILogger optional method)
|
|
119
|
+
*/
|
|
120
|
+
getLogBuffer(): ILogBuffer | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* Register callback for every log event (ILogger optional method).
|
|
123
|
+
* Used by platform to connect logger extensions (ring buffer, persistence).
|
|
124
|
+
*
|
|
125
|
+
* @param callback - Function to call on each log event
|
|
126
|
+
* @returns Unsubscribe function to remove the callback
|
|
127
|
+
*/
|
|
128
|
+
onLog(callback: (record: LogRecord) => void): () => void;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Create Pino logger adapter.
|
|
132
|
+
* This is the factory function called by initPlatform() when loading adapters.
|
|
133
|
+
*/
|
|
134
|
+
declare function createAdapter(config?: PinoLoggerConfig): PinoLoggerAdapter;
|
|
135
|
+
|
|
136
|
+
export { LogRingBuffer, PinoLoggerAdapter, type PinoLoggerConfig, type StreamingConfig, createAdapter, createAdapter as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import pino from 'pino';
|
|
2
|
+
import { generateLogId } from '@kb-labs/core-platform/adapters';
|
|
3
|
+
|
|
4
|
+
// src/index.ts
|
|
5
|
+
|
|
6
|
+
// src/log-ring-buffer.ts
|
|
7
|
+
var LogRingBuffer = class {
|
|
8
|
+
buffer = [];
|
|
9
|
+
subscribers = /* @__PURE__ */ new Set();
|
|
10
|
+
maxSize;
|
|
11
|
+
maxAge;
|
|
12
|
+
constructor(maxSize = 1e3, maxAge = 36e5) {
|
|
13
|
+
this.maxSize = maxSize;
|
|
14
|
+
this.maxAge = maxAge;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Append log record to buffer
|
|
18
|
+
*/
|
|
19
|
+
append(record) {
|
|
20
|
+
this.buffer.push(record);
|
|
21
|
+
if (this.buffer.length > this.maxSize) {
|
|
22
|
+
this.buffer.shift();
|
|
23
|
+
}
|
|
24
|
+
const now = Date.now();
|
|
25
|
+
const cutoff = now - this.maxAge;
|
|
26
|
+
while (this.buffer.length > 0 && this.buffer[0].timestamp < cutoff) {
|
|
27
|
+
this.buffer.shift();
|
|
28
|
+
}
|
|
29
|
+
for (const subscriber of this.subscribers) {
|
|
30
|
+
try {
|
|
31
|
+
subscriber(record);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error("[LogRingBuffer] Subscriber error:", error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Query logs with filters
|
|
39
|
+
*/
|
|
40
|
+
query(query) {
|
|
41
|
+
let results = [...this.buffer];
|
|
42
|
+
if (!query) {
|
|
43
|
+
return results;
|
|
44
|
+
}
|
|
45
|
+
if (query.from !== void 0) {
|
|
46
|
+
results = results.filter((r) => r.timestamp >= query.from);
|
|
47
|
+
}
|
|
48
|
+
if (query.to !== void 0) {
|
|
49
|
+
results = results.filter((r) => r.timestamp <= query.to);
|
|
50
|
+
}
|
|
51
|
+
if (query.source !== void 0) {
|
|
52
|
+
results = results.filter((r) => r.source === query.source);
|
|
53
|
+
}
|
|
54
|
+
if (query.level !== void 0) {
|
|
55
|
+
const levels = [
|
|
56
|
+
"trace",
|
|
57
|
+
"debug",
|
|
58
|
+
"info",
|
|
59
|
+
"warn",
|
|
60
|
+
"error",
|
|
61
|
+
"fatal"
|
|
62
|
+
];
|
|
63
|
+
const minLevelIndex = levels.indexOf(query.level);
|
|
64
|
+
results = results.filter((r) => {
|
|
65
|
+
const recordLevelIndex = levels.indexOf(r.level);
|
|
66
|
+
return recordLevelIndex >= minLevelIndex;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (query.limit !== void 0 && query.limit > 0) {
|
|
70
|
+
results = results.slice(-query.limit);
|
|
71
|
+
}
|
|
72
|
+
return results;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Subscribe to real-time log stream
|
|
76
|
+
*/
|
|
77
|
+
subscribe(callback) {
|
|
78
|
+
this.subscribers.add(callback);
|
|
79
|
+
return () => {
|
|
80
|
+
this.subscribers.delete(callback);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Find log by ID in buffer
|
|
85
|
+
*/
|
|
86
|
+
findById(id) {
|
|
87
|
+
return this.buffer.find((record) => record.id === id);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get buffer statistics
|
|
91
|
+
*/
|
|
92
|
+
getStats() {
|
|
93
|
+
return {
|
|
94
|
+
total: this.buffer.length,
|
|
95
|
+
bufferSize: this.maxSize,
|
|
96
|
+
oldestTimestamp: this.buffer.length > 0 ? this.buffer[0].timestamp : null,
|
|
97
|
+
newestTimestamp: this.buffer.length > 0 ? this.buffer[this.buffer.length - 1].timestamp : null
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// src/manifest.ts
|
|
103
|
+
var manifest = {
|
|
104
|
+
manifestVersion: "1.0.0",
|
|
105
|
+
id: "pino-logger",
|
|
106
|
+
name: "Pino Logger",
|
|
107
|
+
version: "1.0.0",
|
|
108
|
+
description: "Production-ready structured logger based on Pino",
|
|
109
|
+
author: "KB Labs Team",
|
|
110
|
+
license: "KBPL-1.1",
|
|
111
|
+
type: "core",
|
|
112
|
+
implements: "ILogger",
|
|
113
|
+
optional: {
|
|
114
|
+
adapters: ["analytics"]
|
|
115
|
+
},
|
|
116
|
+
capabilities: {
|
|
117
|
+
streaming: true
|
|
118
|
+
},
|
|
119
|
+
configSchema: {
|
|
120
|
+
level: {
|
|
121
|
+
type: "string",
|
|
122
|
+
enum: ["trace", "debug", "info", "warn", "error", "fatal"],
|
|
123
|
+
default: "info",
|
|
124
|
+
description: "Minimum log level"
|
|
125
|
+
},
|
|
126
|
+
pretty: {
|
|
127
|
+
type: "boolean",
|
|
128
|
+
default: false,
|
|
129
|
+
description: "Enable pretty printing for development"
|
|
130
|
+
},
|
|
131
|
+
streaming: {
|
|
132
|
+
type: "object",
|
|
133
|
+
description: "Log streaming/buffering configuration",
|
|
134
|
+
properties: {
|
|
135
|
+
enabled: { type: "boolean", default: false },
|
|
136
|
+
bufferSize: { type: "number", default: 1e3 },
|
|
137
|
+
bufferMaxAge: { type: "number", default: 36e5 }
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// src/index.ts
|
|
144
|
+
var PinoLoggerAdapter = class _PinoLoggerAdapter {
|
|
145
|
+
pino;
|
|
146
|
+
logBuffer;
|
|
147
|
+
logCallbacks = /* @__PURE__ */ new Set();
|
|
148
|
+
bindings = {};
|
|
149
|
+
constructor(config = {}) {
|
|
150
|
+
const resolvedLevel = process.env.KB_LOG_LEVEL ?? process.env.LOG_LEVEL ?? config.level ?? "info";
|
|
151
|
+
if (config.streaming?.enabled) {
|
|
152
|
+
this.logBuffer = new LogRingBuffer(
|
|
153
|
+
config.streaming.bufferSize ?? 1e3,
|
|
154
|
+
config.streaming.bufferMaxAge ?? 36e5
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
const transport = config.pretty ? {
|
|
158
|
+
target: "pino-pretty",
|
|
159
|
+
options: {
|
|
160
|
+
colorize: true,
|
|
161
|
+
translateTime: "SYS:standard",
|
|
162
|
+
ignore: "pid,hostname"
|
|
163
|
+
}
|
|
164
|
+
} : void 0;
|
|
165
|
+
const finalTransport = config.options?.transport ?? transport;
|
|
166
|
+
this.pino = pino({
|
|
167
|
+
level: resolvedLevel,
|
|
168
|
+
...config.options,
|
|
169
|
+
transport: finalTransport
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Emit log record to all registered callbacks (extensions).
|
|
174
|
+
* Fire-and-forget - errors in callbacks don't block logging.
|
|
175
|
+
*/
|
|
176
|
+
emitLog(record) {
|
|
177
|
+
if (this.logCallbacks.size === 0) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
for (const callback of this.logCallbacks) {
|
|
181
|
+
try {
|
|
182
|
+
callback(record);
|
|
183
|
+
} catch (error) {
|
|
184
|
+
console.error("[PinoLogger] Error in onLog callback:", error);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Internal constructor for child loggers.
|
|
190
|
+
*/
|
|
191
|
+
constructor_child(pinoInstance, bindings) {
|
|
192
|
+
const instance = Object.create(_PinoLoggerAdapter.prototype);
|
|
193
|
+
instance.pino = pinoInstance;
|
|
194
|
+
instance.logCallbacks = this.logCallbacks;
|
|
195
|
+
instance.logBuffer = this.logBuffer;
|
|
196
|
+
instance.bindings = bindings;
|
|
197
|
+
return instance;
|
|
198
|
+
}
|
|
199
|
+
mergeBindings(meta) {
|
|
200
|
+
if (!meta) {
|
|
201
|
+
return { ...this.bindings };
|
|
202
|
+
}
|
|
203
|
+
return { ...this.bindings, ...meta };
|
|
204
|
+
}
|
|
205
|
+
info(message, meta) {
|
|
206
|
+
const logId = generateLogId();
|
|
207
|
+
const timestamp = Date.now();
|
|
208
|
+
const mergedMeta = this.mergeBindings(meta);
|
|
209
|
+
this.pino.info(meta ?? {}, message);
|
|
210
|
+
const record = {
|
|
211
|
+
id: logId,
|
|
212
|
+
timestamp,
|
|
213
|
+
level: "info",
|
|
214
|
+
message,
|
|
215
|
+
fields: mergedMeta,
|
|
216
|
+
source: mergedMeta.source ?? "unknown"
|
|
217
|
+
};
|
|
218
|
+
this.logBuffer?.append(record);
|
|
219
|
+
this.emitLog(record);
|
|
220
|
+
}
|
|
221
|
+
warn(message, meta) {
|
|
222
|
+
const logId = generateLogId();
|
|
223
|
+
const timestamp = Date.now();
|
|
224
|
+
const mergedMeta = this.mergeBindings(meta);
|
|
225
|
+
this.pino.warn(meta ?? {}, message);
|
|
226
|
+
const record = {
|
|
227
|
+
id: logId,
|
|
228
|
+
timestamp,
|
|
229
|
+
level: "warn",
|
|
230
|
+
message,
|
|
231
|
+
fields: mergedMeta,
|
|
232
|
+
source: mergedMeta.source ?? "unknown"
|
|
233
|
+
};
|
|
234
|
+
this.logBuffer?.append(record);
|
|
235
|
+
this.emitLog(record);
|
|
236
|
+
}
|
|
237
|
+
error(message, error, meta) {
|
|
238
|
+
const logId = generateLogId();
|
|
239
|
+
const timestamp = Date.now();
|
|
240
|
+
const mergedMeta = this.mergeBindings(meta);
|
|
241
|
+
const enrichedMeta = {
|
|
242
|
+
...mergedMeta,
|
|
243
|
+
...error && {
|
|
244
|
+
error: {
|
|
245
|
+
message: error.message,
|
|
246
|
+
stack: error.stack,
|
|
247
|
+
name: error.name
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
this.pino.error(enrichedMeta, message);
|
|
252
|
+
const record = {
|
|
253
|
+
id: logId,
|
|
254
|
+
timestamp,
|
|
255
|
+
level: "error",
|
|
256
|
+
message,
|
|
257
|
+
fields: enrichedMeta,
|
|
258
|
+
source: mergedMeta.source ?? "unknown"
|
|
259
|
+
};
|
|
260
|
+
this.logBuffer?.append(record);
|
|
261
|
+
this.emitLog(record);
|
|
262
|
+
}
|
|
263
|
+
fatal(message, error, meta) {
|
|
264
|
+
const logId = generateLogId();
|
|
265
|
+
const timestamp = Date.now();
|
|
266
|
+
const mergedMeta = this.mergeBindings(meta);
|
|
267
|
+
const enrichedMeta = {
|
|
268
|
+
...mergedMeta,
|
|
269
|
+
...error && {
|
|
270
|
+
error: {
|
|
271
|
+
message: error.message,
|
|
272
|
+
stack: error.stack,
|
|
273
|
+
name: error.name
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
this.pino.fatal(enrichedMeta, message);
|
|
278
|
+
const record = {
|
|
279
|
+
id: logId,
|
|
280
|
+
timestamp,
|
|
281
|
+
level: "fatal",
|
|
282
|
+
message,
|
|
283
|
+
fields: enrichedMeta,
|
|
284
|
+
source: mergedMeta.source ?? "unknown"
|
|
285
|
+
};
|
|
286
|
+
this.logBuffer?.append(record);
|
|
287
|
+
this.emitLog(record);
|
|
288
|
+
}
|
|
289
|
+
debug(message, meta) {
|
|
290
|
+
const logId = generateLogId();
|
|
291
|
+
const timestamp = Date.now();
|
|
292
|
+
const mergedMeta = this.mergeBindings(meta);
|
|
293
|
+
this.pino.debug(meta ?? {}, message);
|
|
294
|
+
const record = {
|
|
295
|
+
id: logId,
|
|
296
|
+
timestamp,
|
|
297
|
+
level: "debug",
|
|
298
|
+
message,
|
|
299
|
+
fields: mergedMeta,
|
|
300
|
+
source: mergedMeta.source ?? "unknown"
|
|
301
|
+
};
|
|
302
|
+
this.logBuffer?.append(record);
|
|
303
|
+
this.emitLog(record);
|
|
304
|
+
}
|
|
305
|
+
trace(message, meta) {
|
|
306
|
+
const logId = generateLogId();
|
|
307
|
+
const timestamp = Date.now();
|
|
308
|
+
const mergedMeta = this.mergeBindings(meta);
|
|
309
|
+
this.pino.trace(meta ?? {}, message);
|
|
310
|
+
const record = {
|
|
311
|
+
id: logId,
|
|
312
|
+
timestamp,
|
|
313
|
+
level: "trace",
|
|
314
|
+
message,
|
|
315
|
+
fields: mergedMeta,
|
|
316
|
+
source: mergedMeta.source ?? "unknown"
|
|
317
|
+
};
|
|
318
|
+
this.logBuffer?.append(record);
|
|
319
|
+
this.emitLog(record);
|
|
320
|
+
}
|
|
321
|
+
child(bindings) {
|
|
322
|
+
const mergedBindings = { ...this.bindings, ...bindings };
|
|
323
|
+
const childPino = this.pino.child(bindings);
|
|
324
|
+
return this.constructor_child(childPino, mergedBindings);
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Get log buffer for streaming/querying (ILogger optional method)
|
|
328
|
+
*/
|
|
329
|
+
getLogBuffer() {
|
|
330
|
+
return this.logBuffer;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Register callback for every log event (ILogger optional method).
|
|
334
|
+
* Used by platform to connect logger extensions (ring buffer, persistence).
|
|
335
|
+
*
|
|
336
|
+
* @param callback - Function to call on each log event
|
|
337
|
+
* @returns Unsubscribe function to remove the callback
|
|
338
|
+
*/
|
|
339
|
+
onLog(callback) {
|
|
340
|
+
this.logCallbacks.add(callback);
|
|
341
|
+
return () => this.logCallbacks.delete(callback);
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
function createAdapter(config) {
|
|
345
|
+
return new PinoLoggerAdapter(config);
|
|
346
|
+
}
|
|
347
|
+
var index_default = createAdapter;
|
|
348
|
+
|
|
349
|
+
export { LogRingBuffer, PinoLoggerAdapter, createAdapter, index_default as default, manifest };
|
|
350
|
+
//# sourceMappingURL=index.js.map
|
|
351
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../Users/kirillbaranov/Desktop/kb-labs-workspace/infra/kb-labs-adapters/packages/adapters-pino/src/log-ring-buffer.ts","../../../../../../Users/kirillbaranov/Desktop/kb-labs-workspace/infra/kb-labs-adapters/packages/adapters-pino/src/manifest.ts","../../../../../../Users/kirillbaranov/Desktop/kb-labs-workspace/infra/kb-labs-adapters/packages/adapters-pino/src/index.ts"],"names":[],"mappings":";;;;;;AAeO,IAAM,gBAAN,MAA0C;AAAA,EACvC,SAAsB,EAAC;AAAA,EACvB,WAAA,uBAAoD,GAAA,EAAI;AAAA,EAC/C,OAAA;AAAA,EACA,MAAA;AAAA,EAEjB,WAAA,CAAY,OAAA,GAAkB,GAAA,EAAM,MAAA,GAAiB,IAAA,EAAS;AAC5D,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AACf,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,MAAA,EAAyB;AAE9B,IAAA,IAAA,CAAK,MAAA,CAAO,KAAK,MAAM,CAAA;AAGvB,IAAA,IAAI,IAAA,CAAK,MAAA,CAAO,MAAA,GAAS,IAAA,CAAK,OAAA,EAAS;AACrC,MAAA,IAAA,CAAK,OAAO,KAAA,EAAM;AAAA,IACpB;AAGA,IAAA,MAAM,GAAA,GAAM,KAAK,GAAA,EAAI;AACrB,IAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,MAAA;AAC1B,IAAA,OAAO,IAAA,CAAK,OAAO,MAAA,GAAS,CAAA,IAAK,KAAK,MAAA,CAAO,CAAC,CAAA,CAAG,SAAA,GAAY,MAAA,EAAQ;AACnE,MAAA,IAAA,CAAK,OAAO,KAAA,EAAM;AAAA,IACpB;AAGA,IAAA,KAAA,MAAW,UAAA,IAAc,KAAK,WAAA,EAAa;AACzC,MAAA,IAAI;AACF,QAAA,UAAA,CAAW,MAAM,CAAA;AAAA,MACnB,SAAS,KAAA,EAAO;AAEd,QAAA,OAAA,CAAQ,KAAA,CAAM,qCAAqC,KAAK,CAAA;AAAA,MAC1D;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAA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MO,SAAS,cAAc,MAAA,EAA8C;AAC1E,EAAA,OAAO,IAAI,kBAAkB,MAAM,CAAA;AACrC;AAGA,IAAO,aAAA,GAAQ","file":"index.js","sourcesContent":["/**\n * @module @kb-labs/adapters-pino/log-ring-buffer\n * Ring buffer for in-memory log storage with real-time streaming\n */\n\nimport type {\n LogRecord,\n LogQuery,\n ILogBuffer,\n LogLevel,\n} from \"@kb-labs/core-platform\";\n\n/**\n * Ring buffer implementation for log storage\n */\nexport class LogRingBuffer implements ILogBuffer {\n private buffer: LogRecord[] = [];\n private subscribers: Set<(record: LogRecord) => void> = new Set();\n private readonly maxSize: number;\n private readonly maxAge: number;\n\n constructor(maxSize: number = 1000, maxAge: number = 3600000) {\n this.maxSize = maxSize;\n this.maxAge = maxAge; // milliseconds\n }\n\n /**\n * Append log record to buffer\n */\n append(record: LogRecord): void {\n // Add to buffer\n this.buffer.push(record);\n\n // Evict old entries by size\n if (this.buffer.length > this.maxSize) {\n this.buffer.shift();\n }\n\n // Evict old entries by age\n const now = Date.now();\n const cutoff = now - this.maxAge;\n while (this.buffer.length > 0 && this.buffer[0]!.timestamp < cutoff) {\n this.buffer.shift();\n }\n\n // Notify subscribers\n for (const subscriber of this.subscribers) {\n try {\n subscriber(record);\n } catch (error) {\n // Ignore subscriber errors\n console.error(\"[LogRingBuffer] Subscriber error:\", error);\n }\n }\n }\n\n /**\n * Query logs with filters\n */\n query(query?: LogQuery): LogRecord[] {\n let results = [...this.buffer];\n\n if (!query) {\n return results;\n }\n\n // Filter by time range\n if (query.from !== undefined) {\n results = results.filter((r) => r.timestamp >= query.from!);\n }\n if (query.to !== undefined) {\n results = results.filter((r) => r.timestamp <= query.to!);\n }\n\n // Filter by source\n if (query.source !== undefined) {\n results = results.filter((r) => r.source === query.source);\n }\n\n // Filter by level (minimum level)\n if (query.level !== undefined) {\n const levels: LogLevel[] = [\n \"trace\",\n \"debug\",\n \"info\",\n \"warn\",\n \"error\",\n \"fatal\",\n ];\n const minLevelIndex = levels.indexOf(query.level);\n results = results.filter((r) => {\n const recordLevelIndex = levels.indexOf(r.level);\n return recordLevelIndex >= minLevelIndex;\n });\n }\n\n // Apply limit\n if (query.limit !== undefined && query.limit > 0) {\n results = results.slice(-query.limit); // Take most recent N\n }\n\n return results;\n }\n\n /**\n * Subscribe to real-time log stream\n */\n subscribe(callback: (record: LogRecord) => void): () => void {\n this.subscribers.add(callback);\n return () => {\n this.subscribers.delete(callback);\n };\n }\n\n /**\n * Find log by ID in buffer\n */\n findById(id: string): LogRecord | undefined {\n return this.buffer.find((record) => record.id === id);\n }\n\n /**\n * Get buffer statistics\n */\n getStats(): {\n total: number;\n bufferSize: number;\n oldestTimestamp: number | null;\n newestTimestamp: number | null;\n } {\n return {\n total: this.buffer.length,\n bufferSize: this.maxSize,\n oldestTimestamp:\n this.buffer.length > 0 ? this.buffer[0]!.timestamp : null,\n newestTimestamp:\n this.buffer.length > 0\n ? this.buffer[this.buffer.length - 1]!.timestamp\n : null,\n };\n }\n}\n","/**\n * @module @kb-labs/adapters-pino/manifest\n * Adapter manifest for Pino logger.\n */\n\nimport type { AdapterManifest } from \"@kb-labs/core-platform\";\n\n/**\n * Adapter manifest for Pino logger.\n */\nexport const manifest: AdapterManifest = {\n manifestVersion: \"1.0.0\",\n id: \"pino-logger\",\n name: \"Pino Logger\",\n version: \"1.0.0\",\n description: \"Production-ready structured logger based on Pino\",\n author: \"KB Labs Team\",\n license: \"KBPL-1.1\",\n type: \"core\",\n implements: \"ILogger\",\n optional: {\n adapters: [\"analytics\"],\n },\n capabilities: {\n streaming: true,\n },\n configSchema: {\n level: {\n type: \"string\",\n enum: [\"trace\", \"debug\", \"info\", \"warn\", \"error\", \"fatal\"],\n default: \"info\",\n description: \"Minimum log level\",\n },\n pretty: {\n type: \"boolean\",\n default: false,\n description: \"Enable pretty printing for development\",\n },\n streaming: {\n type: \"object\",\n description: \"Log streaming/buffering configuration\",\n properties: {\n enabled: { type: \"boolean\", default: false },\n bufferSize: { type: \"number\", default: 1000 },\n bufferMaxAge: { type: \"number\", default: 3600000 },\n },\n },\n },\n};\n","/**\n * @module @kb-labs/adapters-pino\n * Pino adapter implementing ILogger interface.\n *\n * @example\n * ```typescript\n * import { createAdapter } from '@kb-labs/adapters-pino';\n *\n * const logger = createAdapter({\n * level: 'info',\n * pretty: true,\n * });\n *\n * logger.info('Server started', { port: 3000 });\n * logger.error('Failed to connect', new Error('Connection timeout'));\n *\n * const childLogger = logger.child({ service: 'api' });\n * childLogger.debug('Request received');\n * ```\n */\n\nimport pino, { type Logger as PinoLoggerInstance } from \"pino\";\nimport type { ILogger, ILogBuffer, LogRecord } from \"@kb-labs/core-platform\";\nimport { generateLogId } from \"@kb-labs/core-platform/adapters\";\nimport { LogRingBuffer } from \"./log-ring-buffer\";\n\n// Re-export manifest\nexport { manifest } from \"./manifest.js\";\n\n/**\n * Configuration for log streaming/buffering\n */\nexport interface StreamingConfig {\n /** Enable log buffering for streaming (default: false) */\n enabled: boolean;\n /** Maximum buffer size (number of log records, default: 1000) */\n bufferSize?: number;\n /** Maximum age of logs in buffer (milliseconds, default: 3600000 = 1 hour) */\n bufferMaxAge?: number;\n}\n\n/**\n * Configuration for Pino logger adapter.\n */\nexport interface PinoLoggerConfig {\n /** Log level (default: 'info') */\n level?: \"trace\" | \"debug\" | \"info\" | \"warn\" | \"error\" | \"fatal\";\n /** Enable pretty printing for development (default: false) */\n pretty?: boolean;\n /** Streaming configuration (optional) */\n streaming?: StreamingConfig;\n /** Additional pino options */\n options?: pino.LoggerOptions;\n}\n\n/**\n * Pino implementation of ILogger interface.\n */\nexport class PinoLoggerAdapter implements ILogger {\n private pino: PinoLoggerInstance;\n private logBuffer?: LogRingBuffer;\n private logCallbacks = new Set<(record: LogRecord) => void>();\n private bindings: Record<string, unknown> = {};\n\n constructor(config: PinoLoggerConfig = {}) {\n // Resolve log level with priority: ENV var > config.level > 'info'\n // This allows overriding via KB_LOG_LEVEL or LOG_LEVEL environment variables\n const resolvedLevel =\n (process.env.KB_LOG_LEVEL as PinoLoggerConfig[\"level\"]) ??\n (process.env.LOG_LEVEL as PinoLoggerConfig[\"level\"]) ??\n config.level ??\n \"info\";\n\n // Initialize log buffer if streaming is enabled\n if (config.streaming?.enabled) {\n this.logBuffer = new LogRingBuffer(\n config.streaming.bufferSize ?? 1000,\n config.streaming.bufferMaxAge ?? 3600000,\n );\n }\n\n const transport = config.pretty\n ? {\n target: \"pino-pretty\",\n options: {\n colorize: true,\n translateTime: \"SYS:standard\",\n ignore: \"pid,hostname\",\n },\n }\n : undefined;\n\n // Merge options, but transport from config.options takes precedence\n const finalTransport = config.options?.transport ?? transport;\n\n // Always use single pino instance (no multistream)\n // LogRingBuffer is fed directly in log methods, not via Pino stream\n this.pino = pino({\n level: resolvedLevel,\n ...config.options,\n transport: finalTransport,\n });\n }\n\n /**\n * Emit log record to all registered callbacks (extensions).\n * Fire-and-forget - errors in callbacks don't block logging.\n */\n private emitLog(record: LogRecord): void {\n if (this.logCallbacks.size === 0) {\n return;\n }\n\n for (const callback of this.logCallbacks) {\n try {\n callback(record);\n } catch (error) {\n console.error(\"[PinoLogger] Error in onLog callback:\", error);\n }\n }\n }\n\n /**\n * Internal constructor for child loggers.\n */\n private constructor_child(pinoInstance: PinoLoggerInstance, bindings: Record<string, unknown>) {\n const instance = Object.create(PinoLoggerAdapter.prototype);\n instance.pino = pinoInstance;\n instance.logCallbacks = this.logCallbacks; // Share callbacks with parent\n instance.logBuffer = this.logBuffer; // Share buffer with parent\n instance.bindings = bindings;\n return instance;\n }\n\n private mergeBindings(meta?: Record<string, unknown>): Record<string, unknown> {\n if (!meta) {\n return { ...this.bindings };\n }\n return { ...this.bindings, ...meta };\n }\n\n info(message: string, meta?: Record<string, unknown>): void {\n const logId = generateLogId();\n const timestamp = Date.now();\n const mergedMeta = this.mergeBindings(meta);\n\n this.pino.info(meta ?? {}, message);\n\n const record: LogRecord = {\n id: logId,\n timestamp,\n level: \"info\",\n message,\n fields: mergedMeta,\n source: (mergedMeta.source as string) ?? \"unknown\",\n };\n\n this.logBuffer?.append(record);\n this.emitLog(record);\n }\n\n warn(message: string, meta?: Record<string, unknown>): void {\n const logId = generateLogId();\n const timestamp = Date.now();\n const mergedMeta = this.mergeBindings(meta);\n\n this.pino.warn(meta ?? {}, message);\n\n const record: LogRecord = {\n id: logId,\n timestamp,\n level: \"warn\",\n message,\n fields: mergedMeta,\n source: (mergedMeta.source as string) ?? \"unknown\",\n };\n\n this.logBuffer?.append(record);\n this.emitLog(record);\n }\n\n error(message: string, error?: Error, meta?: Record<string, unknown>): void {\n const logId = generateLogId();\n const timestamp = Date.now();\n const mergedMeta = this.mergeBindings(meta);\n\n const enrichedMeta = {\n ...mergedMeta,\n ...(error && {\n error: {\n message: error.message,\n stack: error.stack,\n name: error.name,\n },\n }),\n };\n\n this.pino.error(enrichedMeta, message);\n\n const record: LogRecord = {\n id: logId,\n timestamp,\n level: \"error\",\n message,\n fields: enrichedMeta,\n source: (mergedMeta.source as string) ?? \"unknown\",\n };\n\n this.logBuffer?.append(record);\n this.emitLog(record);\n }\n\n fatal(message: string, error?: Error, meta?: Record<string, unknown>): void {\n const logId = generateLogId();\n const timestamp = Date.now();\n const mergedMeta = this.mergeBindings(meta);\n\n const enrichedMeta = {\n ...mergedMeta,\n ...(error && {\n error: {\n message: error.message,\n stack: error.stack,\n name: error.name,\n },\n }),\n };\n\n this.pino.fatal(enrichedMeta, message);\n\n const record: LogRecord = {\n id: logId,\n timestamp,\n level: \"fatal\",\n message,\n fields: enrichedMeta,\n source: (mergedMeta.source as string) ?? \"unknown\",\n };\n\n this.logBuffer?.append(record);\n this.emitLog(record);\n }\n\n debug(message: string, meta?: Record<string, unknown>): void {\n const logId = generateLogId();\n const timestamp = Date.now();\n const mergedMeta = this.mergeBindings(meta);\n\n this.pino.debug(meta ?? {}, message);\n\n const record: LogRecord = {\n id: logId,\n timestamp,\n level: \"debug\",\n message,\n fields: mergedMeta,\n source: (mergedMeta.source as string) ?? \"unknown\",\n };\n\n this.logBuffer?.append(record);\n this.emitLog(record);\n }\n\n trace(message: string, meta?: Record<string, unknown>): void {\n const logId = generateLogId();\n const timestamp = Date.now();\n const mergedMeta = this.mergeBindings(meta);\n\n this.pino.trace(meta ?? {}, message);\n\n const record: LogRecord = {\n id: logId,\n timestamp,\n level: \"trace\",\n message,\n fields: mergedMeta,\n source: (mergedMeta.source as string) ?? \"unknown\",\n };\n\n this.logBuffer?.append(record);\n this.emitLog(record);\n }\n\n child(bindings: Record<string, unknown>): ILogger {\n const mergedBindings = { ...this.bindings, ...bindings };\n const childPino = this.pino.child(bindings);\n return this.constructor_child(childPino, mergedBindings);\n }\n\n /**\n * Get log buffer for streaming/querying (ILogger optional method)\n */\n getLogBuffer(): ILogBuffer | undefined {\n return this.logBuffer;\n }\n\n /**\n * Register callback for every log event (ILogger optional method).\n * Used by platform to connect logger extensions (ring buffer, persistence).\n *\n * @param callback - Function to call on each log event\n * @returns Unsubscribe function to remove the callback\n */\n onLog(callback: (record: LogRecord) => void): () => void {\n this.logCallbacks.add(callback);\n return () => this.logCallbacks.delete(callback);\n }\n}\n\n/**\n * Create Pino logger adapter.\n * This is the factory function called by initPlatform() when loading adapters.\n */\nexport function createAdapter(config?: PinoLoggerConfig): PinoLoggerAdapter {\n return new PinoLoggerAdapter(config);\n}\n\n// Default export for direct import\nexport default createAdapter;\n\n// Export buffer class\nexport { LogRingBuffer } from \"./log-ring-buffer\";\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AdapterManifest } from '@kb-labs/core-platform';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @module @kb-labs/adapters-pino/manifest
|
|
5
|
+
* Adapter manifest for Pino logger.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Adapter manifest for Pino logger.
|
|
10
|
+
*/
|
|
11
|
+
declare const manifest: AdapterManifest;
|
|
12
|
+
|
|
13
|
+
export { manifest };
|
package/dist/manifest.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// src/manifest.ts
|
|
2
|
+
var manifest = {
|
|
3
|
+
manifestVersion: "1.0.0",
|
|
4
|
+
id: "pino-logger",
|
|
5
|
+
name: "Pino Logger",
|
|
6
|
+
version: "1.0.0",
|
|
7
|
+
description: "Production-ready structured logger based on Pino",
|
|
8
|
+
author: "KB Labs Team",
|
|
9
|
+
license: "KBPL-1.1",
|
|
10
|
+
type: "core",
|
|
11
|
+
implements: "ILogger",
|
|
12
|
+
optional: {
|
|
13
|
+
adapters: ["analytics"]
|
|
14
|
+
},
|
|
15
|
+
capabilities: {
|
|
16
|
+
streaming: true
|
|
17
|
+
},
|
|
18
|
+
configSchema: {
|
|
19
|
+
level: {
|
|
20
|
+
type: "string",
|
|
21
|
+
enum: ["trace", "debug", "info", "warn", "error", "fatal"],
|
|
22
|
+
default: "info",
|
|
23
|
+
description: "Minimum log level"
|
|
24
|
+
},
|
|
25
|
+
pretty: {
|
|
26
|
+
type: "boolean",
|
|
27
|
+
default: false,
|
|
28
|
+
description: "Enable pretty printing for development"
|
|
29
|
+
},
|
|
30
|
+
streaming: {
|
|
31
|
+
type: "object",
|
|
32
|
+
description: "Log streaming/buffering configuration",
|
|
33
|
+
properties: {
|
|
34
|
+
enabled: { type: "boolean", default: false },
|
|
35
|
+
bufferSize: { type: "number", default: 1e3 },
|
|
36
|
+
bufferMaxAge: { type: "number", default: 36e5 }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { manifest };
|
|
43
|
+
//# sourceMappingURL=manifest.js.map
|
|
44
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../Users/kirillbaranov/Desktop/kb-labs-workspace/infra/kb-labs-adapters/packages/adapters-pino/src/manifest.ts"],"names":[],"mappings":";AAUO,IAAM,QAAA,GAA4B;AAAA,EACvC,eAAA,EAAiB,OAAA;AAAA,EACjB,EAAA,EAAI,aAAA;AAAA,EACJ,IAAA,EAAM,aAAA;AAAA,EACN,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EAAa,kDAAA;AAAA,EACb,MAAA,EAAQ,cAAA;AAAA,EACR,OAAA,EAAS,UAAA;AAAA,EACT,IAAA,EAAM,MAAA;AAAA,EACN,UAAA,EAAY,SAAA;AAAA,EACZ,QAAA,EAAU;AAAA,IACR,QAAA,EAAU,CAAC,WAAW;AAAA,GACxB;AAAA,EACA,YAAA,EAAc;AAAA,IACZ,SAAA,EAAW;AAAA,GACb;AAAA,EACA,YAAA,EAAc;AAAA,IACZ,KAAA,EAAO;AAAA,MACL,IAAA,EAAM,QAAA;AAAA,MACN,MAAM,CAAC,OAAA,EAAS,SAAS,MAAA,EAAQ,MAAA,EAAQ,SAAS,OAAO,CAAA;AAAA,MACzD,OAAA,EAAS,MAAA;AAAA,MACT,WAAA,EAAa;AAAA,KACf;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,IAAA,EAAM,SAAA;AAAA,MACN,OAAA,EAAS,KAAA;AAAA,MACT,WAAA,EAAa;AAAA,KACf;AAAA,IACA,SAAA,EAAW;AAAA,MACT,IAAA,EAAM,QAAA;AAAA,MACN,WAAA,EAAa,uCAAA;AAAA,MACb,UAAA,EAAY;AAAA,QACV,OAAA,EAAS,EAAE,IAAA,EAAM,SAAA,EAAW,SAAS,KAAA,EAAM;AAAA,QAC3C,UAAA,EAAY,EAAE,IAAA,EAAM,QAAA,EAAU,SAAS,GAAA,EAAK;AAAA,QAC5C,YAAA,EAAc,EAAE,IAAA,EAAM,QAAA,EAAU,SAAS,IAAA;AAAQ;AACnD;AACF;AAEJ","file":"manifest.js","sourcesContent":["/**\n * @module @kb-labs/adapters-pino/manifest\n * Adapter manifest for Pino logger.\n */\n\nimport type { AdapterManifest } from \"@kb-labs/core-platform\";\n\n/**\n * Adapter manifest for Pino logger.\n */\nexport const manifest: AdapterManifest = {\n manifestVersion: \"1.0.0\",\n id: \"pino-logger\",\n name: \"Pino Logger\",\n version: \"1.0.0\",\n description: \"Production-ready structured logger based on Pino\",\n author: \"KB Labs Team\",\n license: \"KBPL-1.1\",\n type: \"core\",\n implements: \"ILogger\",\n optional: {\n adapters: [\"analytics\"],\n },\n capabilities: {\n streaming: true,\n },\n configSchema: {\n level: {\n type: \"string\",\n enum: [\"trace\", \"debug\", \"info\", \"warn\", \"error\", \"fatal\"],\n default: \"info\",\n description: \"Minimum log level\",\n },\n pretty: {\n type: \"boolean\",\n default: false,\n description: \"Enable pretty printing for development\",\n },\n streaming: {\n type: \"object\",\n description: \"Log streaming/buffering configuration\",\n properties: {\n enabled: { type: \"boolean\", default: false },\n bufferSize: { type: \"number\", default: 1000 },\n bufferMaxAge: { type: \"number\", default: 3600000 },\n },\n },\n },\n};\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kb-labs/adapters-pino",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Pino adapter implementing ILogger interface",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"scripts": {
|
|
20
|
+
"clean": "rimraf dist",
|
|
21
|
+
"build": "tsup",
|
|
22
|
+
"dev": "tsup --watch",
|
|
23
|
+
"type-check": "tsc --noEmit",
|
|
24
|
+
"test": "vitest run --passWithNoTests",
|
|
25
|
+
"test:watch": "vitest",
|
|
26
|
+
"lint": "eslint src --ext .ts",
|
|
27
|
+
"lint:fix": "eslint . --fix"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"pino": "^9.0.0"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@kb-labs/core-platform": "*"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@kb-labs/core-platform": "link:../../../../platform/kb-labs-core/packages/core-platform",
|
|
37
|
+
"@types/node": "^24.3.3",
|
|
38
|
+
"eslint": "^9",
|
|
39
|
+
"tsup": "^8.5.0",
|
|
40
|
+
"typescript": "^5.6.3",
|
|
41
|
+
"vitest": "^3.2.4",
|
|
42
|
+
"@kb-labs/devkit": "link:../../../kb-labs-devkit",
|
|
43
|
+
"rimraf": "^6.0.1"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=20.0.0",
|
|
47
|
+
"pnpm": ">=9.0.0"
|
|
48
|
+
}
|
|
49
|
+
}
|