pub struct ConfigBuilder(/* private fields */);

Implementations§

source§

impl ConfigBuilder

source

pub fn new() -> ConfigBuilder

source

pub fn new_preset_config_full() -> ConfigBuilder

Preset for saving bigger amount of information than default preset

source

pub fn new_preset_no_micros_in_time() -> ConfigBuilder

source

pub fn set_format_text( &mut self, format_text: &'static str, level: Option<LevelFilter> ) -> &mut ConfigBuilder

Sets format of logged message E.g. “[_time] [[_level]] [_module] "[_msg]"” depending on other settings, may print something like: 14:21:15 [INFO] main: “Hello world!” If level is none, it will set all levels

source

pub fn set_background_color( &mut self, background_color: Option<Color>, level: Option<LevelFilter> ) -> &mut ConfigBuilder

Sets background color If color is none, background will not be colored If level is none, it will set all levels If level is some, it will set only that level Background color is used only if enabled_colors is true

source

pub fn set_colored_text_color( &mut self, colored_text_color: Option<Color>, level: Option<LevelFilter> ) -> &mut ConfigBuilder

Sets text color If color is none, text will be invisible If level is none, it will set all levels If level is some, it will set only that level Background color is used only if enabled_colors is true

source

pub fn set_enabled_colours( &mut self, enabled_colours: bool ) -> &mut ConfigBuilder

Enables colouring of text - only works with TermLogger

source

pub fn set_level(&mut self, level: LevelFilter) -> &mut ConfigBuilder

Sets the level of the logger. E.g. using LevelFilter::Info will print all logs with level Info, Warn, Error, but not Debug or Trace.

source

pub fn set_write_once(&mut self, write_once: bool) -> &mut ConfigBuilder

Instead of writing multiple times to target, creates a buffer, writes to memory and at the end writes only once to target This is useful when saving to file, because allows to not split one log into multiple files if rotating is used. Works only with WriteLogger

source

pub fn set_time_format( &mut self, time_format: TimeFormat, level: Option<LevelFilter> ) -> &mut ConfigBuilder

Set time format used in logger If level is none, it will set all levels Time format can be predefined(Rfc2822 or Rfc3339) or custom

source

pub fn set_time_offset(&mut self, offset: UtcOffset) -> &mut ConfigBuilder

Manually sets the offset used for the time.

source

pub fn set_time_offset_to_local( &mut self ) -> Result<&mut ConfigBuilder, &mut ConfigBuilder>

Sets the offset used to the current local time offset

source

pub fn set_remove_time_offset(&mut self) -> &mut ConfigBuilder

Reset the offset used to UTC

source

pub fn set_message_filtering<F>( &mut self, message_filtering: Option<F> ) -> &mut ConfigBuilderwhere F: Fn(&Record<'_>) -> bool + Send + Sync + 'static,

Sets function that will be used to filter messages If function returns true, message will be logged, otherwise it will be ignored Function takes as argument function that will be filtered allowed results If message_filtering is none, all messages will be logged

use log::{info, Record};
use handsome_logger::{Config, ConfigBuilder};

fn filtering_messages(record: &Record) -> bool {
    if let Some(arg) = record.args().as_str() {
        !arg.contains("E")
    } else {
        true
    }
}

let logger = ConfigBuilder::new().set_message_filtering(Some(filtering_messages)).build();
info!("Got BED"); // This will be ignored
info!("Got ANANAS"); // This will be printed
source

pub fn set_custom_write_formatter<F>( &mut self, write_formatter: Option<F> ) -> &mut ConfigBuilderwhere F: Fn(&Record<'_>, &mut dyn Write) -> Result<(), Error> + Send + Sync + 'static,

Sets custom formatter for WriteLogger If you don’t want to use default formatter, you can set your own Setting write_formatter to None will use default formatter Function takes as argument function that will be filtered allowed results

source

pub fn set_custom_terminal_formatter<F>( &mut self, terminal_formatter: Option<F> ) -> &mut ConfigBuilderwhere F: Fn(&Record<'_>, &mut BufferedStandardStream) -> Result<(), Error> + Send + Sync + 'static,

Sets custom formatter for TermLogger If you don’t want to use default formatter, you can set your own Setting terminal_formatter to None will use default formatter Function takes as argument function that will be filtered allowed results

source

pub fn build(&mut self) -> Config

Builds the config

Trait Implementations§

source§

impl Clone for ConfigBuilder

source§

fn clone(&self) -> ConfigBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ConfigBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ConfigBuilder

source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.