Skip to content

Commit 1fb1146

Browse files
committed
fix: array stringification
1 parent 9651fad commit 1fb1146

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/transports/console.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ export class ConsoleTransport implements Transport {
5555
? `<${this.options.noColor ? entry.category : pc.bold(entry.category)}> `
5656
: ""
5757

58-
// Format message parts
59-
const formattedMessage = this.formatMessageParts(entry.messageParts || [entry.message])
58+
// Format message parts - fall back to message if messageParts is empty
59+
let messageParts = entry.messageParts || [];
60+
if (messageParts.length === 0 && entry.message) {
61+
messageParts = [entry.message];
62+
}
63+
const formattedMessage = this.formatMessageParts(messageParts)
6064

6165
// Combine all parts
6266
const fullMessage = `${timestamp}${levelStr} ${category}${formattedMessage}`
@@ -98,6 +102,11 @@ export class ConsoleTransport implements Transport {
98102
}
99103

100104
if (typeof part === "object") {
105+
// Always use JSON.stringify for arrays
106+
if (Array.isArray(part)) {
107+
return JSON.stringify(part)
108+
}
109+
101110
// Check if object has a non-default toString method
102111
if (part.toString && part.toString !== Object.prototype.toString) {
103112
return part.toString()

0 commit comments

Comments
 (0)