Skip to content

Commit

Permalink
fix Logger.pretty on bun (#3220)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Jul 11, 2024
1 parent 6e0a107 commit 55fdd76
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/kind-peaches-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

fix Logger.pretty on bun
12 changes: 7 additions & 5 deletions packages/effect/src/internal/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,6 @@ export const isLogger = (u: unknown): u is Logger.Logger<unknown, unknown> => {
return typeof u === "object" && u != null && LoggerTypeId in u
}

const processStdoutIsTTY = typeof process === "object" && "stdout" in process && process.stdout.isTTY === true
const hasWindow = typeof window === "object"

const withColor = (text: string, ...colors: ReadonlyArray<string>) => {
let out = ""
for (let i = 0; i < colors.length; i++) {
Expand Down Expand Up @@ -409,6 +406,10 @@ const defaultDateFormat = (date: Date): string =>
date.getSeconds().toString().padStart(2, "0")
}.${date.getMilliseconds().toString().padStart(3, "0")}`

const processStdoutIsTTY = typeof process === "object" && "stdout" in process && process.stdout.isTTY === true
const processIsBun = typeof process === "object" && "isBun" in process && process.isBun === true
const hasWindow = typeof window === "object"

/** @internal */
export const prettyLogger = (options?: {
readonly colors?: "auto" | boolean | undefined
Expand Down Expand Up @@ -457,7 +458,7 @@ export const prettyLogger = (options?: {
console.groupCollapsed(firstLine)
} else {
log(firstLine)
console.group()
if (!processIsBun) console.group()
}
if (!Cause.isEmpty(cause)) {
if (isBrowser) {
Expand All @@ -478,7 +479,8 @@ export const prettyLogger = (options?: {
log(color(`${key}:`, colors.bold, colors.white), value)
}
}
console.groupEnd()

if (!processIsBun) console.groupEnd()
}
)
}

0 comments on commit 55fdd76

Please sign in to comment.