Skip to content

Commit

Permalink
fix: improve debug logs visual formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Dec 10, 2023
1 parent 92240b6 commit 222b1b2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions vike/utils/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,19 @@ function createDebugger(namespace: Namespace, optionsGlobal?: Options) {
const position = i === msgsRest.length - 1 ? 'LAST' : 'MIDDLE'
return formatMsg(msg, optionsResolved, padding, position)
})
console.log('\x1b[1m%s\x1b[0m', namespace, msgFirst)
msgsRest.forEach((msg) => {
let logFirst: unknown[]
let logsRest: unknown[]
const noNewLine =
msgsRest.length <= 1 && [msgFirst, ...msgsRest].every((m) => typeof m === 'string' && m.includes('\n'))
if (noNewLine) {
logFirst = [msgFirst, ...msgsRest]
logsRest = []
} else {
logFirst = [msgFirst]
logsRest = msgsRest
}
console.log('\x1b[1m%s\x1b[0m', namespace, ...logFirst)
logsRest.forEach((msg) => {
console.log(msg)
})
}
Expand Down

0 comments on commit 222b1b2

Please sign in to comment.