|
| 1 | +use tklog::{handle::FileTimeMode, LogOption}; |
| 2 | + |
| 3 | +mod module1 { |
| 4 | + use std::{thread, time::Duration}; |
| 5 | + pub fn testmod() { |
| 6 | + tklog::debug!("module1,tklog api,LOG debug log>>", 1111); |
| 7 | + tklog::info!("module1,tklog api,LOG info log>>", 2222); |
| 8 | + thread::sleep(Duration::from_secs(1)) |
| 9 | + } |
| 10 | + pub mod m1 { |
| 11 | + pub fn testmod() { |
| 12 | + tklog::debug!("m1,tklog api,LOG debug log>>", 123); |
| 13 | + } |
| 14 | + } |
| 15 | + pub mod m2 { |
| 16 | + pub fn testmod() { |
| 17 | + tklog::debug!("m2,tklog api,LOG debug log>>", 123); |
| 18 | + } |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +mod module2 { |
| 23 | + use std::{thread, time::Duration}; |
| 24 | + pub fn testmod() { |
| 25 | + tklog::debug!("module2,tklog api,LOG debug log>>", 123); |
| 26 | + tklog::info!("module2,tklog api,LOG info log>>", 456); |
| 27 | + thread::sleep(Duration::from_secs(1)) |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +#[test] |
| 32 | +fn testmod() { |
| 33 | + tklog::LOG.set_mod_option("test_0210::module1::*", LogOption { level: None, format: None, formatter: None, console: Some(true), fileoption: Some(Box::new(FileTimeMode::new("syncmodule1.log", tklog::MODE::DAY, 0, true))) }); |
| 34 | + module1::testmod(); |
| 35 | + module1::m1::testmod(); |
| 36 | + module1::m2::testmod(); |
| 37 | + module2::testmod(); |
| 38 | +} |
| 39 | + |
| 40 | +mod module3 { |
| 41 | + pub async fn testmod() { |
| 42 | + tklog::async_debug!("async module3,tklog api,LOG debug log>>", 1111); |
| 43 | + tklog::async_info!("async module3,tklog api,LOG debug log>>", 2222); |
| 44 | + } |
| 45 | + pub mod m3 { |
| 46 | + pub async fn testmod() { |
| 47 | + tklog::async_debug!("async m1,tklog api,LOG debug log>>", 3333); |
| 48 | + } |
| 49 | + } |
| 50 | + pub mod m4 { |
| 51 | + pub async fn testmod() { |
| 52 | + tklog::async_info!("async m2,tklog api,LOG debug log>>", 4444); |
| 53 | + } |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +mod module4 { |
| 58 | + pub async fn testmod() { |
| 59 | + tklog::async_debug!("async module4,tklog api,LOG debug log>>", 1111); |
| 60 | + tklog::async_info!("async module4,tklog api,LOG info log>>", 2222); |
| 61 | + log::debug!("async module4,log api,debug log>>{}", 3333); |
| 62 | + log::info!("async module4,log api,info log>>{}", 4444); |
| 63 | + tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | +#[tokio::test] |
| 68 | +async fn testasyncmod() { |
| 69 | + tklog::ASYNC_LOG.set_mod_option("test_0210::module3::*", LogOption { level: None, format: None, formatter: None, console: Some(true), fileoption: Some(Box::new(FileTimeMode::new("asyncmodule2.log", tklog::MODE::DAY, 0, true))) }).await; |
| 70 | + module3::testmod().await; |
| 71 | + module3::m3::testmod().await; |
| 72 | + module3::m4::testmod().await; |
| 73 | + module4::testmod().await; |
| 74 | +} |
0 commit comments