glogg

Types

pub opaque type Field
pub type Level {
  Debug
  Info
  Notice
  Warning
  Error
  Critical
  Alert
  Emergency
}

Constructors

  • Debug
  • Info
  • Notice
  • Warning
  • Error
  • Critical
  • Alert
  • Emergency
pub opaque type Logger

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 alert(
  logger: Logger,
  message: String,
  fields: List(Field),
) -> Nil

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

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

Creates a boolean field with the given key and value.

pub fn configure_default_json_formatting() -> Nil

Configures all loggers to use JSON formatting by default.

pub fn configure_default_minimum_level(level: Level) -> Nil

Configures all loggers to use the specified minimum log level by default. Messages below this level will be ignored.

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

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

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 milliseconds with the given key and value.

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

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

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 fields_to_metadata(
  fields: List(Field),
) -> dict.Dict(String, dynamic.Dynamic)

Converts a list of fields into a metadata dictionary suitable for logging.

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

Creates a float field with the given key and value.

pub fn get_default_fields(logger: Logger) -> List(Field)

Retrieves the default fields of a logger.

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

Creates a group field with the given key and 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 notice(
  logger: Logger,
  message: String,
  fields: List(Field),
) -> Nil

Logs a message and fields at the Notice level.

pub fn stacktrace() -> Field

Creates a stacktrace field that with the key “stacktrace”.

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

Creates a string field with the given key and value.

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

Logs a message and fields at the Warning level.

pub fn with_default_fields(
  arg: 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.

Search Document