Struct slog::Logger [] [src]

pub struct Logger { /* fields omitted */ }

Logging handle used to execute logging statements

Logger handles logging context (key-value list) and handles logging statements.

Child loggers are build from existing loggers, and inherit existing key-value pairs from their parents, which can be supplemented with new ones.

Cloning existing loggers and creating new ones is cheap. Loggers can be freely passed around the code.

Methods

impl Logger
[src]

Build a root Logger

All children and their children and so on form one hierarchy sharing a common drain.

Root logger starts a new hierarchy associated with a given Drain. Root logger drain must return no errors. See DrainExt::ignore_err() and

DrainExt::fuse(). Use o! macro to help build key-value pairs with a nicer syntax.

#[macro_use]
extern crate slog;

fn main() {
    let root = slog::Logger::root(
        slog::Discard,
        o!("key1" => "value1", "key2" => "value2"),
    );
}

Build a child logger

Child logger inherits all existing key-value pairs from it's parent.

All children, their children and so on, form one hierarchy sharing a common drain.

Use o! macro to help build key value pairs using nicer syntax.

#[macro_use]
extern crate slog;

fn main() {
    let root = slog::Logger::root(slog::Discard,
        o!("key1" => "value1", "key2" => "value2"));
    let log = root.new(o!("key" => "value"));
}

Log one logging record

Use specific logging functions instead. See log! macro documentation.

Trait Implementations

impl Clone for Logger
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Logger
[src]

Formats the value using the given formatter.