rusty_logger/
lib.rs

1#[cfg(test)]
2mod tests {
3    use crate::Logger;
4
5    #[test]
6    fn log() {
7        let x = 30;
8        let mut logger = Logger::new("MAIN", std::io::stdout());
9        logger.options.time_unit = crate::types::TimeUnit::Microseconds;
10        logger.info("We will be testing a fibonnaci function");
11        logger.info(format!("Starting fibonnaci({})", x));
12        logger.timer_start("wrap");
13        logger.timer_start("fibonnaci");
14        let y = fibo(x);
15        logger.timer_log_and_stop("fibonnaci");
16        logger.timer_log_and_stop("wrap");
17        logger.info(format!(
18            "The result of the fibonnaci function until {} is : {}",
19            x, y
20        ));
21    }
22
23    fn fibo(n: usize) -> usize {
24        if n < 3 {
25            1
26        } else {
27            fibo_alt(1, 1, n)
28        }
29    }
30
31    fn fibo_alt(a: usize, b: usize, n: usize) -> usize {
32        if n == 2 {
33            b
34        } else {
35            fibo_alt(b, a + b, n - 1)
36        }
37    }
38}
39
40mod timer;
41
42pub mod logger;
43pub mod modules;
44pub mod options;
45pub mod types;
46
47pub use crate::logger::Logger;
48pub use crate::modules::Module;
49pub use crate::options::Options;