@mastra/loggers 1.3.6-alpha.0 → 1.3.6-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-logging-pino-logger.md +1 -1
- package/dist/file/index.cjs +2 -4
- package/dist/file/index.cjs.map +1 -1
- package/dist/file/index.d.ts.map +1 -1
- package/dist/file/index.js +3 -5
- package/dist/file/index.js.map +1 -1
- package/package.json +2 -2
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-loggers
|
|
|
3
3
|
description: Documentation for @mastra/loggers. Use when working with @mastra/loggers APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/loggers"
|
|
6
|
-
version: "1.3.6-alpha.
|
|
6
|
+
version: "1.3.6-alpha.1"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -156,7 +156,7 @@ You can create custom transports using the `createCustomTransport` utility to in
|
|
|
156
156
|
Creates a custom transport using `createCustomTransport` and integrates it with a third-party logging stream such as `pino-sentry-transport`. The custom transport forwards logs to an external system such as Sentry for advanced monitoring and observability.
|
|
157
157
|
|
|
158
158
|
```typescript
|
|
159
|
-
import { createCustomTransport } from '@mastra/core/
|
|
159
|
+
import { createCustomTransport } from '@mastra/core/logger'
|
|
160
160
|
import { PinoLogger } from '@mastra/loggers/pino'
|
|
161
161
|
import pinoSentry from 'pino-sentry-transport'
|
|
162
162
|
|
package/dist/file/index.cjs
CHANGED
|
@@ -9,10 +9,8 @@ var FileTransport = class extends _mastra_core_logger.LoggerTransport {
|
|
|
9
9
|
constructor({ path }) {
|
|
10
10
|
super({ objectMode: true });
|
|
11
11
|
this.path = path;
|
|
12
|
-
if (!(0, fs.existsSync)(this.path))
|
|
13
|
-
|
|
14
|
-
throw new Error("File path does not exist");
|
|
15
|
-
}
|
|
12
|
+
if (!(0, fs.existsSync)(this.path)) throw new Error("File path does not exist");
|
|
13
|
+
if (!(0, fs.statSync)(this.path).isFile()) throw new Error(`File path must point to a file: ${this.path}`);
|
|
16
14
|
this.fileStream = (0, fs.createWriteStream)(this.path, { flags: "a" });
|
|
17
15
|
}
|
|
18
16
|
_transform(chunk, _encoding, callback) {
|
package/dist/file/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["LoggerTransport","#queryLogs"],"sources":["../../src/file/index.ts"],"sourcesContent":["import type { WriteStream } from 'node:fs';\nimport { createReadStream, createWriteStream, existsSync } from 'node:fs';\nimport { createInterface } from 'node:readline';\nimport { LoggerTransport } from '@mastra/core/logger';\nimport type { BaseLogMessage, LogLevel } from '@mastra/core/logger';\n\nexport class FileTransport extends LoggerTransport {\n path: string;\n fileStream: WriteStream;\n constructor({ path }: { path: string }) {\n super({ objectMode: true });\n this.path = path;\n\n if (!existsSync(this.path)) {\n
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["LoggerTransport","#queryLogs"],"sources":["../../src/file/index.ts"],"sourcesContent":["import type { WriteStream } from 'node:fs';\nimport { createReadStream, createWriteStream, existsSync, statSync } from 'node:fs';\nimport { createInterface } from 'node:readline';\nimport { LoggerTransport } from '@mastra/core/logger';\nimport type { BaseLogMessage, LogLevel } from '@mastra/core/logger';\n\nexport class FileTransport extends LoggerTransport {\n path: string;\n fileStream: WriteStream;\n constructor({ path }: { path: string }) {\n super({ objectMode: true });\n this.path = path;\n\n if (!existsSync(this.path)) {\n throw new Error('File path does not exist');\n }\n\n if (!statSync(this.path).isFile()) {\n throw new Error(`File path must point to a file: ${this.path}`);\n }\n\n this.fileStream = createWriteStream(this.path, { flags: 'a' });\n }\n\n _transform(chunk: any, _encoding: string, callback: (error: Error | null, chunk: any) => void) {\n try {\n this.fileStream.write(chunk);\n } catch (error) {\n console.error('Error parsing log entry:', error);\n }\n callback(null, chunk);\n }\n\n _flush(callback: Function) {\n // End the file stream when transform stream ends\n this.fileStream.end(() => {\n callback();\n });\n }\n\n _write(chunk: any, encoding?: string, callback?: (error?: Error | null) => void): boolean {\n if (typeof callback === 'function') {\n this._transform(chunk, encoding || 'utf8', callback);\n return true;\n }\n\n this._transform(chunk, encoding || 'utf8', (error: Error | null) => {\n if (error) console.error('Transform error in write:', error);\n });\n return true;\n }\n\n // Clean up resources\n _destroy(error: Error, callback: Function) {\n if (this.fileStream) {\n this.fileStream.destroy(error);\n }\n callback(error);\n }\n\n async listLogs(params?: {\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n returnPaginationResults?: boolean; // default true\n page?: number;\n perPage?: number;\n }): Promise<{\n logs: BaseLogMessage[];\n total: number;\n page: number;\n perPage: number;\n hasMore: boolean;\n }> {\n try {\n return await this.#queryLogs(params || {});\n } catch (error) {\n console.error('Error getting logs from file:', error);\n return { logs: [], total: 0, page: 0, perPage: 0, hasMore: false };\n }\n }\n\n async listLogsByRunId({\n runId,\n fromDate,\n toDate,\n logLevel,\n filters,\n page,\n perPage,\n }: {\n runId: string;\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n page?: number;\n perPage?: number;\n }): Promise<{\n logs: BaseLogMessage[];\n total: number;\n page: number;\n perPage: number;\n hasMore: boolean;\n }> {\n try {\n return await this.#queryLogs({ runId, fromDate, toDate, logLevel, filters, page, perPage });\n } catch (error) {\n console.error('Error getting logs by runId from file:', error);\n return { logs: [], total: 0, page: 0, perPage: 0, hasMore: false };\n }\n }\n\n /**\n * Streams the log file line by line, counting every matching record but\n * retaining only the requested page (or all matches when pagination is off).\n */\n async #queryLogs({\n runId,\n fromDate,\n toDate,\n logLevel,\n filters,\n returnPaginationResults = true,\n page: pageInput,\n perPage: perPageInput,\n }: {\n runId?: string;\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n returnPaginationResults?: boolean;\n page?: number;\n perPage?: number;\n }) {\n const page = pageInput === 0 ? 1 : (pageInput ?? 1);\n const perPage = (perPageInput ?? 100) || 100;\n const start = (page - 1) * perPage;\n const end = start + perPage;\n const filterEntries = Object.entries(filters ?? {});\n\n const logs: BaseLogMessage[] = [];\n let total = 0;\n\n const lines = createInterface({ input: createReadStream(this.path, 'utf8'), crlfDelay: Infinity });\n for await (const line of lines) {\n if (!line.trim()) continue;\n\n let log: any;\n try {\n log = JSON.parse(line);\n } catch {\n continue;\n }\n\n if (log === null || typeof log !== 'object') continue;\n if (runId !== undefined && log.runId !== runId) continue;\n if (!filterEntries.every(([key, value]) => log[key] === value)) continue;\n if (logLevel && log.level !== logLevel) continue;\n if (fromDate && !(new Date(log.time).getTime() >= fromDate.getTime())) continue;\n if (toDate && !(new Date(log.time).getTime() <= toDate.getTime())) continue;\n\n if (!returnPaginationResults || (total >= start && total < end)) {\n logs.push(log);\n }\n total++;\n }\n\n if (!returnPaginationResults) {\n return { logs, total, page, perPage: total, hasMore: false };\n }\n\n return { logs, total, page, perPage, hasMore: end < total };\n }\n}\n"],"mappings":";;;;;AAMA,IAAa,gBAAb,cAAmCA,oBAAAA,gBAAgB;CACjD;CACA;CACA,YAAY,EAAE,QAA0B;EACtC,MAAM,EAAE,YAAY,KAAK,CAAC;EAC1B,KAAK,OAAO;EAEZ,IAAI,EAAA,GAAA,GAAA,WAAA,CAAY,KAAK,IAAI,GACvB,MAAM,IAAI,MAAM,0BAA0B;EAG5C,IAAI,EAAA,GAAA,GAAA,SAAA,CAAU,KAAK,IAAI,CAAC,CAAC,OAAO,GAC9B,MAAM,IAAI,MAAM,mCAAmC,KAAK,MAAM;EAGhE,KAAK,cAAA,GAAA,GAAA,kBAAA,CAA+B,KAAK,MAAM,EAAE,OAAO,IAAI,CAAC;CAC/D;CAEA,WAAW,OAAY,WAAmB,UAAqD;EAC7F,IAAI;GACF,KAAK,WAAW,MAAM,KAAK;EAC7B,SAAS,OAAO;GACd,QAAQ,MAA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pB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC9B,uBAAuB,CAAC,EAAE,OAAO,CAAC;QAClC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC;QACV,IAAI,EAAE,cAAc,EAAE,CAAC;QACvB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC,CAOD;IAEK,eAAe,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,OAAO,GACR,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,IAAI,CAAC;QAChB,MAAM,CAAC,EAAE,IAAI,CAAC;QACd,QAAQ,CAAC,EAAE,QAAQ,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC;QACV,IAAI,EAAE,cAAc,EAAE,CAAC;QACvB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC,CAOD;CAgEF"}
|
package/dist/file/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LoggerTransport } from "@mastra/core/logger";
|
|
2
|
-
import { createReadStream, createWriteStream, existsSync } from "fs";
|
|
2
|
+
import { createReadStream, createWriteStream, existsSync, statSync } from "fs";
|
|
3
3
|
import { createInterface } from "readline";
|
|
4
4
|
//#region src/file/index.ts
|
|
5
5
|
var FileTransport = class extends LoggerTransport {
|
|
@@ -8,10 +8,8 @@ var FileTransport = class extends LoggerTransport {
|
|
|
8
8
|
constructor({ path }) {
|
|
9
9
|
super({ objectMode: true });
|
|
10
10
|
this.path = path;
|
|
11
|
-
if (!existsSync(this.path))
|
|
12
|
-
|
|
13
|
-
throw new Error("File path does not exist");
|
|
14
|
-
}
|
|
11
|
+
if (!existsSync(this.path)) throw new Error("File path does not exist");
|
|
12
|
+
if (!statSync(this.path).isFile()) throw new Error(`File path must point to a file: ${this.path}`);
|
|
15
13
|
this.fileStream = createWriteStream(this.path, { flags: "a" });
|
|
16
14
|
}
|
|
17
15
|
_transform(chunk, _encoding, callback) {
|
package/dist/file/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["#queryLogs"],"sources":["../../src/file/index.ts"],"sourcesContent":["import type { WriteStream } from 'node:fs';\nimport { createReadStream, createWriteStream, existsSync } from 'node:fs';\nimport { createInterface } from 'node:readline';\nimport { LoggerTransport } from '@mastra/core/logger';\nimport type { BaseLogMessage, LogLevel } from '@mastra/core/logger';\n\nexport class FileTransport extends LoggerTransport {\n path: string;\n fileStream: WriteStream;\n constructor({ path }: { path: string }) {\n super({ objectMode: true });\n this.path = path;\n\n if (!existsSync(this.path)) {\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["#queryLogs"],"sources":["../../src/file/index.ts"],"sourcesContent":["import type { WriteStream } from 'node:fs';\nimport { createReadStream, createWriteStream, existsSync, statSync } from 'node:fs';\nimport { createInterface } from 'node:readline';\nimport { LoggerTransport } from '@mastra/core/logger';\nimport type { BaseLogMessage, LogLevel } from '@mastra/core/logger';\n\nexport class FileTransport extends LoggerTransport {\n path: string;\n fileStream: WriteStream;\n constructor({ path }: { path: string }) {\n super({ objectMode: true });\n this.path = path;\n\n if (!existsSync(this.path)) {\n throw new Error('File path does not exist');\n }\n\n if (!statSync(this.path).isFile()) {\n throw new Error(`File path must point to a file: ${this.path}`);\n }\n\n this.fileStream = createWriteStream(this.path, { flags: 'a' });\n }\n\n _transform(chunk: any, _encoding: string, callback: (error: Error | null, chunk: any) => void) {\n try {\n this.fileStream.write(chunk);\n } catch (error) {\n console.error('Error parsing log entry:', error);\n }\n callback(null, chunk);\n }\n\n _flush(callback: Function) {\n // End the file stream when transform stream ends\n this.fileStream.end(() => {\n callback();\n });\n }\n\n _write(chunk: any, encoding?: string, callback?: (error?: Error | null) => void): boolean {\n if (typeof callback === 'function') {\n this._transform(chunk, encoding || 'utf8', callback);\n return true;\n }\n\n this._transform(chunk, encoding || 'utf8', (error: Error | null) => {\n if (error) console.error('Transform error in write:', error);\n });\n return true;\n }\n\n // Clean up resources\n _destroy(error: Error, callback: Function) {\n if (this.fileStream) {\n this.fileStream.destroy(error);\n }\n callback(error);\n }\n\n async listLogs(params?: {\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n returnPaginationResults?: boolean; // default true\n page?: number;\n perPage?: number;\n }): Promise<{\n logs: BaseLogMessage[];\n total: number;\n page: number;\n perPage: number;\n hasMore: boolean;\n }> {\n try {\n return await this.#queryLogs(params || {});\n } catch (error) {\n console.error('Error getting logs from file:', error);\n return { logs: [], total: 0, page: 0, perPage: 0, hasMore: false };\n }\n }\n\n async listLogsByRunId({\n runId,\n fromDate,\n toDate,\n logLevel,\n filters,\n page,\n perPage,\n }: {\n runId: string;\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n page?: number;\n perPage?: number;\n }): Promise<{\n logs: BaseLogMessage[];\n total: number;\n page: number;\n perPage: number;\n hasMore: boolean;\n }> {\n try {\n return await this.#queryLogs({ runId, fromDate, toDate, logLevel, filters, page, perPage });\n } catch (error) {\n console.error('Error getting logs by runId from file:', error);\n return { logs: [], total: 0, page: 0, perPage: 0, hasMore: false };\n }\n }\n\n /**\n * Streams the log file line by line, counting every matching record but\n * retaining only the requested page (or all matches when pagination is off).\n */\n async #queryLogs({\n runId,\n fromDate,\n toDate,\n logLevel,\n filters,\n returnPaginationResults = true,\n page: pageInput,\n perPage: perPageInput,\n }: {\n runId?: string;\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n returnPaginationResults?: boolean;\n page?: number;\n perPage?: number;\n }) {\n const page = pageInput === 0 ? 1 : (pageInput ?? 1);\n const perPage = (perPageInput ?? 100) || 100;\n const start = (page - 1) * perPage;\n const end = start + perPage;\n const filterEntries = Object.entries(filters ?? {});\n\n const logs: BaseLogMessage[] = [];\n let total = 0;\n\n const lines = createInterface({ input: createReadStream(this.path, 'utf8'), crlfDelay: Infinity });\n for await (const line of lines) {\n if (!line.trim()) continue;\n\n let log: any;\n try {\n log = JSON.parse(line);\n } catch {\n continue;\n }\n\n if (log === null || typeof log !== 'object') continue;\n if (runId !== undefined && log.runId !== runId) continue;\n if (!filterEntries.every(([key, value]) => log[key] === value)) continue;\n if (logLevel && log.level !== logLevel) continue;\n if (fromDate && !(new Date(log.time).getTime() >= fromDate.getTime())) continue;\n if (toDate && !(new Date(log.time).getTime() <= toDate.getTime())) continue;\n\n if (!returnPaginationResults || (total >= start && total < end)) {\n logs.push(log);\n }\n total++;\n }\n\n if (!returnPaginationResults) {\n return { logs, total, page, perPage: total, hasMore: false };\n }\n\n return { logs, total, page, perPage, hasMore: end < total };\n }\n}\n"],"mappings":";;;;AAMA,IAAa,gBAAb,cAAmC,gBAAgB;CACjD;CACA;CACA,YAAY,EAAE,QAA0B;EACtC,MAAM,EAAE,YAAY,KAAK,CAAC;EAC1B,KAAK,OAAO;EAEZ,IAAI,CAAC,WAAW,KAAK,IAAI,GACvB,MAAM,IAAI,MAAM,0BAA0B;EAG5C,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,OAAO,GAC9B,MAAM,IAAI,MAAM,mCAAmC,KAAK,MAAM;EAGhE,KAAK,aAAa,kBAAkB,KAAK,MAAM,EAAE,OAAO,IAAI,CAAC;CAC/D;CAEA,WAAW,OAAY,WAAmB,UAA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": [
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"vitest": "4.1.11",
|
|
79
79
|
"@internal/lint": "0.0.141",
|
|
80
80
|
"@internal/types-builder": "0.0.116",
|
|
81
|
-
"@mastra/core": "1.76.0-alpha.
|
|
81
|
+
"@mastra/core": "1.76.0-alpha.1"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
84
|
"@mastra/core": ">=1.0.0-0 <2.0.0-0"
|