Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

Logger.md

120 lines3.3 KB

1---
2id: Logger
3title: Logger
4---
5​
6Defined in: [packages/ai/src/logger/types.ts:4](https://github.com/TanStack/ai/blob/main/packages/ai/src/logger/types.ts#L4)
7​
8Pluggable logger interface consumed by every `@tanstack/ai` activity when `debug` is enabled. Supply a custom implementation via `debug: { logger }` on `chat()`, `summarize()`, `generateImage()`, etc. The four methods correspond to log levels: use `debug` for chunk-level diagnostic output, `info`/`warn` for notable events, `error` for caught exceptions.
9​
10## Properties
11​
12### debug
13​
14```ts
15debug: (message, meta?) => void;
16```
17​
18Defined in: [packages/ai/src/logger/types.ts:9](https://github.com/TanStack/ai/blob/main/packages/ai/src/logger/types.ts#L9)
19​
20Called for chunk-level diagnostic output (raw provider chunks, per-chunk output, agent-loop iteration markers).
21​
22#### Parameters
23​
24##### message
25​
26`string`
27​
28##### meta?
29​
30`Record`\<`string`, `unknown`\>
31​
32Structured data forwarded to the underlying logger. Loggers like pino will preserve this as a structured record; the default `ConsoleLogger` renders it with a runtime-appropriate strategy (depth-unlimited `console.dir` on Node, JSON appended to the message on Cloudflare Workers, a second `console.<level>` argument elsewhere).
33​
34#### Returns
35​
36`void`
37​
38***
39​
40### error
41​
42```ts
43error: (message, meta?) => void;
44```
45​
46Defined in: [packages/ai/src/logger/types.ts:24](https://github.com/TanStack/ai/blob/main/packages/ai/src/logger/types.ts#L24)
47​
48Called for caught exceptions throughout the pipeline.
49​
50#### Parameters
51​
52##### message
53​
54`string`
55​
56##### meta?
57​
58`Record`\<`string`, `unknown`\>
59​
60Structured data forwarded to the underlying logger. Loggers like pino will preserve this as a structured record; the default `ConsoleLogger` renders it with a runtime-appropriate strategy (depth-unlimited `console.dir` on Node, JSON appended to the message on Cloudflare Workers, a second `console.<level>` argument elsewhere).
61​
62#### Returns
63​
64`void`
65​
66***
67​
68### info
69​
70```ts
71info: (message, meta?) => void;
72```
73​
74Defined in: [packages/ai/src/logger/types.ts:14](https://github.com/TanStack/ai/blob/main/packages/ai/src/logger/types.ts#L14)
75​
76Called for notable informational events (outgoing requests, tool invocations, middleware transitions).
77​
78#### Parameters
79​
80##### message
81​
82`string`
83​
84##### meta?
85​
86`Record`\<`string`, `unknown`\>
87​
88Structured data forwarded to the underlying logger. Loggers like pino will preserve this as a structured record; the default `ConsoleLogger` renders it with a runtime-appropriate strategy (depth-unlimited `console.dir` on Node, JSON appended to the message on Cloudflare Workers, a second `console.<level>` argument elsewhere).
89​
90#### Returns
91​
92`void`
93​
94***
95​
96### warn
97​
98```ts
99warn: (message, meta?) => void;
100```
101​
102Defined in: [packages/ai/src/logger/types.ts:19](https://github.com/TanStack/ai/blob/main/packages/ai/src/logger/types.ts#L19)
103​
104Called for notable warnings that don't halt execution (deprecations, recoverable anomalies).
105​
106#### Parameters
107​
108##### message
109​
110`string`
111​
112##### meta?
113​
114`Record`\<`string`, `unknown`\>
115​
116Structured data forwarded to the underlying logger. Loggers like pino will preserve this as a structured record; the default `ConsoleLogger` renders it with a runtime-appropriate strategy (depth-unlimited `console.dir` on Node, JSON appended to the message on Cloudflare Workers, a second `console.<level>` argument elsewhere).
117​
118#### Returns
119​
120`void`