effect-io-ai

Package: effect
Module: LogLevel

LogLevel.isEnabled

Checks whether a given log level is enabled for the current fiber.

When to use

Use to check whether a log level would be emitted under the current fiber’s minimum log level.

Details

A log level is enabled when it is greater than or equal to References.MinimumLogLevel.

Example (Checking current fiber log level)

import { Effect, LogLevel, References } from "effect"

const program = Effect.gen(function*() {
  const debugEnabled = yield* LogLevel.isEnabled("Debug")
  const errorEnabled = yield* LogLevel.isEnabled("Error")

  console.log({ debugEnabled, errorEnabled })
})

const warnOnly = program.pipe(
  Effect.provideService(References.MinimumLogLevel, "Warn")
)

Signature

declare const isEnabled: (self: LogLevel) => Effect.Effect<boolean>

Source

Since v4.0.0