Struct rusty_logger::logger::Logger [−][src]
Fields
options: Options<T>Implementations
impl<T: Write> Logger<T>[src]
impl<T: Write> Logger<T>[src]pub fn new(s: &str, output: T) -> Self[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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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,
T: RefUnwindSafe,
impl<T> Send for Logger<T> where
T: Send,
T: Send,
impl<T> Sync for Logger<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Logger<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Logger<T> where
T: UnwindSafe,
T: UnwindSafe,