Struct Settings

Source
pub struct Settings {
    pub title: &'static str,
    pub filters: &'static [(&'static str, LevelFilter)],
    pub file_out: Option<&'static Path>,
    pub console_out: bool,
    pub panic_hook: Option<fn(Panic<'_>)>,
}
Expand description

Settings for the logger

Fields§

§title: &'static str

A human-readable name for the application

§filters: &'static [(&'static str, LevelFilter)]

List of module-prefix filters to match against, earlier filters get priority

§file_out: Option<&'static Path>

Optional file path to output to (desktop only)

§console_out: bool

Set to true to output to an appropriate console

§panic_hook: Option<fn(Panic<'_>)>

Enables the formatted panic hook, and calls the supplied function. Use |_| () if you don’t have anything to run

Implementations§

Source§

impl Settings

Source

pub fn init(self)

Initializes the logger

§Panics

will panic if initialization fails in any way

Examples found in repository?
examples/demo.rs (line 22)
8fn main() {
9	multiline_logger::Settings {
10		title: "logger test",
11		filters: &[("", LevelFilter::Trace)],
12		file_out: Some(Path::new("target/test.log")),
13		console_out: true,
14		#[expect(clippy::print_stdout, reason = "demo")]
15		panic_hook: Some(|info| {
16			println!(
17				"Custom panic handler\nPanic info: {info:?}\nBacktrace: {:?}",
18				info.trace.as_string()
19			);
20		}),
21	}
22	.init();
23	log::trace!("Trace\n");
24	log::debug!("Debug\n{:?}", [1, 2, 3, 4]);
25	log::info!("Info: {}", 7);
26	log::warn!("Warn {:#?}", [0, 9, 8, 7]);
27	log::error!("Error");
28	panic!("Panic Message");
29}

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.