birch/level

Log levels for controlling which messages are emitted.

Levels are ordered by severity: TRACE < DEBUG < INFO < WARN < ERROR < FATAL

Messages at or above the configured threshold are logged; those below are filtered.

Types

Log level representing the severity of a log message.

Levels are ordered from least to most severe:

  • Trace: Very detailed diagnostic information
  • Debug: Debugging information useful during development
  • Info: Normal operational messages (default threshold)
  • Warn: Warning conditions that might need attention
  • Err: Error conditions that should be addressed
  • Fatal: Critical errors that prevent the system from continuing

Note: Err is used instead of Error to avoid conflict with the Result type’s Error constructor.

pub type Level {
  Trace
  Debug
  Info
  Warn
  Err
  Fatal
}

Constructors

  • Trace
  • Debug
  • Info
  • Warn
  • Err
  • Fatal

Values

pub fn compare(a: Level, b: Level) -> order.Order

Compare two log levels. Returns the ordering relationship between them.

pub fn from_string(s: String) -> Result(Level, Nil)

Parse a string into a log level. Case-insensitive. Returns Error for unrecognized strings.

pub fn gt(a: Level, b: Level) -> Bool

Check if the first level is more severe than the second.

pub fn gte(a: Level, b: Level) -> Bool

Check if the first level is at least as severe as the second. Used for filtering: should_log(message_level, threshold).

pub fn to_int(level: Level) -> Int

Convert a log level to its integer representation. Lower numbers are less severe.

pub fn to_string(level: Level) -> String

Convert a log level to its string representation.

pub fn to_string_lowercase(level: Level) -> String

Convert a log level to a lowercase string (for JSON output).

Search Document