pub struct Builder { /* private fields */ }
Expand description

Builder for initializing logger

The builder is used to initialize the logging framework for later use. It provides

Implementations

Initializes the log builder with defaults.

Examples

Create a new builder and configure filters and style:


let mut builder = Builder::new();
builder.filter(None, LevelFilter::Info).init();

Use a specific android log buffer. Defaults to the main buffer is used as tag (if present).

Examples

let mut builder = Builder::new();
builder.buffer(Buffer::Crash)
    .init();

Use a specific log tag. If no tag is set the module path is used as tag (if present).

Examples

let mut builder = Builder::new();

builder.tag("foo")
    .init();

Use the target string as tag

Examples

let mut builder = Builder::new();
builder.tag_target().init();

Use the target string as tag and strip off ::.*

Examples

let mut builder = Builder::new();
builder.tag_target_strip().init();

Prepend module to log message.

If set true the Rust module path is prepended to the log message.

Examples

let mut builder = Builder::new();
builder.prepend_module(true).init();

Adds a directive to the filter for a specific module.

Examples

Only include messages for warning and above for logs in path::to::module:


let mut builder = Builder::new();

builder.filter_module("path::to::module", LevelFilter::Info).init();

Adds a directive to the filter for all modules.

Examples

Only include messages for warning and above for logs in path::to::module:


let mut builder = Builder::new();
builder.filter_level(LevelFilter::Info).init();

Adds filters to the logger.

The given module (if any) will log at most the specified level provided. If no module is provided then the filter will apply to all log messages.

Examples

Only include messages for warning and above for logs in path::to::module:


let mut builder = Builder::new();
builder.filter(Some("path::to::module"), LevelFilter::Info).init();

Parses the directives string in the same form as the RUST_LOG environment variable.

See the module documentation for more details.

Initializes the global logger with the built logd logger.

This should be called early in the execution of a Rust program. Any log events that occur before initialization will be ignored.

Errors

This function will fail if it is called more than once, or if another library has already initialized a global logger.

Initializes the global logger with the built logger.

This should be called early in the execution of a Rust program. Any log events that occur before initialization will be ignored.

Panics

This function will panic if it is called more than once, or if another library has already initialized a global logger.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.