Skip to content

Commit

Permalink
add Logger.prettyLoggerDefault, to prevent duplicate pretty loggers (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored and fubhy committed Sep 13, 2024
1 parent ee00dda commit 546723b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/honest-cups-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"effect": minor
"@effect/platform": patch
---

add Logger.prettyLoggerDefault, to prevent duplicate pretty loggers
8 changes: 8 additions & 0 deletions packages/effect/src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,14 @@ export const prettyLogger: (
}
) => Logger<unknown, void> = internal.prettyLogger

/**
* A default version of the pretty logger.
*
* @since 3.8.0
* @category constructors
*/
export const prettyLoggerDefault: Logger<unknown, void> = internal.prettyLoggerDefault

/**
* The structured logger provides detailed log outputs, structured in a way that
* retains comprehensive traceability of the events, suitable for deeper
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/internal/fiberRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,7 @@ export const logFmtLogger: Logger<unknown, void> = globalValue(
/** @internal */
export const prettyLogger: Logger<unknown, void> = globalValue(
Symbol.for("effect/Logger/prettyLogger"),
() => internalLogger.prettyLogger()
() => internalLogger.prettyLoggerDefault
)

/** @internal */
Expand Down
4 changes: 4 additions & 0 deletions packages/effect/src/internal/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as Context from "../Context.js"
import * as FiberRefs from "../FiberRefs.js"
import type { LazyArg } from "../Function.js"
import { constVoid, dual, pipe } from "../Function.js"
import { globalValue } from "../GlobalValue.js"
import * as HashMap from "../HashMap.js"
import * as Inspectable from "../Inspectable.js"
import * as List from "../List.js"
Expand Down Expand Up @@ -570,3 +571,6 @@ const prettyLoggerBrowser = (options: {
}
)
}

/** @internal */
export const prettyLoggerDefault = globalValue("effect/Logger/prettyLoggerDefault", () => prettyLogger())
2 changes: 1 addition & 1 deletion packages/platform/src/Runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const addPrettyLogger = (refs: FiberRefs.FiberRefs, fiberId: FiberId.Runtime) =>
fiberRef: FiberRef.currentLoggers,
value: loggers.pipe(
HashSet.remove(Logger.defaultLogger),
HashSet.add(Logger.prettyLogger())
HashSet.add(Logger.prettyLoggerDefault)
)
})
}
Expand Down

0 comments on commit 546723b

Please sign in to comment.