glog

Types

A Gleam implementation of Erlang logger Glog is the current “state” of the log to print

pub opaque type Glog

Functions

pub fn add(logger: Glog, key: String, value: a) -> Glog

Adds a key/value to the current log

Usage

import glog.{Glog}

let logger: Glog = glog.new()
logger
|> add("foo", "bar")
|> add("woo", "zoo")
pub fn add_error(logger: Glog, error: a) -> Glog

Adds an error key to the current log

Usage

import glog.{Glog}
import glog/field

let logger: Glog = glog.new()
logger
|> add_error("foo")
pub fn add_field(logger: Glog, f: Field) -> Glog

Adds a Field to the current log

Usage

import glog.{Glog}
import glog/field

let logger: Glog = glog.new()
logger
|> add_field(field.new("foo", "bar"))
pub fn add_fields(logger: Glog, f: List(Field)) -> Glog

Adds Fields to the current log

Usage

import glog.{Glog}
import glog/field

let logger: Glog = glog.new()
logger
|> add_fields([field.new("foo", "bar"), field.new("woo", "zoo")])
pub fn add_option(logger: Glog, key: String, o: Option(a)) -> Glog

Adds an Option to the current log

Usage

import glog.{Glog}
import glog/field

let logger: Glog = glog.new()
logger
|> add_option("foo", Some("foo"))
pub fn add_result(logger: Glog, key: String, r: Result(a, b)) -> Glog

Adds a Result to the current log

Usage

import glog.{Glog}
import glog/field

let logger: Glog = glog.new()
logger
|> add_result("foo", Ok("foo"))
pub fn alert(logger: Glog, message: String) -> Glog

Prints Alert log with current fields stored and the given message

Calling this function return a new Glog. Old Glog can still be used.

pub fn alertf(logger: Glog, string: String, values: List(Arg)) -> Glog

Prints Alert log with current fields stored and the given message template and values

Calling this function return a new Glog. Old Glog can still be used.

pub fn critical(logger: Glog, message: String) -> Glog

Prints Critical log with current fields stored and the given message

Calling this function return a new Glog. Old Glog can still be used.

pub fn criticalf(logger: Glog, string: String, values: List(Arg)) -> Glog

Prints Critical log with current fields stored and the given message template and values

Calling this function return a new Glog. Old Glog can still be used.

pub fn debug(logger: Glog, message: String) -> Glog

Prints Debug log with current fields stored and the given message

Calling this function return a new Glog. Old Glog can still be used.

pub fn debugf(logger: Glog, string: String, values: List(Arg)) -> Glog

Prints Debug log with current fields stored and the given message template and values

Calling this function return a new Glog. Old Glog can still be used.

pub fn emergency(logger: Glog, message: String) -> Glog

Prints Emergency log with current fields stored and the given message

Calling this function return a new Glog. Old Glog can still be used.

Usage

import glog.{Glog}

let logger: Glog = glog.new()
logger
|> emergency("er")
pub fn emergencyf(logger: Glog, string: String, values: List(Arg)) -> Glog

Prints Emergency log with current fields stored and the given message template and values

Calling this function return a new Glog. Old Glog can still be used.

Usage

import glog.{Glog}

let logger: Glog = glog.new()
logger
|> emergencyf("~p is the new ~p", [arg.new("foo"), arg.new("bar")])
pub fn error(logger: Glog, message: String) -> Glog

Prints Err log with current fields stored and the given message

Calling this function return a new Glog. Old Glog can still be used.

pub fn errorf(logger: Glog, string: String, values: List(Arg)) -> Glog

Prints Err log with current fields stored and the given message template and values

Calling this function return a new Glog. Old Glog can still be used.

pub fn get_field(logger: Glog, key: String) -> Result(Field, Nil)

Fetches a field if it exists from its key

pub fn has_field(logger: Glog, key: String) -> Bool

Finds if a field exists from its key

pub fn info(logger: Glog, message: String) -> Glog

Prints Info log with current fields stored and the given message

Calling this function return a new Glog. Old Glog can still be used.

pub fn infof(logger: Glog, string: String, values: List(Arg)) -> Glog

Prints Info log with current fields stored and the given message template and values

Calling this function return a new Glog. Old Glog can still be used.

pub fn new() -> Glog

Initializes a new Glog representation

Usage

import glog.{Glog}

let logger: Glog = glog.new()
pub fn new_with(with: Option(List(Field))) -> Glog

Initializes a new Glog representation with fields

pub fn notice(logger: Glog, message: String) -> Glog

Prints Notice log with current fields stored and the given message

Calling this function return a new Glog. Old Glog can still be used.

pub fn noticef(logger: Glog, string: String, values: List(Arg)) -> Glog

Prints Notice log with current fields stored and the given message template and values

Calling this function return a new Glog. Old Glog can still be used.

pub fn set_default_config() -> Nil

Sets a default formatter for default handler

This function is what we want to recommend as default format or the lib

pub fn set_handler_log_level(handler: String, level: ConfigLevel) -> Nil

Sets log level for given handler

pub fn set_primary_log_level(level: ConfigLevel) -> Nil

Sets log level for primary handler

pub fn warning(logger: Glog, message: String) -> Glog

Prints Warning log with current fields stored and the given message

Calling this function return a new Glog. Old Glog can still be used.

pub fn warningf(logger: Glog, string: String, values: List(Arg)) -> Glog

Prints Warning log with current fields stored and the given message template and values

Calling this function return a new Glog. Old Glog can still be used.

Search Document