LogLevel
Constructors
Signature
declare const All: LogLevel;Signature
declare const allLevels: readonly Array<LogLevel>Signature
declare const Debug: LogLevel;Signature
declare const Error: LogLevel;Signature
declare const Fatal: LogLevel;Signature
declare const Info: LogLevel;Signature
declare const None: LogLevel;Signature
declare const Trace: LogLevel;Signature
declare const Warning: LogLevel;Conversions
fromLiteral
Added in v2.0.0
Source
Signature
declare function fromLiteral(
literal: "All" | "Fatal" | "Error" | "Warning" | "Info" | "Debug" | "Trace" | "None",
): LogLevel;Instances
Model
Signature
interface All extends Pipeable {
readonly _tag: "All";
readonly label: "ALL";
readonly ordinal: number;
readonly syslog: 0;
}Signature
interface Debug extends Pipeable {
readonly _tag: "Debug";
readonly label: "DEBUG";
readonly ordinal: number;
readonly syslog: 7;
}Signature
interface Error extends Pipeable {
readonly _tag: "Error";
readonly label: "ERROR";
readonly ordinal: number;
readonly syslog: 3;
}Signature
interface Fatal extends Pipeable {
readonly _tag: "Fatal";
readonly label: "FATAL";
readonly ordinal: number;
readonly syslog: 2;
}Signature
interface Info extends Pipeable {
readonly _tag: "Info";
readonly label: "INFO";
readonly ordinal: number;
readonly syslog: 6;
}Signature
type Literal = LogLevel["_tag"];Signature
type LogLevel = All | Fatal | Error | Warning | Info | Debug | Trace | None;Signature
interface None extends Pipeable {
readonly _tag: "None";
readonly label: "OFF";
readonly ordinal: number;
readonly syslog: 7;
}Signature
interface Trace extends Pipeable {
readonly _tag: "Trace";
readonly label: "TRACE";
readonly ordinal: number;
readonly syslog: 7;
}Signature
interface Warning extends Pipeable {
readonly _tag: "Warning";
readonly label: "WARN";
readonly ordinal: number;
readonly syslog: 4;
}Ordering
greaterThan
Added in v2.0.0
Source
Signature
declare const greaterThan: {
(that: LogLevel): (self: LogLevel) => boolean;
(self: LogLevel, that: LogLevel): boolean;
};greaterThanEqual
Added in v2.0.0
Source
Signature
declare const greaterThanEqual: {
(that: LogLevel): (self: LogLevel) => boolean;
(self: LogLevel, that: LogLevel): boolean;
};Signature
declare const lessThan: {
(that: LogLevel): (self: LogLevel) => boolean;
(self: LogLevel, that: LogLevel): boolean;
};lessThanEqual
Added in v2.0.0
Source
Signature
declare const lessThanEqual: {
(that: LogLevel): (self: LogLevel) => boolean;
(self: LogLevel, that: LogLevel): boolean;
};Utils
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
A
LogLevelrepresents 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.