(self: LogLevel): numberReturns the ordinal value of the log level.
When to use
Use to project a LogLevel into the numeric sort key used by
LogLevel.Order when custom ordering code or an integration needs a number
instead of an Order comparison.
Details
The mapping is All to Number.MIN_SAFE_INTEGER, Trace to 0, Debug to
10000, Info to 20000, Warn to 30000, Error to 40000, Fatal to
50000, and None to Number.MAX_SAFE_INTEGER.
Gotchas
These ordinals are internal sort keys; do not treat them as external severity numbers.
export const const getOrdinal: (
self: LogLevel
) => number
Returns the ordinal value of the log level.
When to use
Use to project a LogLevel into the numeric sort key used by
LogLevel.Order when custom ordering code or an integration needs a number
instead of an Order comparison.
Details
The mapping is All to Number.MIN_SAFE_INTEGER, Trace to 0, Debug to
10000, Info to 20000, Warn to 30000, Error to 40000, Fatal to
50000, and None to Number.MAX_SAFE_INTEGER.
Gotchas
These ordinals are internal sort keys; do not treat them as external severity
numbers.
getOrdinal = (self: LogLevelself: 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): number => import effecteffect.const logLevelToOrder: (
level: LogLevel.LogLevel
) => number
logLevelToOrder(self: LogLevelself)