Skip to content

Commit

Permalink
fix: log object
Browse files Browse the repository at this point in the history
  • Loading branch information
rharkor committed Jan 26, 2024
1 parent 0cd0fcf commit d160b49
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,18 @@ const printColor =
(bg?: string, text?: string) =>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(...args: any) => {
if (bg && text) return chalk.bgHex(bg).hex(text)(args.join(" "))
if (bg) return chalk.bgHex(bg)(args.join(" "))
if (text) return chalk.hex(text)(args.join(" "))
const data = args
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.map((arg: any) => {
if (typeof arg === "object") {
return JSON.stringify(arg, null, 2)
}
return arg
})
.join(" ")
if (bg && text) return chalk.bgHex(bg).hex(text)(data)
if (bg) return chalk.bgHex(bg)(data)
if (text) return chalk.hex(text)(data)
}

const log = printColor(undefined, text)
Expand Down

0 comments on commit d160b49

Please sign in to comment.