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 ed96afc commit 5336a52
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,50 @@ fn main(){
```


#### Split Log(ByLogDate)

#### Split Log(.log packer)
```rust
use fast_log::config::Config;
use fast_log::plugin::file_split::{PackType, KeepType, DateType, HowPack};
use std::thread::sleep;
use std::time::Duration;
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/",
HowPack::new(PackType::ByDate(DateType::Day)),
KeepType::KeepNum(2),
LogPacker {},
)).unwrap();
for _ in 0..60 {
sleep(Duration::from_secs(1));
log::info!("Commencing yak shaving");
}
log::logger().flush();
println!("you can see log files in path: {}", "target/logs/")
}

```


#### Split Log(ByLogSize)

```rust
use fast_log::plugin::file_split::RollingType;
use fast_log::config::Config;
use fast_log::consts::LogSize;
use fast_log::plugin::packer::LogPacker;
use fast_log::plugin::file_split::{PackType, KeepType, HowPack};

#[test]
pub fn test_file_compation() {
fast_log::init(Config::new()
.console()
.chan_len(Some(100000))
.file_split("target/logs/",
LogSize::MB(1),
RollingType::All,
HowPack::new(PackType::BySize(LogSize::MB(1))),
KeepType::All,
LogPacker{})).unwrap();
for _ in 0..200000 {
info!("Commencing yak shaving");
Expand Down

0 comments on commit 5336a52

Please sign in to comment.