1import * as Context from "../Context.ts"
2import type { ErrorReporter } from "../ErrorReporter.ts"
3import { constTrue, constUndefined } from "../Function.ts"
4import type { LogLevel, Severity } from "../LogLevel.ts"
5import type { ReadonlyRecord } from "../Record.ts"
6import type { StackFrame } from "../References.ts"
7import type { SpanLink } from "../Tracer.ts"
8
9/** @internal */
10export const CurrentErrorReporters = Context.Reference<ReadonlySet<ErrorReporter>>(
11 "effect/ErrorReporter/CurrentErrorReporters",
12 { defaultValue: () => new Set() }
13)
14
15/** @internal */
16export const CurrentStackFrame = Context.Reference<StackFrame | undefined>("effect/References/CurrentStackFrame", {
17 fiberCached: true,
18 defaultValue: constUndefined
19})
20
21/** @internal */
22export const TracerEnabled = Context.Reference<boolean>("effect/References/TracerEnabled", {
23 fiberCached: true,
24 defaultValue: constTrue
25})
26
27/** @internal */
28export const TracerTimingEnabled = Context.Reference<boolean>("effect/References/TracerTimingEnabled", {
29 defaultValue: constTrue
30})
31
32/** @internal */
33export const TracerSpanAnnotations = Context.Reference<ReadonlyRecord<string, unknown>>(
34 "effect/References/TracerSpanAnnotations",
35 { defaultValue: () => ({}) }
36)
37
38/** @internal */
39export const TracerSpanLinks = Context.Reference<ReadonlyArray<SpanLink>>("effect/References/TracerSpanLinks", {
40 defaultValue: () => []
41})
42
43/** @internal */
44export const CurrentLogAnnotations = Context.Reference<ReadonlyRecord<string, unknown>>(
45 "effect/References/CurrentLogAnnotations",
46 { defaultValue: () => ({}) }
47)
48
49/** @internal */
50export const CurrentLogLevel: Context.Reference<Severity> = Context.Reference<Severity>(
51 "effect/References/CurrentLogLevel",
52 { fiberCached: true, defaultValue: () => "Info" }
53)
54
55/** @internal */
56export const MinimumLogLevel = Context.Reference<
57 LogLevel
58>("effect/References/MinimumLogLevel", { fiberCached: true, defaultValue: () => "Info" })
59
60/** @internal */
61export const UnhandledLogLevel: Context.Reference<Severity | undefined> = Context.Reference(
62 "effect/References/UnhandledLogLevel",
63 { defaultValue: (): Severity | undefined => "Error" }
64)
65
66/** @internal */
67export const CurrentLogSpans = Context.Reference<
68 ReadonlyArray<[label: string, timestamp: number]>
69>("effect/References/CurrentLogSpans", { defaultValue: () => [] })