[][src]Struct casual_logger::Logger

pub struct Logger {
    pub retention_days: i64,
    pub level: Level,
    pub fatal_timeout_secs: u64,
    // some fields omitted
}

Examples:

All: 'tic-tac-toe-2020-07-11.log.toml' Prefix: 'tic-tac-toe' StartDate: '-2020-07-11' Suffix: '.log' Extention: '.toml'

If you don't like the .toml extension, leave the suffix empty and the .log extension.

Fields

retention_days: i64

File retention days. Delete the file after day from StartDate.

level: Level

Activation.

fatal_timeout_secs: u64

Timeout seconds when fatal.

Implementations

impl Logger[src]

pub fn enabled(&self, level: Level) -> bool[src]

Check level.

Examples

use casual_logger::{Level, Logger};
use std::sync::Mutex;

let mut logger = Logger::default();
logger.set_file_name("casual-log-test", ".log", ".toml");
if logger.enabled(Level::Trace) {
    assert_eq!(true, true);
} else {
    assert_eq!(true, false);
}

logger.level = Level::Debug;
if logger.enabled(Level::Trace) {
    assert_eq!(true, false);
} else {
    assert_eq!(true, true);
}

pub fn get_file_prefix(&self) -> &str[src]

Example:

If 'tic-tac-toe-2020-07-11.log.toml', This is 'tic-tac-toe'.

pub fn get_file_suffix(&self) -> &str[src]

Example:

If 'tic-tac-toe-2020-07-11.log.toml', This is '.log'.

pub fn get_file_extention(&self) -> &str[src]

Example:

If 'tic-tac-toe-2020-07-11.log.toml', This is '.toml'.

pub fn set_file_name(&mut self, prefix: &str, suffix: &str, extention: &str)[src]

Set name except StartDate.

Examples:

All: 'tic-tac-toe-2020-07-11.log.toml' Prefix: 'tic-tac-toe' StartDate: '-2020-07-11' Suffix: '.log' Extention: '.toml'

pub fn remove_old_logs(&self) -> usize[src]

For log rotation.

Trait Implementations

impl Default for Logger[src]

Auto Trait Implementations

impl RefUnwindSafe for Logger

impl Send for Logger

impl Sync for Logger

impl Unpin for Logger

impl UnwindSafe for Logger

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.