@mastra/loggers 1.0.0-beta.3 → 1.0.0-beta.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @mastra/loggers
2
2
 
3
+ ## 1.0.0-beta.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Add embedded documentation support for Mastra packages ([#11472](https://github.com/mastra-ai/mastra/pull/11472))
8
+
9
+ Mastra packages now include embedded documentation in the published npm package under `dist/docs/`. This enables coding agents and AI assistants to understand and use the framework by reading documentation directly from `node_modules`.
10
+
11
+ Each package includes:
12
+ - **SKILL.md** - Entry point explaining the package's purpose and capabilities
13
+ - **SOURCE_MAP.json** - Machine-readable index mapping exports to types and implementation files
14
+ - **Topic folders** - Conceptual documentation organized by feature area
15
+
16
+ Documentation is driven by the `packages` frontmatter field in MDX files, which maps docs to their corresponding packages. CI validation ensures all docs include this field.
17
+
18
+ - Updated dependencies [[`d2d3e22`](https://github.com/mastra-ai/mastra/commit/d2d3e22a419ee243f8812a84e3453dd44365ecb0), [`bc72b52`](https://github.com/mastra-ai/mastra/commit/bc72b529ee4478fe89ecd85a8be47ce0127b82a0), [`05b8bee`](https://github.com/mastra-ai/mastra/commit/05b8bee9e50e6c2a4a2bf210eca25ee212ca24fa), [`c042bd0`](https://github.com/mastra-ai/mastra/commit/c042bd0b743e0e86199d0cb83344ca7690e34a9c), [`940a2b2`](https://github.com/mastra-ai/mastra/commit/940a2b27480626ed7e74f55806dcd2181c1dd0c2), [`e0941c3`](https://github.com/mastra-ai/mastra/commit/e0941c3d7fc75695d5d258e7008fd5d6e650800c), [`0c0580a`](https://github.com/mastra-ai/mastra/commit/0c0580a42f697cd2a7d5973f25bfe7da9055038a), [`28f5f89`](https://github.com/mastra-ai/mastra/commit/28f5f89705f2409921e3c45178796c0e0d0bbb64), [`e601b27`](https://github.com/mastra-ai/mastra/commit/e601b272c70f3a5ecca610373aa6223012704892), [`3d3366f`](https://github.com/mastra-ai/mastra/commit/3d3366f31683e7137d126a3a57174a222c5801fb), [`5a4953f`](https://github.com/mastra-ai/mastra/commit/5a4953f7d25bb15ca31ed16038092a39cb3f98b3), [`eb9e522`](https://github.com/mastra-ai/mastra/commit/eb9e522ce3070a405e5b949b7bf5609ca51d7fe2), [`20e6f19`](https://github.com/mastra-ai/mastra/commit/20e6f1971d51d3ff6dd7accad8aaaae826d540ed), [`4f0b3c6`](https://github.com/mastra-ai/mastra/commit/4f0b3c66f196c06448487f680ccbb614d281e2f7), [`74c4f22`](https://github.com/mastra-ai/mastra/commit/74c4f22ed4c71e72598eacc346ba95cdbc00294f), [`81b6a8f`](https://github.com/mastra-ai/mastra/commit/81b6a8ff79f49a7549d15d66624ac1a0b8f5f971), [`e4d366a`](https://github.com/mastra-ai/mastra/commit/e4d366aeb500371dd4210d6aa8361a4c21d87034), [`a4f010b`](https://github.com/mastra-ai/mastra/commit/a4f010b22e4355a5fdee70a1fe0f6e4a692cc29e), [`73b0bb3`](https://github.com/mastra-ai/mastra/commit/73b0bb394dba7c9482eb467a97ab283dbc0ef4db), [`5627a8c`](https://github.com/mastra-ai/mastra/commit/5627a8c6dc11fe3711b3fa7a6ffd6eb34100a306), [`3ff45d1`](https://github.com/mastra-ai/mastra/commit/3ff45d10e0c80c5335a957ab563da72feb623520), [`251df45`](https://github.com/mastra-ai/mastra/commit/251df4531407dfa46d805feb40ff3fb49769f455), [`f894d14`](https://github.com/mastra-ai/mastra/commit/f894d148946629af7b1f452d65a9cf864cec3765), [`c2b9547`](https://github.com/mastra-ai/mastra/commit/c2b9547bf435f56339f23625a743b2147ab1c7a6), [`580b592`](https://github.com/mastra-ai/mastra/commit/580b5927afc82fe460dfdf9a38a902511b6b7e7f), [`58e3931`](https://github.com/mastra-ai/mastra/commit/58e3931af9baa5921688566210f00fb0c10479fa), [`08bb631`](https://github.com/mastra-ai/mastra/commit/08bb631ae2b14684b2678e3549d0b399a6f0561e), [`4fba91b`](https://github.com/mastra-ai/mastra/commit/4fba91bec7c95911dc28e369437596b152b04cd0), [`12b0cc4`](https://github.com/mastra-ai/mastra/commit/12b0cc4077d886b1a552637dedb70a7ade93528c)]:
19
+ - @mastra/core@1.0.0-beta.20
20
+
3
21
  ## 1.0.0-beta.3
4
22
 
5
23
  ### Minor Changes
@@ -0,0 +1,33 @@
1
+ # @mastra/loggers Documentation
2
+
3
+ > Embedded documentation for coding agents
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # Read the skill overview
9
+ cat docs/SKILL.md
10
+
11
+ # Get the source map
12
+ cat docs/SOURCE_MAP.json
13
+
14
+ # Read topic documentation
15
+ cat docs/<topic>/01-overview.md
16
+ ```
17
+
18
+ ## Structure
19
+
20
+ ```
21
+ docs/
22
+ ├── SKILL.md # Entry point
23
+ ├── README.md # This file
24
+ ├── SOURCE_MAP.json # Export index
25
+ ├── core/ (1 files)
26
+ ├── logging/ (1 files)
27
+ ├── observability/ (2 files)
28
+ ```
29
+
30
+ ## Version
31
+
32
+ Package: @mastra/loggers
33
+ Version: 1.0.0-beta.4
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: mastra-loggers-docs
3
+ description: Documentation for @mastra/loggers. Includes links to type definitions and readable implementation code in dist/.
4
+ ---
5
+
6
+ # @mastra/loggers Documentation
7
+
8
+ > **Version**: 1.0.0-beta.4
9
+ > **Package**: @mastra/loggers
10
+
11
+ ## Quick Navigation
12
+
13
+ Use SOURCE_MAP.json to find any export:
14
+
15
+ ```bash
16
+ cat docs/SOURCE_MAP.json
17
+ ```
18
+
19
+ Each export maps to:
20
+ - **types**: `.d.ts` file with JSDoc and API signatures
21
+ - **implementation**: `.js` chunk file with readable source
22
+ - **docs**: Conceptual documentation in `docs/`
23
+
24
+ ## Top Exports
25
+
26
+
27
+
28
+ See SOURCE_MAP.json for the complete list.
29
+
30
+ ## Available Topics
31
+
32
+ - [Core](core/) - 1 file(s)
33
+ - [Logging](logging/) - 1 file(s)
34
+ - [Observability](observability/) - 2 file(s)
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": "1.0.0-beta.4",
3
+ "package": "@mastra/loggers",
4
+ "exports": {},
5
+ "modules": {}
6
+ }
@@ -0,0 +1,42 @@
1
+ # Core API Reference
2
+
3
+ > API reference for core - 1 entries
4
+
5
+
6
+ ---
7
+
8
+ ## Reference: Mastra Class
9
+
10
+ > Documentation for the `Mastra` class in Mastra, the core entry point for managing agents, workflows, MCP servers, and server endpoints.
11
+
12
+ The `Mastra` class is the central orchestrator in any Mastra application, managing agents, workflows, storage, logging, telemetry, and more. Typically, you create a single instance of `Mastra` to coordinate your application.
13
+
14
+ Think of `Mastra` as a top-level registry:
15
+
16
+ - Registering **integrations** makes them accessible to **agents**, **workflows**, and **tools** alike.
17
+ - **tools** aren’t registered on `Mastra` directly but are associated with agents and discovered automatically.
18
+
19
+ ## Usage example
20
+
21
+ ```typescript title="src/mastra/index.ts"
22
+ import { Mastra } from "@mastra/core";
23
+ import { PinoLogger } from "@mastra/loggers";
24
+ import { LibSQLStore } from "@mastra/libsql";
25
+ import { weatherWorkflow } from "./workflows/weather-workflow";
26
+ import { weatherAgent } from "./agents/weather-agent";
27
+
28
+ export const mastra = new Mastra({
29
+ workflows: { weatherWorkflow },
30
+ agents: { weatherAgent },
31
+ storage: new LibSQLStore({
32
+ id: 'mastra-storage',
33
+ url: ":memory:",
34
+ }),
35
+ logger: new PinoLogger({
36
+ name: "Mastra",
37
+ level: "info",
38
+ }),
39
+ });
40
+ ```
41
+
42
+ ## Constructor parameters
@@ -0,0 +1,116 @@
1
+ # Logging API Reference
2
+
3
+ > API reference for logging - 1 entries
4
+
5
+
6
+ ---
7
+
8
+ ## Reference: PinoLogger
9
+
10
+ > Documentation for PinoLogger, which provides methods to record events at various severity levels.
11
+
12
+ A Logger instance is created using `new PinoLogger()` and provides methods to record events at various severity levels.
13
+
14
+ When deploying to Mastra Cloud, logs are displayed on the [Logs](https://mastra.ai/docs/v1/mastra-cloud/observability#logs) page. In self-hosted or custom environments, logs can be directed to files or external services depending on the configured transports.
15
+
16
+ ## Usage example
17
+
18
+ ```typescript title="src/mastra/index.ts"
19
+ import { Mastra } from "@mastra/core";
20
+ import { PinoLogger } from "@mastra/loggers";
21
+
22
+ export const mastra = new Mastra({
23
+ logger: new PinoLogger({
24
+ name: "Mastra",
25
+ level: "info",
26
+ }),
27
+ });
28
+ ```
29
+
30
+ ## Parameters
31
+
32
+ ## File transport (structured logs)
33
+
34
+ Writes structured logs to a file using the `FileTransport`. The logger accepts a plain message as the first argument and structured metadata as the second argument. These are internally converted to a `BaseLogMessage` and persisted to the configured file path.
35
+
36
+ ```typescript title="src/mastra/loggers/file-transport.ts"
37
+ import { FileTransport } from "@mastra/loggers/file";
38
+ import { PinoLogger } from "@mastra/loggers/pino";
39
+
40
+ export const fileLogger = new PinoLogger({
41
+ name: "Mastra",
42
+ transports: { file: new FileTransport({ path: "test-dir/test.log" }) },
43
+ level: "warn",
44
+ });
45
+ ```
46
+
47
+ ### File transport usage
48
+
49
+ ```typescript
50
+ fileLogger.warn("Low disk space", {
51
+ destinationPath: "system",
52
+ type: "WORKFLOW",
53
+ });
54
+ ```
55
+
56
+ ## Upstash transport (remote log drain)
57
+
58
+ Streams structured logs to a remote Redis list using the `UpstashTransport`. The logger accepts a string message and a structured metadata object. This enables centralized logging for distributed environments, supporting filtering by `destinationPath`, `type`, and `runId`.
59
+
60
+ ```typescript title="src/mastra/loggers/upstash-transport.ts"
61
+ import { UpstashTransport } from "@mastra/loggers/upstash";
62
+ import { PinoLogger } from "@mastra/loggers/pino";
63
+
64
+ export const upstashLogger = new PinoLogger({
65
+ name: "Mastra",
66
+ transports: {
67
+ upstash: new UpstashTransport({
68
+ listName: "production-logs",
69
+ upstashUrl: process.env.UPSTASH_URL!,
70
+ upstashToken: process.env.UPSTASH_TOKEN!,
71
+ }),
72
+ },
73
+ level: "info",
74
+ });
75
+ ```
76
+
77
+ ### Upstash transport usage
78
+
79
+ ```typescript
80
+ upstashLogger.info("User signed in", {
81
+ destinationPath: "auth",
82
+ type: "AGENT",
83
+ runId: "run_123",
84
+ });
85
+ ```
86
+
87
+ ## Custom transport
88
+
89
+ You can create custom transports using the `createCustomTransport` utility to integrate with any logging service or stream.
90
+
91
+ ### Sentry transport example
92
+
93
+ Creates a custom transport using `createCustomTransport` and integrates it with a third-party logging stream such as `pino-sentry-transport`. This allows forwarding logs to an external system like Sentry for advanced monitoring and observability.
94
+
95
+ ```typescript title="src/mastra/loggers/sentry-transport.ts"
96
+ import { createCustomTransport } from "@mastra/core/loggers";
97
+ import { PinoLogger } from "@mastra/loggers/pino";
98
+ import pinoSentry from "pino-sentry-transport";
99
+
100
+ const sentryStream = await pinoSentry({
101
+ sentry: {
102
+ dsn: "YOUR_SENTRY_DSN",
103
+ _experiments: {
104
+ enableLogs: true,
105
+ },
106
+ },
107
+ });
108
+
109
+ const customTransport = createCustomTransport(sentryStream);
110
+
111
+ export const sentryLogger = new PinoLogger({
112
+ name: "Mastra",
113
+ level: "info",
114
+ transports: { sentry: customTransport },
115
+ });
116
+ ```
@@ -0,0 +1,64 @@
1
+ > Monitor and debug applications with Mastra
2
+
3
+ # Observability Overview
4
+
5
+ Mastra provides observability features for AI applications. Monitor LLM operations, trace agent decisions, and debug complex workflows with tools that understand AI-specific patterns.
6
+
7
+ ## Key Features
8
+
9
+ ### Tracing
10
+
11
+ Specialized tracing for AI operations that captures:
12
+
13
+ - **Model interactions**: Token usage, latency, prompts, and completions
14
+ - **Agent execution**: Decision paths, tool calls, and memory operations
15
+ - **Workflow steps**: Branching logic, parallel execution, and step outputs
16
+ - **Automatic instrumentation**: Tracing with decorators
17
+
18
+ ## Quick Start
19
+
20
+ Configure Observability in your Mastra instance:
21
+
22
+ ```typescript title="src/mastra/index.ts"
23
+ import { Mastra } from "@mastra/core";
24
+ import { PinoLogger } from "@mastra/loggers";
25
+ import { LibSQLStore } from "@mastra/libsql";
26
+ import {
27
+ Observability,
28
+ DefaultExporter,
29
+ CloudExporter,
30
+ SensitiveDataFilter,
31
+ } from "@mastra/observability";
32
+
33
+ export const mastra = new Mastra({
34
+ logger: new PinoLogger(),
35
+ storage: new LibSQLStore({
36
+ id: 'mastra-storage',
37
+ url: "file:./mastra.db", // Storage is required for tracing
38
+ }),
39
+ observability: new Observability({
40
+ configs: {
41
+ default: {
42
+ serviceName: "mastra",
43
+ exporters: [
44
+ new DefaultExporter(), // Persists traces to storage for Mastra Studio
45
+ new CloudExporter(), // Sends traces to Mastra Cloud (if MASTRA_CLOUD_ACCESS_TOKEN is set)
46
+ ],
47
+ spanOutputProcessors: [
48
+ new SensitiveDataFilter(), // Redacts sensitive data like passwords, tokens, keys
49
+ ],
50
+ },
51
+ },
52
+ }),
53
+ });
54
+ ```
55
+
56
+ With this basic setup, you will see Traces and Logs in both Studio and in Mastra Cloud.
57
+
58
+ We also support various external tracing providers like MLflow, Langfuse, Braintrust, and any OpenTelemetry-compatible platform (Datadog, New Relic, SigNoz, etc.). See more about this in the [Tracing](https://mastra.ai/docs/v1/observability/tracing/overview) documentation.
59
+
60
+ ## What's Next?
61
+
62
+ - **[Set up Tracing](https://mastra.ai/docs/v1/observability/tracing/overview)**: Configure tracing for your application
63
+ - **[Configure Logging](https://mastra.ai/docs/v1/observability/logging)**: Add structured logging
64
+ - **[API Reference](https://mastra.ai/reference/v1/observability/tracing/instances)**: Detailed configuration options
@@ -0,0 +1,104 @@
1
+ > Learn how to use logging in Mastra to monitor execution, capture application behavior, and improve the accuracy of AI applications.
2
+
3
+ # Logging
4
+
5
+ Mastra's logging system captures function execution, input data, and output responses in a structured format.
6
+
7
+ When deploying to Mastra Cloud, logs are shown on the [Logs](https://mastra.ai/docs/v1/mastra-cloud/observability) page. In self-hosted or custom environments, logs can be directed to files or external services depending on the configured transports.
8
+
9
+ ## Configuring logs with PinoLogger
10
+
11
+ When [initializing a new Mastra project](https://mastra.ai/guides/v1/getting-started/quickstart) using the CLI, `PinoLogger` is included by default.
12
+
13
+ ```typescript title="src/mastra/index.ts"
14
+ import { Mastra } from "@mastra/core/mastra";
15
+ import { PinoLogger } from "@mastra/loggers";
16
+
17
+ export const mastra = new Mastra({
18
+ logger: new PinoLogger({
19
+ name: "Mastra",
20
+ level: "info",
21
+ }),
22
+ });
23
+ ```
24
+
25
+ > **Note:**
26
+
27
+ Visit [PinoLogger](https://mastra.ai/reference/v1/logging/pino-logger) for all available configuration options.
28
+
29
+ ## Customizing logs
30
+
31
+ Mastra provides access to a logger instance via the `mastra.getLogger()` method, available inside both workflow steps and tools. The logger supports standard severity levels: `debug`, `info`, `warn`, and `error`.
32
+
33
+ ### Logging from workflow steps
34
+
35
+ Within a workflow step, access the logger via the `mastra` parameter inside the `execute` function. This allows you to log messages relevant to the step’s execution.
36
+
37
+ ```typescript {6-7} title="src/mastra/workflows/test-workflow.ts"
38
+ import { createWorkflow, createStep } from "@mastra/core/workflows";
39
+ import { z } from "zod";
40
+
41
+ const step1 = createStep({
42
+ execute: async ({ mastra }) => {
43
+ const logger = mastra.getLogger();
44
+ logger.info("workflow info log");
45
+
46
+ return {
47
+ output: ""
48
+ };
49
+ }
50
+ });
51
+
52
+ export const testWorkflow = createWorkflow({...})
53
+ .then(step1)
54
+ .commit();
55
+ ```
56
+
57
+ ### Logging from tools
58
+
59
+ Similarly, tools have access to the logger instance via the `mastra` parameter. Use this to log tool specific activity during execution.
60
+
61
+ ```typescript {6-7} title="src/mastra/tools/test-tool.ts"
62
+ import { createTool } from "@mastra/core/tools";
63
+ import { z } from "zod";
64
+
65
+ export const testTool = createTool({
66
+ execute: async ({ mastra }) => {
67
+ const logger = mastra?.getLogger();
68
+ logger?.info("tool info log");
69
+
70
+ return {
71
+ output: "",
72
+ };
73
+ },
74
+ });
75
+ ```
76
+
77
+ ### Logging with additional data
78
+
79
+ Logger methods accept an optional second argument for additional data. This can be any value, such as an object, string, or number.
80
+
81
+ In this example, the log message includes an object with a key of `agent` and a value of the `testAgent` instance.
82
+
83
+ ```typescript {10} title="src/mastra/workflows/test-workflow.ts"
84
+ import { createWorkflow, createStep } from "@mastra/core/workflows";
85
+ import { z } from "zod";
86
+
87
+ const step1 = createStep({
88
+ execute: async ({ mastra }) => {
89
+
90
+ const testAgent = mastra.getAgent("testAgent");
91
+
92
+ const logger = mastra.getLogger();
93
+ logger.info("workflow info log", { agent: testAgent });
94
+
95
+ return {
96
+ output: ""
97
+ };
98
+ }
99
+ });
100
+
101
+ export const testWorkflow = createWorkflow({...})
102
+ .then(step1)
103
+ .commit();
104
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/loggers",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.4",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -69,17 +69,16 @@
69
69
  "pino-pretty": "^13.0.0"
70
70
  },
71
71
  "devDependencies": {
72
- "@microsoft/api-extractor": "^7.52.8",
73
72
  "@types/node": "22.13.17",
74
73
  "@vitest/coverage-v8": "4.0.12",
75
74
  "@vitest/ui": "4.0.12",
76
75
  "eslint": "^9.37.0",
77
76
  "tsup": "^8.5.0",
78
- "typescript": "^5.8.3",
79
- "vitest": "4.0.12",
80
- "@internal/lint": "0.0.53",
77
+ "typescript": "^5.9.3",
78
+ "vitest": "4.0.16",
81
79
  "@internal/types-builder": "0.0.28",
82
- "@mastra/core": "1.0.0-beta.8"
80
+ "@internal/lint": "0.0.53",
81
+ "@mastra/core": "1.0.0-beta.20"
83
82
  },
84
83
  "peerDependencies": {
85
84
  "@mastra/core": ">=1.0.0-0 <2.0.0-0"
@@ -88,7 +87,8 @@
88
87
  "node": ">=22.13.0"
89
88
  },
90
89
  "scripts": {
91
- "build": "tsup --silent --config tsup.config.ts",
90
+ "build:lib": "tsup --silent --config tsup.config.ts",
91
+ "build:docs": "pnpx tsx ../../scripts/generate-package-docs.ts packages/loggers",
92
92
  "build:watch": "tsup --watch --silent --config tsup.config.ts",
93
93
  "test": "vitest run",
94
94
  "lint": "eslint ."