File: test_textfilter.rs

package info (click to toggle)
rust-flexi-logger 0.29.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,084 kB
  • sloc: makefile: 2
file content (38 lines) | stat: -rw-r--r-- 1,288 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
mod test_utils;

#[test]
#[cfg(feature = "textfilter")]
fn test_textfilter() {
    use flexi_logger::{default_format, FileSpec, LogSpecification, Logger};
    use log::*;

    let logspec = LogSpecification::parse("info/Hello").unwrap();
    let logger = Logger::with(logspec)
        .format(default_format)
        .print_message()
        .log_to_file(
            FileSpec::default()
                .directory(self::test_utils::dir())
                .suppress_timestamp(),
        )
        .start()
        .unwrap_or_else(|e| panic!("Logger initialization failed with {e}"));

    error!("This is an error message");
    warn!("This is a warning");
    info!("This is an info message");
    debug!("This is a debug message - you must not see it!");
    trace!("This is a trace message - you must not see it!");

    error!("Hello, this is an error message");
    warn!("This is a warning! Hello!!");
    info!("Hello, this is an info message! Hello");
    debug!("Hello, this is a debug message - you must not see it!");
    trace!("Hello, this is a trace message - you must not see it!");

    logger.validate_logs(&[
        ("ERROR", "test_textfilter", "Hello, this"),
        ("WARN", "test_textfilter", "! Hello!!"),
        ("INFO", "test_textfilter", "! Hello"),
    ]);
}