pub struct Builder { /* private fields */ }
Expand description
Builder object to build a logger
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn format(
self,
fmt: impl Fn(&mut String, &Record<'_>) -> Result + Send + Sync + 'static,
) -> Self
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}
Sourcepub fn filter(self, filter: LevelFilter) -> Self
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}
Sourcepub fn detail(self) -> Self
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}
Sourcepub fn build(self)
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
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§
impl Freeze for Builder
impl !RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl !UnwindSafe for Builder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more