Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.

LogLevel

26 exports Since v2.0.0 Source

Constructors

Since v2.0.0

Signature

declare const All: LogLevel

Signature

declare const allLevels: readonly Array<LogLevel>
Since v2.0.0

Signature

declare const Debug: LogLevel
Since v2.0.0

Signature

declare const Error: LogLevel
Since v2.0.0

Signature

declare const Fatal: LogLevel
Since v2.0.0

Signature

declare const Info: LogLevel
Since v2.0.0

Signature

declare const None: LogLevel
Since v2.0.0

Signature

declare const Trace: LogLevel
Since v2.0.0

Signature

declare const Warning: LogLevel

Conversions

Signature

declare function fromLiteral(literal: "All" | "Fatal" | "Error" | "Warning" | "Info" | "Debug" | "Trace" | "None"): LogLevel

Instances

Since v2.0.0

Signature

declare const Order: order.Order<LogLevel>

Model

All

interface
Since v2.0.0

Signature

interface All extends Pipeable {
readonly _tag: "All";
readonly label: "ALL";
readonly ordinal: number;
readonly syslog: 0;
}

Debug

interface
Since v2.0.0

Signature

interface Debug extends Pipeable {
readonly _tag: "Debug";
readonly label: "DEBUG";
readonly ordinal: number;
readonly syslog: 7;
}

Error

interface
Since v2.0.0

Signature

interface Error extends Pipeable {
readonly _tag: "Error";
readonly label: "ERROR";
readonly ordinal: number;
readonly syslog: 3;
}

Fatal

interface
Since v2.0.0

Signature

interface Fatal extends Pipeable {
readonly _tag: "Fatal";
readonly label: "FATAL";
readonly ordinal: number;
readonly syslog: 2;
}

Info

interface
Since v2.0.0

Signature

interface Info extends Pipeable {
readonly _tag: "Info";
readonly label: "INFO";
readonly ordinal: number;
readonly syslog: 6;
}
Since v2.0.0

Signature

type Literal = LogLevel["_tag"]
Since v2.0.0

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

None

interface
Since v2.0.0

Signature

interface None extends Pipeable {
readonly _tag: "None";
readonly label: "OFF";
readonly ordinal: number;
readonly syslog: 7;
}

Trace

interface
Since v2.0.0

Signature

interface Trace extends Pipeable {
readonly _tag: "Trace";
readonly label: "TRACE";
readonly ordinal: number;
readonly syslog: 7;
}

Warning

interface
Since v2.0.0

Signature

interface Warning extends Pipeable {
readonly _tag: "Warning";
readonly label: "WARN";
readonly ordinal: number;
readonly syslog: 4;
}

Ordering

Signature

declare const greaterThan: {
(that: LogLevel): (self: LogLevel) => boolean;
(self: LogLevel, that: LogLevel): boolean;
}

Signature

declare const greaterThanEqual: {
(that: LogLevel): (self: LogLevel) => boolean;
(self: LogLevel, that: LogLevel): boolean;
}
Since v2.0.0

Signature

declare const lessThan: {
(that: LogLevel): (self: LogLevel) => boolean;
(self: LogLevel, that: LogLevel): boolean;
}

Signature

declare const lessThanEqual: {
(that: LogLevel): (self: LogLevel) => boolean;
(self: LogLevel, that: LogLevel): boolean;
}

Utils

Since v2.0.0

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.

Signature

declare const locally: {
(self: LogLevel): <A, E, R>(use: Effect<A, E, R>) => Effect<A, E, R>;
<A, E, R>(use: Effect<A, E, R>, self: LogLevel): Effect<A, E, R>;
}

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