diff --git a/example/src/split_log.rs b/example/src/split_log.rs index a29559a..2a1383b 100644 --- a/example/src/split_log.rs +++ b/example/src/split_log.rs @@ -1,13 +1,13 @@ use fast_log::config::Config; use fast_log::consts::LogSize; -use fast_log::plugin::file_split::{PackType, KeepType}; +use fast_log::plugin::file_split::{PackType, KeepType, HowPack}; use fast_log::plugin::packer::LogPacker; fn main() { //file_path also can use '"target/logs/test.log"' fast_log::init(Config::new().chan_len(Some(100000)).console().file_split( "target/logs/", - PackType::BySize(LogSize::KB(500)), + HowPack::new(PackType::BySize(LogSize::KB(500))), KeepType::KeepNum(2), LogPacker {}, )) diff --git a/example/src/split_log_gz.rs b/example/src/split_log_gz.rs index f978a47..41c12ef 100644 --- a/example/src/split_log_gz.rs +++ b/example/src/split_log_gz.rs @@ -1,12 +1,12 @@ use fast_log::config::Config; use fast_log::consts::LogSize; -use fast_log::plugin::file_split::{PackType, KeepType}; +use fast_log::plugin::file_split::{PackType, KeepType, HowPack}; use fast_log::plugin::packer::GZipPacker; fn main() { fast_log::init(Config::new().chan_len(Some(100000)).console().file_split( "target/logs/", - PackType::BySize(LogSize::KB(50)), + HowPack::new(PackType::BySize(LogSize::KB(50))), KeepType::KeepNum(5), GZipPacker {}, )) diff --git a/example/src/split_log_lz4.rs b/example/src/split_log_lz4.rs index 6b09dc8..d008521 100644 --- a/example/src/split_log_lz4.rs +++ b/example/src/split_log_lz4.rs @@ -1,12 +1,12 @@ use fast_log::config::Config; use fast_log::consts::LogSize; -use fast_log::plugin::file_split::{PackType, KeepType}; +use fast_log::plugin::file_split::{PackType, KeepType, HowPack}; use fast_log::plugin::packer::LZ4Packer; fn main() { fast_log::init(Config::new().chan_len(Some(100000)).console().file_split( "target/logs/", - PackType::BySize(LogSize::KB(50)), + HowPack::new(PackType::BySize(LogSize::KB(50))), KeepType::KeepNum(5), LZ4Packer {}, )) diff --git a/example/src/split_log_zip.rs b/example/src/split_log_zip.rs index d37b34a..450e1b1 100644 --- a/example/src/split_log_zip.rs +++ b/example/src/split_log_zip.rs @@ -1,5 +1,5 @@ use fast_log::consts::LogSize; -use fast_log::plugin::file_split::{PackType, KeepType}; +use fast_log::plugin::file_split::{PackType, KeepType, HowPack}; use fast_log::plugin::packer::ZipPacker; use fast_log::config::Config; @@ -7,7 +7,7 @@ use fast_log::config::Config; fn main() { fast_log::init(Config::new().chan_len(Some(100000)).console().file_split( "target/logs/", - PackType::BySize(LogSize::KB(50)), + HowPack::new(PackType::BySize(LogSize::KB(50))), KeepType::KeepNum(5), ZipPacker {}, )) diff --git a/src/plugin/file_split.rs b/src/plugin/file_split.rs index 45792c0..c69ff2a 100644 --- a/src/plugin/file_split.rs +++ b/src/plugin/file_split.rs @@ -257,7 +257,7 @@ impl CanPack for HowPack { PackType::BySize(limit) => { if temp_size >= limit.get_len() { let log_name = { - let last_time = DateTime::now(); + let last_time = DateTime::from_system_time(last_time, fastdate::offset_sec()); if let Some(idx) = temp_name.rfind(".") { let suffix = &temp_name[idx..]; temp_name.replace(suffix, &last_time.format(&format!("YYYY-MM-DDThh-mm-ss.000000{}", suffix)))