log +linux +x86_64

The log module provides a simple interface for application logging. The logger interface provides an abstraction that users may implement for custom logging logic. We provide a simple logger implementation that prefixes each line with the current timestamp; to initialize such a logger see new.

A global logger is also provided for simple applications to use, global, which is an instance of the standard logger that writes to os::stdout by default. The user may configure a new global logger via setlogger.

Index

Types

type logger;

// Undocumented types:
type stdlogger;

Globals

let global: *logger;

Functions

fn fatal(fmt::formattable...) void;
fn fatalf(str, fmt::field...) void;
fn lfatal(*logger, fmt::formattable...) void;
fn lfatalf(*logger, str, fmt::field...) void;
fn lprintfln(*logger, str, fmt::field...) void;
fn lprintln(*logger, fmt::formattable...) void;
fn new(io::handle) stdlogger;
fn printfln(str, fmt::field...) void;
fn println(fmt::formattable...) void;
fn setlogger(*logger) void;

Types

type logger[link]

type logger = struct {
	println: *fn(logger: *logger, fields: fmt::formattable...) void,
	printfln: *fn(logger: *logger, fmt: str, fields: fmt::field...) void,
};

Interface for implementing a logger.

type stdlogger[link]

Show undocumented member
type stdlogger = struct {
	logger,
	sink: io::handle,
};

Globals

let global[link]

let global: *logger;

The default global logger instance.

Functions

fn fatal[link]

@noreturn fn fatal(fields: fmt::formattable...) void;

Prints data to the global log, then terminates the process.

fn fatalf[link]

@noreturn fn fatalf(fmt: str, fields: fmt::field...) void;

Formats and prints data to the global log, then terminates the process.

fn lfatal[link]

@noreturn fn lfatal(log: *logger, fields: fmt::formattable...) void;

Prints data to the log with a newline, then terminates the process.

fn lfatalf[link]

@noreturn fn lfatalf(log: *logger, fmt: str, fields: fmt::field...) void;

Formats and prints data to the log, then terminates the process.

fn lprintfln[link]

fn lprintfln(log: *logger, fmt: str, fields: fmt::field...) void;

Formats and prints data to the log, with a newline.

fn lprintln[link]

fn lprintln(log: *logger, fields: fmt::formattable...) void;

Prints data to the log, with a newline.

fn new[link]

fn new(sink: io::handle) stdlogger;

Creates a new standard logger.

fn printfln[link]

fn printfln(fmt: str, fields: fmt::field...) void;

Formats and prints data to the global log, with a newline.

fn println[link]

fn println(fields: fmt::formattable...) void;

Prints data to the global log, with a newline.

fn setlogger[link]

fn setlogger(log: *logger) void;

Sets the global logger instance to the provided logger.