diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index d8aa01b..cdee397 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -4,10 +4,12 @@ # Quick Start +- [Rust](./platform/rust.md) - [Flutter](./platform/flutter.md) - [Android](./platform/android.md) - [iOS](./platform/ios.md) -- [Rust](./platform/rust.md) + +[Log query](./query.md) [Benchmark](./benchmark.md) diff --git a/docs/src/images/ui-screenshot.png b/docs/src/images/ui-screenshot.png new file mode 100644 index 0000000..7428c40 Binary files /dev/null and b/docs/src/images/ui-screenshot.png differ diff --git a/docs/src/platform/android.md b/docs/src/platform/android.md index ca34e65..80739f4 100644 --- a/docs/src/platform/android.md +++ b/docs/src/platform/android.md @@ -69,6 +69,9 @@ override fun onCreate() { Log.i("ezlog", "$logName $date $err") } }) + + // get logs + EZLog.requestLogFilesForDate("demo", new Date()) } ``` diff --git a/docs/src/platform/flutter.md b/docs/src/platform/flutter.md index debce8f..0fb8c88 100644 --- a/docs/src/platform/flutter.md +++ b/docs/src/platform/flutter.md @@ -45,7 +45,7 @@ class _MyAppState extends State { logger.d("init", "success"); - var logs = await EZLog.requestLogFilesForDate("main", "2022_08_25"); + var logs = await EZLog.requestLogFilesForDate("main", DateTime.now()); } } ``` diff --git a/docs/src/platform/ios.md b/docs/src/platform/ios.md index dbc5f9f..19c8b70 100644 --- a/docs/src/platform/ios.md +++ b/docs/src/platform/ios.md @@ -53,6 +53,9 @@ init() { }) logger.debug("first blood") + + let millis = Int64((date.timeIntervalSince1970 * 1000.0).rounded()) + requestLogsForDate(logName: "demo", start: millis, end: millis) } ``` click run and see console ouput. diff --git a/docs/src/platform/rust.md b/docs/src/platform/rust.md index 5d63988..72b7304 100644 --- a/docs/src/platform/rust.md +++ b/docs/src/platform/rust.md @@ -17,7 +17,21 @@ use ezlog::Level; use log::{error, info, warn}; use log::{LevelFilter, Log}; -ezlog::InitBuilder::new().init(); +let on_success: fn(&str, &str, &[&str]) = |name, date, logs| { + println!( + "on_success: name: {}, desc: {}, tags: {:?}", name, date, logs + ); +}; + +let on_fail: fn(&str, &str, &str) = |name, date, err| { + println!( + "on_fail: name: {}, desc: {}, err: {}", name, date, err + ); +}; + +ezlog::InitBuilder::new() + .with_request_callback_fn(on_success, on_fail) + .init(); let config = EZLogConfigBuilder::new() .level(Level::Trace) @@ -33,6 +47,12 @@ ezlog::create_log(config); info!("hello ezlog"); +ezlog::request_log_files_for_date( + ezlog::DEFAULT_LOG_NAME, + OffsetDateTime::now_utc(), + OffsetDateTime::now_utc() +); + ``` see more examples in examples dir. diff --git a/docs/src/query.md b/docs/src/query.md new file mode 100644 index 0000000..513baf0 --- /dev/null +++ b/docs/src/query.md @@ -0,0 +1,11 @@ +## Logs Query&View + +### View Logs + +If you want view a log file, you can use cmdline tools to parse the log, and open the output file in any text viewer application. Or you can download ezlog-ui application which is a desktop app built by tauri, it support decompress and decrypt. + +download at [release page]( https://github.com/s1rius/ezlog/releases/tag/ezlog-ui-0.1.0) + +Open the app, and drag the log file to the window, you can see the log conent. + +![screenshot](images/ui-screenshot.png) diff --git a/ezlog-core/src/decode.rs b/ezlog-core/src/decode.rs index 20b0775..6c72fee 100644 --- a/ezlog-core/src/decode.rs +++ b/ezlog-core/src/decode.rs @@ -293,7 +293,6 @@ mod tests { use time::OffsetDateTime; use super::decode_record; - use crate::{thread_name, LogError}; use crate::{ decode, EZLogger, @@ -301,6 +300,10 @@ mod tests { EZRecordBuilder, Header, }; + use crate::{ + thread_name, + LogError, + }; #[cfg(feature = "decode")] fn create_all_feature_config(path: &str) -> crate::EZLogConfig { @@ -364,7 +367,9 @@ mod tests { count += 1; } if is_end { - tx.send(()).unwrap_or_else(|_| { LogError::Parse("Could not send signal on channel.".to_string()); }); + tx.send(()).unwrap_or_else(|_| { + LogError::Parse("Could not send signal on channel.".to_string()); + }); return None; } Some(0) @@ -376,7 +381,9 @@ mod tests { header, my_closure, ); - rx.recv().unwrap_or_else(|_| { LogError::Parse("Could not receive from channel.".to_string()); }); + rx.recv().unwrap_or_else(|_| { + LogError::Parse("Could not receive from channel.".to_string()); + }); Ok(count) } @@ -443,7 +450,9 @@ mod tests { } } if is_end { - tx.send(()).unwrap_or_else(|_| { LogError::Parse("Could not send signal on channel.".to_string()); }); + tx.send(()).unwrap_or_else(|_| { + LogError::Parse("Could not send signal on channel.".to_string()); + }); return None; } Some(0) @@ -455,7 +464,9 @@ mod tests { header, my_closure, ); - rx.recv().unwrap_or_else(|_| { LogError::Parse("Could not receive from channel.".to_string()); }); + rx.recv().unwrap_or_else(|_| { + LogError::Parse("Could not receive from channel.".to_string()); + }); Ok(array) }