[][src]Struct loggify::LogBuilder

pub struct LogBuilder { /* fields omitted */ }

Struct for building a new logger

Implementations

impl LogBuilder[src]

pub fn new() -> Self[src]

Creates a new instance of the LogBuilder

Defaults

  • level -> The default level is Info
  • exclude -> No targets are excluded
  • time_format -> dd.mm.YY HH:MM:SS
  • log_target -> false

Example

//! Example for initializing the logger with the LogBuilder
use log::{error, warn, info, debug, trace};
use loggify::LogBuilder;
 
/// The `LogBuilder` is used to set more logger options
/// This example will change the log level to Trace
/// and the printed time format to time only
fn main() {
    LogBuilder::new()
        .set_level(log::Level::Trace)
        .set_time_format(String::from("%H:%M:%S"))
        .build()
        .unwrap();
 
    error!("My error message");
    warn!("My warn message");
    info!("My info message");
    debug!("My debug message");
    trace!("My trace message");
}

pub fn add_exclude(self, name: String) -> Self[src]

Adds a new target to exclude from logging

See the example exclude for usage

pub fn set_level(self, level: Level) -> Self[src]

Sets the minimum level

pub fn set_time_format(self, format: String) -> Self[src]

Sets the time format See https://docs.rs/chrono/0.4.6/chrono/format/strftime/index.html for supported escape sequences

pub fn set_log_target(self, state: bool) -> Self[src]

Defines if the log target should be printed or not This option should be used to find out where a log comes from and what target to exclude from logging

pub fn disable_color(self) -> Self[src]

Disables color output Per default true

pub fn build(self) -> Result<(), SetLoggerError>[src]

Creates a new logger

Trait Implementations

impl Default for LogBuilder[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

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.

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.