@mastra/loggers 0.10.2 → 0.10.3-alpha.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 +0 -1
- package/dist/_tsup-dts-rollup.d.cts +69 -0
- package/dist/_tsup-dts-rollup.d.ts +69 -0
- package/dist/http/index.cjs +166 -0
- package/dist/http/index.d.cts +1 -0
- package/dist/http/index.d.ts +1 -0
- package/dist/http/index.js +164 -0
- package/dist/index.cjs +1 -3
- package/dist/index.js +1 -3
- package/package.json +18 -8
package/README.md
CHANGED
|
@@ -47,6 +47,68 @@ export declare class FileTransport extends LoggerTransport {
|
|
|
47
47
|
}>;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
export declare class HttpTransport extends LoggerTransport {
|
|
51
|
+
private url;
|
|
52
|
+
private method;
|
|
53
|
+
private headers;
|
|
54
|
+
private batchSize;
|
|
55
|
+
private flushInterval;
|
|
56
|
+
private timeout;
|
|
57
|
+
private retryOptions;
|
|
58
|
+
private logBuffer;
|
|
59
|
+
private lastFlush;
|
|
60
|
+
private flushIntervalId;
|
|
61
|
+
constructor(options: HttpTransportOptions);
|
|
62
|
+
private makeHttpRequest;
|
|
63
|
+
_flush(): Promise<void>;
|
|
64
|
+
_write(chunk: any, encoding?: string, callback?: (error?: Error | null) => void): boolean;
|
|
65
|
+
_transform(chunk: string, _enc: string, cb: Function): void;
|
|
66
|
+
_destroy(err: Error, cb: Function): void;
|
|
67
|
+
getLogs(params?: {
|
|
68
|
+
fromDate?: Date;
|
|
69
|
+
toDate?: Date;
|
|
70
|
+
logLevel?: LogLevel;
|
|
71
|
+
filters?: Record<string, any>;
|
|
72
|
+
returnPaginationResults?: boolean;
|
|
73
|
+
page?: number;
|
|
74
|
+
perPage?: number;
|
|
75
|
+
}): Promise<{
|
|
76
|
+
logs: BaseLogMessage[];
|
|
77
|
+
total: number;
|
|
78
|
+
page: number;
|
|
79
|
+
perPage: number;
|
|
80
|
+
hasMore: boolean;
|
|
81
|
+
}>;
|
|
82
|
+
getLogsByRunId({ runId: _runId, fromDate: _fromDate, toDate: _toDate, logLevel: _logLevel, filters: _filters, page, perPage, }: {
|
|
83
|
+
runId: string;
|
|
84
|
+
fromDate?: Date;
|
|
85
|
+
toDate?: Date;
|
|
86
|
+
logLevel?: LogLevel;
|
|
87
|
+
filters?: Record<string, any>;
|
|
88
|
+
page?: number;
|
|
89
|
+
perPage?: number;
|
|
90
|
+
}): Promise<{
|
|
91
|
+
logs: BaseLogMessage[];
|
|
92
|
+
total: number;
|
|
93
|
+
page: number;
|
|
94
|
+
perPage: number;
|
|
95
|
+
hasMore: boolean;
|
|
96
|
+
}>;
|
|
97
|
+
getBufferedLogs(): BaseLogMessage[];
|
|
98
|
+
clearBuffer(): void;
|
|
99
|
+
getLastFlushTime(): number;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
declare interface HttpTransportOptions {
|
|
103
|
+
url: string;
|
|
104
|
+
method?: 'POST' | 'PUT' | 'PATCH';
|
|
105
|
+
headers?: Record<string, string>;
|
|
106
|
+
batchSize?: number;
|
|
107
|
+
flushInterval?: number;
|
|
108
|
+
timeout?: number;
|
|
109
|
+
retryOptions?: RetryOptions;
|
|
110
|
+
}
|
|
111
|
+
|
|
50
112
|
export { LogLevel }
|
|
51
113
|
export { LogLevel as LogLevel_alias_1 }
|
|
52
114
|
|
|
@@ -57,6 +119,7 @@ declare class PinoLogger extends MastraLogger {
|
|
|
57
119
|
level?: LogLevel;
|
|
58
120
|
transports?: TransportMap;
|
|
59
121
|
overrideDefaultTransports?: boolean;
|
|
122
|
+
formatters?: pino.LoggerOptions['formatters'];
|
|
60
123
|
});
|
|
61
124
|
debug(message: string, args?: Record<string, any>): void;
|
|
62
125
|
info(message: string, args?: Record<string, any>): void;
|
|
@@ -66,6 +129,12 @@ declare class PinoLogger extends MastraLogger {
|
|
|
66
129
|
export { PinoLogger }
|
|
67
130
|
export { PinoLogger as PinoLogger_alias_1 }
|
|
68
131
|
|
|
132
|
+
declare interface RetryOptions {
|
|
133
|
+
maxRetries?: number;
|
|
134
|
+
retryDelay?: number;
|
|
135
|
+
exponentialBackoff?: boolean;
|
|
136
|
+
}
|
|
137
|
+
|
|
69
138
|
declare type TransportMap = Record<string, LoggerTransport>;
|
|
70
139
|
|
|
71
140
|
export declare class UpstashTransport extends LoggerTransport {
|
|
@@ -47,6 +47,68 @@ export declare class FileTransport extends LoggerTransport {
|
|
|
47
47
|
}>;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
export declare class HttpTransport extends LoggerTransport {
|
|
51
|
+
private url;
|
|
52
|
+
private method;
|
|
53
|
+
private headers;
|
|
54
|
+
private batchSize;
|
|
55
|
+
private flushInterval;
|
|
56
|
+
private timeout;
|
|
57
|
+
private retryOptions;
|
|
58
|
+
private logBuffer;
|
|
59
|
+
private lastFlush;
|
|
60
|
+
private flushIntervalId;
|
|
61
|
+
constructor(options: HttpTransportOptions);
|
|
62
|
+
private makeHttpRequest;
|
|
63
|
+
_flush(): Promise<void>;
|
|
64
|
+
_write(chunk: any, encoding?: string, callback?: (error?: Error | null) => void): boolean;
|
|
65
|
+
_transform(chunk: string, _enc: string, cb: Function): void;
|
|
66
|
+
_destroy(err: Error, cb: Function): void;
|
|
67
|
+
getLogs(params?: {
|
|
68
|
+
fromDate?: Date;
|
|
69
|
+
toDate?: Date;
|
|
70
|
+
logLevel?: LogLevel;
|
|
71
|
+
filters?: Record<string, any>;
|
|
72
|
+
returnPaginationResults?: boolean;
|
|
73
|
+
page?: number;
|
|
74
|
+
perPage?: number;
|
|
75
|
+
}): Promise<{
|
|
76
|
+
logs: BaseLogMessage[];
|
|
77
|
+
total: number;
|
|
78
|
+
page: number;
|
|
79
|
+
perPage: number;
|
|
80
|
+
hasMore: boolean;
|
|
81
|
+
}>;
|
|
82
|
+
getLogsByRunId({ runId: _runId, fromDate: _fromDate, toDate: _toDate, logLevel: _logLevel, filters: _filters, page, perPage, }: {
|
|
83
|
+
runId: string;
|
|
84
|
+
fromDate?: Date;
|
|
85
|
+
toDate?: Date;
|
|
86
|
+
logLevel?: LogLevel;
|
|
87
|
+
filters?: Record<string, any>;
|
|
88
|
+
page?: number;
|
|
89
|
+
perPage?: number;
|
|
90
|
+
}): Promise<{
|
|
91
|
+
logs: BaseLogMessage[];
|
|
92
|
+
total: number;
|
|
93
|
+
page: number;
|
|
94
|
+
perPage: number;
|
|
95
|
+
hasMore: boolean;
|
|
96
|
+
}>;
|
|
97
|
+
getBufferedLogs(): BaseLogMessage[];
|
|
98
|
+
clearBuffer(): void;
|
|
99
|
+
getLastFlushTime(): number;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
declare interface HttpTransportOptions {
|
|
103
|
+
url: string;
|
|
104
|
+
method?: 'POST' | 'PUT' | 'PATCH';
|
|
105
|
+
headers?: Record<string, string>;
|
|
106
|
+
batchSize?: number;
|
|
107
|
+
flushInterval?: number;
|
|
108
|
+
timeout?: number;
|
|
109
|
+
retryOptions?: RetryOptions;
|
|
110
|
+
}
|
|
111
|
+
|
|
50
112
|
export { LogLevel }
|
|
51
113
|
export { LogLevel as LogLevel_alias_1 }
|
|
52
114
|
|
|
@@ -57,6 +119,7 @@ declare class PinoLogger extends MastraLogger {
|
|
|
57
119
|
level?: LogLevel;
|
|
58
120
|
transports?: TransportMap;
|
|
59
121
|
overrideDefaultTransports?: boolean;
|
|
122
|
+
formatters?: pino.LoggerOptions['formatters'];
|
|
60
123
|
});
|
|
61
124
|
debug(message: string, args?: Record<string, any>): void;
|
|
62
125
|
info(message: string, args?: Record<string, any>): void;
|
|
@@ -66,6 +129,12 @@ declare class PinoLogger extends MastraLogger {
|
|
|
66
129
|
export { PinoLogger }
|
|
67
130
|
export { PinoLogger as PinoLogger_alias_1 }
|
|
68
131
|
|
|
132
|
+
declare interface RetryOptions {
|
|
133
|
+
maxRetries?: number;
|
|
134
|
+
retryDelay?: number;
|
|
135
|
+
exponentialBackoff?: boolean;
|
|
136
|
+
}
|
|
137
|
+
|
|
69
138
|
declare type TransportMap = Record<string, LoggerTransport>;
|
|
70
139
|
|
|
71
140
|
export declare class UpstashTransport extends LoggerTransport {
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var logger = require('@mastra/core/logger');
|
|
4
|
+
|
|
5
|
+
// src/http/index.ts
|
|
6
|
+
var HttpTransport = class extends logger.LoggerTransport {
|
|
7
|
+
url;
|
|
8
|
+
method;
|
|
9
|
+
headers;
|
|
10
|
+
batchSize;
|
|
11
|
+
flushInterval;
|
|
12
|
+
timeout;
|
|
13
|
+
retryOptions;
|
|
14
|
+
logBuffer;
|
|
15
|
+
lastFlush;
|
|
16
|
+
flushIntervalId;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
super({ objectMode: true });
|
|
19
|
+
if (!options.url) {
|
|
20
|
+
throw new Error("HTTP URL is required");
|
|
21
|
+
}
|
|
22
|
+
this.url = options.url;
|
|
23
|
+
this.method = options.method || "POST";
|
|
24
|
+
this.headers = {
|
|
25
|
+
"Content-Type": "application/json",
|
|
26
|
+
...options.headers
|
|
27
|
+
};
|
|
28
|
+
this.batchSize = options.batchSize || 100;
|
|
29
|
+
this.flushInterval = options.flushInterval || 1e4;
|
|
30
|
+
this.timeout = options.timeout || 3e4;
|
|
31
|
+
this.retryOptions = {
|
|
32
|
+
maxRetries: options.retryOptions?.maxRetries || 3,
|
|
33
|
+
retryDelay: options.retryOptions?.retryDelay || 1e3,
|
|
34
|
+
exponentialBackoff: options.retryOptions?.exponentialBackoff || true
|
|
35
|
+
};
|
|
36
|
+
this.logBuffer = [];
|
|
37
|
+
this.lastFlush = Date.now();
|
|
38
|
+
this.flushIntervalId = setInterval(() => {
|
|
39
|
+
this._flush().catch((err) => {
|
|
40
|
+
console.error("Error flushing logs to HTTP endpoint:", err);
|
|
41
|
+
});
|
|
42
|
+
}, this.flushInterval);
|
|
43
|
+
}
|
|
44
|
+
async makeHttpRequest(data, retryCount = 0) {
|
|
45
|
+
const controller = new AbortController();
|
|
46
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
47
|
+
try {
|
|
48
|
+
const body = JSON.stringify({ logs: data });
|
|
49
|
+
const response = await fetch(this.url, {
|
|
50
|
+
method: this.method,
|
|
51
|
+
headers: this.headers,
|
|
52
|
+
body,
|
|
53
|
+
signal: controller.signal
|
|
54
|
+
});
|
|
55
|
+
clearTimeout(timeoutId);
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
58
|
+
}
|
|
59
|
+
return response;
|
|
60
|
+
} catch (error) {
|
|
61
|
+
clearTimeout(timeoutId);
|
|
62
|
+
if (retryCount < this.retryOptions.maxRetries) {
|
|
63
|
+
const delay = this.retryOptions.exponentialBackoff ? this.retryOptions.retryDelay * Math.pow(2, retryCount) : this.retryOptions.retryDelay;
|
|
64
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
65
|
+
return this.makeHttpRequest(data, retryCount + 1);
|
|
66
|
+
}
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async _flush() {
|
|
71
|
+
if (this.logBuffer.length === 0) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const now = Date.now();
|
|
75
|
+
const logs = this.logBuffer.splice(0, this.batchSize);
|
|
76
|
+
try {
|
|
77
|
+
await this.makeHttpRequest(logs);
|
|
78
|
+
this.lastFlush = now;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
this.logBuffer.unshift(...logs);
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
_write(chunk, encoding, callback) {
|
|
85
|
+
if (typeof callback === "function") {
|
|
86
|
+
this._transform(chunk, encoding || "utf8", callback);
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
this._transform(chunk, encoding || "utf8", (error) => {
|
|
90
|
+
if (error) console.error("Transform error in write:", error);
|
|
91
|
+
});
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
_transform(chunk, _enc, cb) {
|
|
95
|
+
try {
|
|
96
|
+
const log = typeof chunk === "string" ? JSON.parse(chunk) : chunk;
|
|
97
|
+
if (!log.time) {
|
|
98
|
+
log.time = Date.now();
|
|
99
|
+
}
|
|
100
|
+
this.logBuffer.push(log);
|
|
101
|
+
if (this.logBuffer.length >= this.batchSize) {
|
|
102
|
+
this._flush().catch((err) => {
|
|
103
|
+
console.error("Error flushing logs to HTTP endpoint:", err);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
cb(null, chunk);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
cb(error);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
_destroy(err, cb) {
|
|
112
|
+
clearInterval(this.flushIntervalId);
|
|
113
|
+
if (this.logBuffer.length > 0) {
|
|
114
|
+
this._flush().then(() => cb(err)).catch((flushErr) => {
|
|
115
|
+
console.error("Error in final flush:", flushErr);
|
|
116
|
+
cb(err || flushErr);
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
cb(err);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async getLogs(params) {
|
|
123
|
+
console.warn(
|
|
124
|
+
"HttpTransport.getLogs: This transport is write-only. Override this method to implement log retrieval."
|
|
125
|
+
);
|
|
126
|
+
return {
|
|
127
|
+
logs: [],
|
|
128
|
+
total: 0,
|
|
129
|
+
page: params?.page ?? 1,
|
|
130
|
+
perPage: params?.perPage ?? 100,
|
|
131
|
+
hasMore: false
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
async getLogsByRunId({
|
|
135
|
+
runId: _runId,
|
|
136
|
+
fromDate: _fromDate,
|
|
137
|
+
toDate: _toDate,
|
|
138
|
+
logLevel: _logLevel,
|
|
139
|
+
filters: _filters,
|
|
140
|
+
page,
|
|
141
|
+
perPage
|
|
142
|
+
}) {
|
|
143
|
+
console.warn(
|
|
144
|
+
"HttpTransport.getLogsByRunId: This transport is write-only. Override this method to implement log retrieval."
|
|
145
|
+
);
|
|
146
|
+
return {
|
|
147
|
+
logs: [],
|
|
148
|
+
total: 0,
|
|
149
|
+
page: page ?? 1,
|
|
150
|
+
perPage: perPage ?? 100,
|
|
151
|
+
hasMore: false
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
// Utility methods
|
|
155
|
+
getBufferedLogs() {
|
|
156
|
+
return [...this.logBuffer];
|
|
157
|
+
}
|
|
158
|
+
clearBuffer() {
|
|
159
|
+
this.logBuffer = [];
|
|
160
|
+
}
|
|
161
|
+
getLastFlushTime() {
|
|
162
|
+
return this.lastFlush;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
exports.HttpTransport = HttpTransport;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HttpTransport } from '../_tsup-dts-rollup.cjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HttpTransport } from '../_tsup-dts-rollup.js';
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { LoggerTransport } from '@mastra/core/logger';
|
|
2
|
+
|
|
3
|
+
// src/http/index.ts
|
|
4
|
+
var HttpTransport = class extends LoggerTransport {
|
|
5
|
+
url;
|
|
6
|
+
method;
|
|
7
|
+
headers;
|
|
8
|
+
batchSize;
|
|
9
|
+
flushInterval;
|
|
10
|
+
timeout;
|
|
11
|
+
retryOptions;
|
|
12
|
+
logBuffer;
|
|
13
|
+
lastFlush;
|
|
14
|
+
flushIntervalId;
|
|
15
|
+
constructor(options) {
|
|
16
|
+
super({ objectMode: true });
|
|
17
|
+
if (!options.url) {
|
|
18
|
+
throw new Error("HTTP URL is required");
|
|
19
|
+
}
|
|
20
|
+
this.url = options.url;
|
|
21
|
+
this.method = options.method || "POST";
|
|
22
|
+
this.headers = {
|
|
23
|
+
"Content-Type": "application/json",
|
|
24
|
+
...options.headers
|
|
25
|
+
};
|
|
26
|
+
this.batchSize = options.batchSize || 100;
|
|
27
|
+
this.flushInterval = options.flushInterval || 1e4;
|
|
28
|
+
this.timeout = options.timeout || 3e4;
|
|
29
|
+
this.retryOptions = {
|
|
30
|
+
maxRetries: options.retryOptions?.maxRetries || 3,
|
|
31
|
+
retryDelay: options.retryOptions?.retryDelay || 1e3,
|
|
32
|
+
exponentialBackoff: options.retryOptions?.exponentialBackoff || true
|
|
33
|
+
};
|
|
34
|
+
this.logBuffer = [];
|
|
35
|
+
this.lastFlush = Date.now();
|
|
36
|
+
this.flushIntervalId = setInterval(() => {
|
|
37
|
+
this._flush().catch((err) => {
|
|
38
|
+
console.error("Error flushing logs to HTTP endpoint:", err);
|
|
39
|
+
});
|
|
40
|
+
}, this.flushInterval);
|
|
41
|
+
}
|
|
42
|
+
async makeHttpRequest(data, retryCount = 0) {
|
|
43
|
+
const controller = new AbortController();
|
|
44
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
45
|
+
try {
|
|
46
|
+
const body = JSON.stringify({ logs: data });
|
|
47
|
+
const response = await fetch(this.url, {
|
|
48
|
+
method: this.method,
|
|
49
|
+
headers: this.headers,
|
|
50
|
+
body,
|
|
51
|
+
signal: controller.signal
|
|
52
|
+
});
|
|
53
|
+
clearTimeout(timeoutId);
|
|
54
|
+
if (!response.ok) {
|
|
55
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
56
|
+
}
|
|
57
|
+
return response;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
clearTimeout(timeoutId);
|
|
60
|
+
if (retryCount < this.retryOptions.maxRetries) {
|
|
61
|
+
const delay = this.retryOptions.exponentialBackoff ? this.retryOptions.retryDelay * Math.pow(2, retryCount) : this.retryOptions.retryDelay;
|
|
62
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
63
|
+
return this.makeHttpRequest(data, retryCount + 1);
|
|
64
|
+
}
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async _flush() {
|
|
69
|
+
if (this.logBuffer.length === 0) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const now = Date.now();
|
|
73
|
+
const logs = this.logBuffer.splice(0, this.batchSize);
|
|
74
|
+
try {
|
|
75
|
+
await this.makeHttpRequest(logs);
|
|
76
|
+
this.lastFlush = now;
|
|
77
|
+
} catch (error) {
|
|
78
|
+
this.logBuffer.unshift(...logs);
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
_write(chunk, encoding, callback) {
|
|
83
|
+
if (typeof callback === "function") {
|
|
84
|
+
this._transform(chunk, encoding || "utf8", callback);
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
this._transform(chunk, encoding || "utf8", (error) => {
|
|
88
|
+
if (error) console.error("Transform error in write:", error);
|
|
89
|
+
});
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
_transform(chunk, _enc, cb) {
|
|
93
|
+
try {
|
|
94
|
+
const log = typeof chunk === "string" ? JSON.parse(chunk) : chunk;
|
|
95
|
+
if (!log.time) {
|
|
96
|
+
log.time = Date.now();
|
|
97
|
+
}
|
|
98
|
+
this.logBuffer.push(log);
|
|
99
|
+
if (this.logBuffer.length >= this.batchSize) {
|
|
100
|
+
this._flush().catch((err) => {
|
|
101
|
+
console.error("Error flushing logs to HTTP endpoint:", err);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
cb(null, chunk);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
cb(error);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
_destroy(err, cb) {
|
|
110
|
+
clearInterval(this.flushIntervalId);
|
|
111
|
+
if (this.logBuffer.length > 0) {
|
|
112
|
+
this._flush().then(() => cb(err)).catch((flushErr) => {
|
|
113
|
+
console.error("Error in final flush:", flushErr);
|
|
114
|
+
cb(err || flushErr);
|
|
115
|
+
});
|
|
116
|
+
} else {
|
|
117
|
+
cb(err);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async getLogs(params) {
|
|
121
|
+
console.warn(
|
|
122
|
+
"HttpTransport.getLogs: This transport is write-only. Override this method to implement log retrieval."
|
|
123
|
+
);
|
|
124
|
+
return {
|
|
125
|
+
logs: [],
|
|
126
|
+
total: 0,
|
|
127
|
+
page: params?.page ?? 1,
|
|
128
|
+
perPage: params?.perPage ?? 100,
|
|
129
|
+
hasMore: false
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
async getLogsByRunId({
|
|
133
|
+
runId: _runId,
|
|
134
|
+
fromDate: _fromDate,
|
|
135
|
+
toDate: _toDate,
|
|
136
|
+
logLevel: _logLevel,
|
|
137
|
+
filters: _filters,
|
|
138
|
+
page,
|
|
139
|
+
perPage
|
|
140
|
+
}) {
|
|
141
|
+
console.warn(
|
|
142
|
+
"HttpTransport.getLogsByRunId: This transport is write-only. Override this method to implement log retrieval."
|
|
143
|
+
);
|
|
144
|
+
return {
|
|
145
|
+
logs: [],
|
|
146
|
+
total: 0,
|
|
147
|
+
page: page ?? 1,
|
|
148
|
+
perPage: perPage ?? 100,
|
|
149
|
+
hasMore: false
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
// Utility methods
|
|
153
|
+
getBufferedLogs() {
|
|
154
|
+
return [...this.logBuffer];
|
|
155
|
+
}
|
|
156
|
+
clearBuffer() {
|
|
157
|
+
this.logBuffer = [];
|
|
158
|
+
}
|
|
159
|
+
getLastFlushTime() {
|
|
160
|
+
return this.lastFlush;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export { HttpTransport };
|
package/dist/index.cjs
CHANGED
|
@@ -30,9 +30,7 @@ var PinoLogger = class extends logger.MastraLogger {
|
|
|
30
30
|
{
|
|
31
31
|
name: options.name || "app",
|
|
32
32
|
level: options.level || logger.LogLevel.INFO,
|
|
33
|
-
formatters:
|
|
34
|
-
level: (label) => ({ level: label })
|
|
35
|
-
}
|
|
33
|
+
formatters: options.formatters
|
|
36
34
|
},
|
|
37
35
|
options.overrideDefaultTransports ? options?.transports?.default : transportsAry.length === 0 ? prettyStream : pino__default.default.multistream([
|
|
38
36
|
...transportsAry.map(([, transport]) => ({
|
package/dist/index.js
CHANGED
|
@@ -23,9 +23,7 @@ var PinoLogger = class extends MastraLogger {
|
|
|
23
23
|
{
|
|
24
24
|
name: options.name || "app",
|
|
25
25
|
level: options.level || LogLevel.INFO,
|
|
26
|
-
formatters:
|
|
27
|
-
level: (label) => ({ level: label })
|
|
28
|
-
}
|
|
26
|
+
formatters: options.formatters
|
|
29
27
|
},
|
|
30
28
|
options.overrideDefaultTransports ? options?.transports?.default : transportsAry.length === 0 ? prettyStream : pino.multistream([
|
|
31
29
|
...transportsAry.map(([, transport]) => ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/loggers",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -39,6 +39,16 @@
|
|
|
39
39
|
"default": "./dist/upstash/index.cjs"
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
|
+
"./http": {
|
|
43
|
+
"import": {
|
|
44
|
+
"types": "./dist/http/index.d.ts",
|
|
45
|
+
"default": "./dist/http/index.js"
|
|
46
|
+
},
|
|
47
|
+
"require": {
|
|
48
|
+
"types": "./dist/http/index.d.cts",
|
|
49
|
+
"default": "./dist/http/index.cjs"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
42
52
|
"./package.json": "./package.json"
|
|
43
53
|
},
|
|
44
54
|
"keywords": [],
|
|
@@ -50,19 +60,19 @@
|
|
|
50
60
|
},
|
|
51
61
|
"devDependencies": {
|
|
52
62
|
"@microsoft/api-extractor": "^7.52.8",
|
|
53
|
-
"@types/node": "^20.
|
|
54
|
-
"eslint": "^9.
|
|
63
|
+
"@types/node": "^20.19.0",
|
|
64
|
+
"eslint": "^9.29.0",
|
|
55
65
|
"tsup": "^8.5.0",
|
|
56
|
-
"typescript": "^5.8.
|
|
57
|
-
"vitest": "^3.2.
|
|
58
|
-
"@internal/lint": "0.0.
|
|
59
|
-
"@mastra/core": "0.10.
|
|
66
|
+
"typescript": "^5.8.3",
|
|
67
|
+
"vitest": "^3.2.4",
|
|
68
|
+
"@internal/lint": "0.0.16",
|
|
69
|
+
"@mastra/core": "0.10.10-alpha.1"
|
|
60
70
|
},
|
|
61
71
|
"peerDependencies": {
|
|
62
72
|
"@mastra/core": ">=0.10.4-0 <0.11.0"
|
|
63
73
|
},
|
|
64
74
|
"scripts": {
|
|
65
|
-
"build": "tsup src/index.ts src/file/index.ts src/upstash/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|
|
75
|
+
"build": "tsup src/index.ts src/file/index.ts src/upstash/index.ts src/http/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|
|
66
76
|
"build:watch": "pnpm build --watch",
|
|
67
77
|
"test": "vitest run",
|
|
68
78
|
"lint": "eslint ."
|