LogPrefs

Struct LogPrefs 

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

Preferences that dictate logging.

Implementations§

Source§

impl LogPrefs

Source

pub fn quiet(&mut self, quiet: bool) -> &mut Self

Sets whether all output should be silenced, regardless of log level.

§Example
bunt_logger::with().quiet(true);
Source

pub fn level(&mut self, level: Level) -> &mut Self

Sets the log level.

§Example
use bunt_logger::Level;

bunt_logger::with().level(Level::Debug);
Examples found in repository?
examples/basic.rs (line 5)
3fn main() {
4    bunt_logger::with()
5        .level(Level::Trace)
6        .stderr(ColorChoice::Always);
7
8    error!("{$red+bold}A red and bold error message!{/$}");
9    warn!("{$yellow}A yellow warning message!{/$}");
10    info!("{$green}A green info message!{/$}");
11    debug!("{$cyan}A cyan debug message!{/$}");
12    trace!("{$white+dimmed}A white and dimmed trace message!{/$}");
13}
Source

pub fn writer(&mut self, writer: Box<dyn WriteColor + Send + Sync>) -> &mut Self

Sets the logging target.

By default, StandardStream::stdout(ColorChoice::Auto) is used.

§Example
use bunt_logger::{ColorChoice, StandardStream};

let stderr_writer = StandardStream::stderr(ColorChoice::Never);
bunt_logger::with()
    .writer(Box::new(stderr_writer));
Source

pub fn stdout(&mut self, color: ColorChoice) -> &mut Self

Sets the logging target to stdout with the given ColorChoice.

§Example
use bunt_logger::ColorChoice;

bunt_logger::with()
    .stdout(ColorChoice::Always);
Source

pub fn stderr(&mut self, color: ColorChoice) -> &mut Self

Sets the logging target to stderr with the given ColorChoice.

§Example
use bunt_logger::ColorChoice;

bunt_logger::with()
    .stderr(ColorChoice::Always);
Examples found in repository?
examples/basic.rs (line 6)
3fn main() {
4    bunt_logger::with()
5        .level(Level::Trace)
6        .stderr(ColorChoice::Always);
7
8    error!("{$red+bold}A red and bold error message!{/$}");
9    warn!("{$yellow}A yellow warning message!{/$}");
10    info!("{$green}A green info message!{/$}");
11    debug!("{$cyan}A cyan debug message!{/$}");
12    trace!("{$white+dimmed}A white and dimmed trace message!{/$}");
13}

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.