glogg

Types

pub opaque type Field
pub type Level {
  Trace
  Info
  Error
  Warn
  Debug
}

Constructors

  • Trace
  • Info
  • Error
  • Warn
  • Debug
pub opaque type Logger
pub type Writer =
  fn(String) -> Nil

Values

pub fn add_default_fields(
  logger: Logger,
  fields: List(Field),
) -> Logger

Adds additional default fields to an existing logger.

The new fields are appended to the logger’s existing default fields. These fields will be included in every log message produced by the returned logger.

pub fn bool(key: String, value: Bool) -> Field

Creates a boolean field with the given key and value.

pub fn capture_stacktrace() -> List(String)
pub fn debug(
  logger: Logger,
  message: String,
  fields: List(Field),
) -> Nil

Logs a message and fields at the Debug level.

pub fn duration_ms(
  key: String,
  duration: duration.Duration,
) -> Field

Creates a duration field in miliseconds.

pub fn error(
  logger: Logger,
  message: String,
  fields: List(Field),
) -> Nil

Logs a message and fields at the Error level to standard error.

pub fn float(key: String, value: Float) -> Field

Creates a float field with the given key and value.

pub fn group(key: String, fields: List(Field)) -> Field

Creates a group field containing nested fields.

pub fn info(
  logger: Logger,
  message: String,
  fields: List(Field),
) -> Nil

Logs a message and fields at the Info level.

pub fn int(key: String, value: Int) -> Field

Creates an integer field with the given key and value.

pub fn new() -> Logger

Creates a new logger with sensible default settings. By default, the minimum level is Debug and there are no default fields.

pub fn serialize(
  level: Level,
  message: String,
  default_fields: List(Field),
  fields: List(Field),
) -> String
pub fn stacktrace() -> Field

Creates a stacktrace field capturing the current stack trace.

pub fn string(key: String, value: String) -> Field

Creates a string field with the given key and value.

pub fn trace(
  logger: Logger,
  message: String,
  fields: List(Field),
) -> Nil

Logs a message and fields at the Trace level.

pub fn warn(
  logger: Logger,
  message: String,
  fields: List(Field),
) -> Nil

Logs a message and fields at the Warn level.

pub fn with_default_fields(
  logger: Logger,
  fields: List(Field),
) -> Logger

Returns a new logger with a set of default fields.

These fields will be included in every log message produced by this logger, in addition to any fields provided at the call site.

pub fn with_error_writer(
  logger: Logger,
  error_writer: fn(String) -> Nil,
) -> Logger

Returns a new logger with a custom error writer.

This writer will be used to write all error log messages produced by this logger.

pub fn with_min_level(
  logger: Logger,
  minimum_level: Level,
) -> Logger

Returns a new logger with the specified minimum log level.

Log messages with a severity below this level will be ignored.

pub fn with_writer(
  logger: Logger,
  writer: fn(String) -> Nil,
) -> Logger

Returns a new logger with a custom writer.

This writer will be used to write all log messages produced by this logger.

Search Document