Skip to content

Commit

Permalink
add HowPack
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxiujia committed Jul 27, 2024
1 parent ea410b7 commit ed96afc
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions example/src/split_log.rs
Original file line number Diff line number Diff line change
@@ -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 {},
))
Expand Down
4 changes: 2 additions & 2 deletions example/src/split_log_gz.rs
Original file line number Diff line number Diff line change
@@ -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 {},
))
Expand Down
4 changes: 2 additions & 2 deletions example/src/split_log_lz4.rs
Original file line number Diff line number Diff line change
@@ -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 {},
))
Expand Down
4 changes: 2 additions & 2 deletions example/src/split_log_zip.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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;

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 {},
))
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/file_split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit ed96afc

Please sign in to comment.