log+x86_64 +linux

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::stderr by default. The user may configure a new global logger via setlogger.

Index

Types

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

// Undocumented types:
type stdlogger = struct {
	logger,
	sink: io::handle,
};

Globals

const default: *logger;
let global: *logger;
const silent: *logger;

Functions

fn fatal(fields: fmt::formattable...) never;
fn fatalf(fmt: str, fields: fmt::field...) never;
fn lfatal(log: *logger, fields: fmt::formattable...) never;
fn lfatalf(log: *logger, fmt: str, fields: fmt::field...) never;
fn lprintfln(log: *logger, fmt: str, fields: fmt::field...) void;
fn lprintln(log: *logger, fields: fmt::formattable...) void;
fn new(sink: io::handle) stdlogger;
fn printfln(fmt: str, fields: fmt::field...) void;
fn println(fields: fmt::formattable...) void;
fn setlogger(log: *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 default[link]

const default: *logger;

Default logger that writes to os::stderr.

let global[link]

let global: *logger;

The global logger instance.

let silent[link]

const silent: *logger;

A logger that does not print any messages.

Functions

fn fatal[link]

fn fatal(fields: fmt::formattable...) never;

Prints data to the global log with new line, then terminates the process.

fn fatalf[link]

fn fatalf(fmt: str, fields: fmt::field...) never;

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

fn lfatal[link]

fn lfatal(log: *logger, fields: fmt::formattable...) never;

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

fn lfatalf[link]

fn lfatalf(log: *logger, fmt: str, fields: fmt::field...) never;

Formats and prints data to the log with new line, 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.