LogLevel.ts overview
Since v2.0.0
Exports Grouped by Category
constructors
All
Signature
declare const All: LogLevel
Since v2.0.0
Debug
Signature
declare const Debug: LogLevel
Since v2.0.0
Error
Signature
declare const Error: LogLevel
Since v2.0.0
Fatal
Signature
declare const Fatal: LogLevel
Since v2.0.0
Info
Signature
declare const Info: LogLevel
Since v2.0.0
None
Signature
declare const None: LogLevel
Since v2.0.0
Trace
Signature
declare const Trace: LogLevel
Since v2.0.0
Warning
Signature
declare const Warning: LogLevel
Since v2.0.0
allLevels
Signature
declare const allLevels: ReadonlyArray<LogLevel>
Since v2.0.0
conversions
fromLiteral
Signature
declare const fromLiteral: (literal: Literal) => LogLevel
Since v2.0.0
instances
Order
Signature
declare const Order: order.Order<LogLevel>
Since v2.0.0
model
All (interface)
Signature
export interface All extends Pipeable {
readonly _tag: "All"
readonly label: "ALL"
readonly syslog: 0
readonly ordinal: number
}
Since v2.0.0
Debug (interface)
Signature
export interface Debug extends Pipeable {
readonly _tag: "Debug"
readonly label: "DEBUG"
readonly syslog: 7
readonly ordinal: number
}
Since v2.0.0
Error (interface)
Signature
export interface Error extends Pipeable {
readonly _tag: "Error"
readonly label: "ERROR"
readonly syslog: 3
readonly ordinal: number
}
Since v2.0.0
Fatal (interface)
Signature
export interface Fatal extends Pipeable {
readonly _tag: "Fatal"
readonly label: "FATAL"
readonly syslog: 2
readonly ordinal: number
}
Since v2.0.0
Info (interface)
Signature
export interface Info extends Pipeable {
readonly _tag: "Info"
readonly label: "INFO"
readonly syslog: 6
readonly ordinal: number
}
Since v2.0.0
Literal (type alias)
Signature
type Literal = LogLevel["_tag"]
Since v2.0.0
LogLevel (type alias)
A LogLevel
represents the log level associated with an individual logging operation. Log levels are used both to describe the granularity (or importance) of individual log statements, as well as to enable tuning verbosity of log output.
Signature
type LogLevel = All | Fatal | Error | Warning | Info | Debug | Trace | None
Since v2.0.0
None (interface)
Signature
export interface None extends Pipeable {
readonly _tag: "None"
readonly label: "OFF"
readonly syslog: 7
readonly ordinal: number
}
Since v2.0.0
Trace (interface)
Signature
export interface Trace extends Pipeable {
readonly _tag: "Trace"
readonly label: "TRACE"
readonly syslog: 7
readonly ordinal: number
}
Since v2.0.0
Warning (interface)
Signature
export interface Warning extends Pipeable {
readonly _tag: "Warning"
readonly label: "WARN"
readonly syslog: 4
readonly ordinal: number
}
Since v2.0.0
ordering
greaterThan
Signature
declare const greaterThan: { (that: LogLevel): (self: LogLevel) => boolean; (self: LogLevel, that: LogLevel): boolean }
Since v2.0.0
greaterThanEqual
Signature
declare const greaterThanEqual: {
(that: LogLevel): (self: LogLevel) => boolean
(self: LogLevel, that: LogLevel): boolean
}
Since v2.0.0
lessThan
Signature
declare const lessThan: { (that: LogLevel): (self: LogLevel) => boolean; (self: LogLevel, that: LogLevel): boolean }
Since v2.0.0
lessThanEqual
Signature
declare const lessThanEqual: {
(that: LogLevel): (self: LogLevel) => boolean
(self: LogLevel, that: LogLevel): boolean
}
Since v2.0.0
utils
locally
Temporarily sets a LogLevel
for an Effect
workflow.
Details
This function allows you to apply a specific LogLevel
locally to an Effect
workflow. Once the workflow completes, the LogLevel
reverts to its previous state.
When to Use
This is particularly useful when you want to adjust the verbosity of logging for specific parts of your program without affecting the global log level.
Example
import { Effect, LogLevel } from "effect"
const program = Effect.gen(function* () {
yield* Effect.log("message1")
yield* Effect.gen(function* () {
yield* Effect.log("message2")
yield* Effect.log("message3")
}).pipe(LogLevel.locally(LogLevel.Warning))
})
Effect.runFork(program)
// timestamp=... level=INFO fiber=#0 message=message1
// timestamp=... level=WARN fiber=#0 message=message2
// timestamp=... level=WARN fiber=#0 message=message3
Signature
declare const locally: {
(self: LogLevel): <A, E, R>(use: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
<A, E, R>(use: Effect.Effect<A, E, R>, self: LogLevel): Effect.Effect<A, E, R>
}
Since v2.0.0