Struct Builder

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

Builder object to build a logger

Implementations§

Source§

impl Builder

Source

pub fn format( self, fmt: impl Fn(&mut String, &Record<'_>) -> Result + Send + Sync + 'static, ) -> Self

Set a function which is called every time logger formats strings

Examples found in repository?
examples/format.rs (line 8)
4fn main() {
5    stdweb::initialize();
6
7    stdweb_logger::builder()
8        .format(|s, r| write!(s, "{}: {}: {}", r.level(), r.target(), r.args()))
9        .build();
10
11    error!("{} -> {}", "test1", 1);
12    warn!("{} -> {}", "test2", 2);
13    info!("{} -> {}", "test3", 3);
14    debug!("{} -> {}", "test4", 4);
15    trace!("{} -> {}", "test5", 5);
16
17    stdweb::event_loop();
18}
Source

pub fn filter(self, filter: LevelFilter) -> Self

Set log level filter

Examples found in repository?
examples/detail.rs (line 7)
3fn main() {
4    stdweb::initialize();
5
6    stdweb_logger::builder()
7        .filter(LevelFilter::Debug)
8        .detail()
9        .build();
10
11    error!("{} -> {}", "test1", 1);
12    warn!("{} -> {}", "test2", 2);
13    info!("{} -> {}", "test3", 3);
14    debug!("{} -> {}", "test4", 4);
15    trace!("{} -> {}", "test5", 5);
16
17    stdweb::event_loop();
18}
Source

pub fn detail(self) -> Self

Show more detail (line numbers, file names etc.) in log

Examples found in repository?
examples/detail.rs (line 8)
3fn main() {
4    stdweb::initialize();
5
6    stdweb_logger::builder()
7        .filter(LevelFilter::Debug)
8        .detail()
9        .build();
10
11    error!("{} -> {}", "test1", 1);
12    warn!("{} -> {}", "test2", 2);
13    info!("{} -> {}", "test3", 3);
14    debug!("{} -> {}", "test4", 4);
15    trace!("{} -> {}", "test5", 5);
16
17    stdweb::event_loop();
18}
Source

pub fn build(self)

Sets the logger

Examples found in repository?
examples/detail.rs (line 9)
3fn main() {
4    stdweb::initialize();
5
6    stdweb_logger::builder()
7        .filter(LevelFilter::Debug)
8        .detail()
9        .build();
10
11    error!("{} -> {}", "test1", 1);
12    warn!("{} -> {}", "test2", 2);
13    info!("{} -> {}", "test3", 3);
14    debug!("{} -> {}", "test4", 4);
15    trace!("{} -> {}", "test5", 5);
16
17    stdweb::event_loop();
18}
More examples
Hide additional examples
examples/format.rs (line 9)
4fn main() {
5    stdweb::initialize();
6
7    stdweb_logger::builder()
8        .format(|s, r| write!(s, "{}: {}: {}", r.level(), r.target(), r.args()))
9        .build();
10
11    error!("{} -> {}", "test1", 1);
12    warn!("{} -> {}", "test2", 2);
13    info!("{} -> {}", "test3", 3);
14    debug!("{} -> {}", "test4", 4);
15    trace!("{} -> {}", "test5", 5);
16
17    stdweb::event_loop();
18}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.