Struct android_logd_logger::Builder[][src]

pub struct Builder<'a> { /* fields omitted */ }
Expand description

Builder for initializing logger

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

Implementations

impl<'a> Builder<'a>[src]

pub fn new() -> Builder<'a>[src]

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();

pub fn buffer(&mut self, buffer: Buffer) -> &mut Self[src]

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();

pub fn tag(&mut self, tag: &'a str) -> &mut Self[src]

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();

pub fn prepend_module(&mut self, prepend: bool) -> &mut Self[src]

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();

pub fn filter_module(&mut self, module: &str, level: LevelFilter) -> &mut Self[src]

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);

pub fn filter_level(&mut self, level: LevelFilter) -> &mut Self[src]

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);

pub fn filter(&mut self, module: Option<&str>, level: LevelFilter) -> &mut Self[src]

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);

pub fn parse_filters(&mut self, filters: &str) -> &mut Self[src]

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

See the module documentation for more details.

pub fn try_init(&mut self) -> Result<(), SetLoggerError>[src]

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.

pub fn init(&mut self)[src]

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

impl<'a> Default for Builder<'a>[src]

fn default() -> Builder<'a>[src]

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

Auto Trait Implementations

impl<'a> RefUnwindSafe for Builder<'a>

impl<'a> Send for Builder<'a>

impl<'a> Sync for Builder<'a>

impl<'a> Unpin for Builder<'a>

impl<'a> UnwindSafe for Builder<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.