Options<Message>Information supplied to a Logger for a single log event.
Details
Includes the logged message, log level, cause, current fiber, and timestamp.
Example (Accessing logger options)
import { Effect, Logger } from "effect"
// Options interface provides all logging context
const detailedLogger = Logger.make((options) => {
const output = {
message: options.message,
level: options.logLevel,
timestamp: options.date.toISOString(),
fiberId: options.fiber.id,
hasCause: options.cause !== undefined
}
console.log(JSON.stringify(output))
})
const program = Effect.log("Processing request").pipe(
Effect.provide(Logger.layer([detailedLogger]))
)options
Source effect/Logger.ts:1037 lines
export interface interface Options<out Message>Information supplied to a Logger for a single log event.
Details
Includes the logged message, log level, cause, current fiber, and timestamp.
Example (Accessing logger options)
import { Effect, Logger } from "effect"
// Options interface provides all logging context
const detailedLogger = Logger.make((options) => {
const output = {
message: options.message,
level: options.logLevel,
timestamp: options.date.toISOString(),
fiberId: options.fiber.id,
hasCause: options.cause !== undefined
}
console.log(JSON.stringify(output))
})
const program = Effect.log("Processing request").pipe(
Effect.provide(Logger.layer([detailedLogger]))
)
Options<out function (type parameter) Message in Options<out Message>Message> {
readonly Options<out Message>.message: out Messagemessage: function (type parameter) Message in Options<out Message>Message
readonly Options<out Message>.logLevel: LogLevel.LogLevellogLevel: import LogLevelLogLevel.type LogLevel =
| "All"
| "Fatal"
| "Error"
| "Warn"
| "Info"
| "Debug"
| "Trace"
| "None"
Represents every level used by Effect logging, including concrete message
severities and the All and None sentinel levels.
When to use
Use to type values that may be either concrete log message severities or
logging configuration sentinels.
Details
The levels are ordered from most severe to least severe:
All - Special level that allows all messages
Fatal - System is unusable, immediate attention required
Error - Error conditions that should be investigated
Warn - Warning conditions that may indicate problems
Info - Informational messages about normal operation
Debug - Debug information useful during development
Trace - Very detailed trace information
None - Special level that suppresses all messages
Example (Using log levels)
import { Effect } from "effect"
// Using log levels with Effect logging
const program = Effect.gen(function*() {
yield* Effect.logFatal("System failure")
yield* Effect.logError("Database error")
yield* Effect.logWarning("High memory usage")
yield* Effect.logInfo("User logged in")
yield* Effect.logDebug("Processing request")
yield* Effect.logTrace("Variable state")
})
// Type-safe log level variables
const errorLevel = "Error" // LogLevel
const debugLevel = "Debug" // LogLevel
LogLevel
readonly Options<out Message>.cause: Cause.Cause<unknown>(property) Options<out Message>.cause: {
reasons: ReadonlyArray<Reason<E>>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
cause: import CauseCause.type Cause.Cause = /*unresolved*/ anyCause<unknown>
readonly Options<out Message>.fiber: Fiber.Fiber<unknown, unknown>(property) Options<out Message>.fiber: {
id: number;
currentOpCount: number;
getRef: <A>(ref: Context.Reference<A>) => A;
context: Context.Context<never>;
setContext: (context: Context.Context<never>) => void;
currentScheduler: Scheduler;
currentDispatcher: SchedulerDispatcher;
currentSpan: AnySpan | undefined;
currentLogLevel: LogLevel;
minimumLogLevel: LogLevel;
currentStackFrame: StackFrame | undefined;
maxOpsBeforeYield: number;
currentPreventYield: boolean;
addObserver: (cb: (exit: Exit<A, E>) => void) => () => void;
interruptUnsafe: (fiberId?: number | undefined, annotations?: Context.Context<never> | undefined) => void;
pollUnsafe: () => Exit<A, E> | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
fiber: import FiberFiber.type Fiber.Fiber = /*unresolved*/ anyFiber<unknown, unknown>
readonly Options<out Message>.date: Datedate: Date
}Referenced by 2 symbols