Struct rusty_logger::logger::Logger[][src]

pub struct Logger<T: Write> {
    pub options: Options<T>,
    // some fields omitted
}

Fields

options: Options<T>

Implementations

impl<T: Write> Logger<T>[src]

pub fn new(s: &str, output: T) -> Self[src]

Creates a new Logger with default values and the given name

Example

use rusty_logger::logger::Logger;

let mut logger = Logger::new("name", std::io::stdout());
logger.info("This is a new logger named 'name' !");

pub fn with_options(s: &str, options: Options<T>) -> Logger<T>[src]

Creates a new Logger with default values, custom options and the given name

Example

use rusty_logger::logger::{Logger, Options};

let options = Options::new(std::io::stdout());
let mut logger = Logger::with_options("name", options);
logger.info("This is a new logger named 'name' which has 'options' as its options !");

pub fn static_log<D: Display>(msg: D, msg_type: LogType, output: T)[src]

Static implementation for the log function

Mainly used to print internal error messages but can also be used by an end user

Example

use rusty_logger::logger::{Logger, LogType};

Logger::static_log("Printing on the fly", LogType::Info, std::io::stdout());

pub fn info<D: Display>(&mut self, msg: D)[src]

Logs the given message to the output as an information

Example

use rusty_logger::logger::{Logger, LogType};

let mut logger = Logger::new("name", std::io::stdout());
logger.info("Here is some information I want to log");

pub fn warn<D: Display>(&mut self, msg: D)[src]

Logs the given message to the output as a warning

Example

use rusty_logger::logger::{Logger, LogType};

let mut logger = Logger::new("name", std::io::stdout());
logger.warn("Here is a warning");

pub fn error<D: Display>(&mut self, msg: D)[src]

Logs the given message to the output as an error

Example

use rusty_logger::logger::{Logger, LogType};

let mut logger = Logger::new("name", std::io::stdout());
logger.info("Some error happened");

pub fn timer_start(&mut self, msg: &str)[src]

Starts a new timer with the given name and the actual time

pub fn timer_get(&self, msg: &str) -> Option<Duration>[src]

Gets the duration from when the timer with the given name was started

pub fn timer_stop(&mut self, msg: &str) -> Option<Duration>[src]

Stops the timer with the given name and returns it as a duration

pub fn timer_reset(&mut self, msg: &str) -> Option<Duration>[src]

Resets the timer with the given name and returns the duration of the timer before being reset as a duration

pub fn timer_log(&mut self, msg: &str)[src]

Logs the time elapsed between the start/reset of the timer and now without reseting it

Example

use rusty_logger::logger::{Logger, LogType};

let mut logger = Logger::new("name", std::io::stdout());

logger.timer_start("new_timer");

std::thread::sleep(std::time::Duration::from_millis(1));

logger.timer_log("new_timer");

pub fn timer_log_and_stop(&mut self, msg: &str)[src]

Logs the time elapsed between the start/reset of the timer and now and then stops it

Example

use rusty_logger::logger::{Logger, LogType};

let mut logger = Logger::new("name", std::io::stdout());

logger.timer_start("new_timer");

std::thread::sleep(std::time::Duration::from_millis(1));

logger.timer_log_and_stop("new_timer");

pub fn timer_log_and_reset(&mut self, msg: &str)[src]

Logs the time elapsed between the start/reset of the timer and now and then resets it

Example

use rusty_logger::logger::{Logger, LogType};

let mut logger = Logger::new("name", std::io::stdout());

logger.timer_start("new_timer");

std::thread::sleep(std::time::Duration::from_millis(1));

logger.timer_log_and_reset("new_timer");

std::thread::sleep(std::time::Duration::from_millis(1));

logger.timer_log_and_stop("new_timer");

Auto Trait Implementations

impl<T> RefUnwindSafe for Logger<T> where
    T: RefUnwindSafe

impl<T> Send for Logger<T> where
    T: Send

impl<T> Sync for Logger<T> where
    T: Sync

impl<T> Unpin for Logger<T> where
    T: Unpin

impl<T> UnwindSafe for Logger<T> where
    T: UnwindSafe

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.