Skip to content

Commit 98f8a8b

Browse files
roaminroMastra Code (anthropic/claude-opus-4-6)
andauthored
fix(core): pass object bindings in __setLogger child() call (#15079)
Co-authored-by: Mastra Code (anthropic/claude-opus-4-6) <noreply@mastra.ai>
1 parent bc605db commit 98f8a8b

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

.changeset/perky-mammals-wink.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@mastra/core': patch
3+
---
4+
5+
Fixed `__setLogger` passing a raw string to `logger.child()`, which caused PinoLogger to serialize each character as a separate log field (e.g. `0: "B", 1: "U", 2: "N"...`). Now passes `{ component }` object instead.

packages/core/src/base.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ export class MastraBase {
4545
*/
4646
__setLogger(logger: IMastraLogger) {
4747
this.logger =
48-
'child' in logger && typeof (logger as any).child === 'function' ? (logger as any).child(this.component) : logger;
48+
'child' in logger && typeof (logger as any).child === 'function'
49+
? (logger as any).child({ component: this.component })
50+
: logger;
4951
}
5052
}
5153

packages/core/src/logger/default-logger.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ export class ConsoleLogger extends MastraLogger {
4141
this.filter = options.filter;
4242
}
4343

44-
child(component: RegisteredLogger): ConsoleLogger {
44+
child(componentOrBindings: RegisteredLogger | Record<string, unknown>): ConsoleLogger {
45+
const component =
46+
typeof componentOrBindings === 'string'
47+
? componentOrBindings
48+
: ((componentOrBindings?.component as RegisteredLogger) ?? this.component);
4549
return new ConsoleLogger({
4650
name: this.name,
4751
level: this.level,

0 commit comments

Comments
 (0)