Crates.io | cbsk_log_tokio |
lib.rs | cbsk_log_tokio |
version | 2.0.6 |
source | src |
created_at | 2024-08-26 10:42:32.070232 |
updated_at | 2024-11-15 03:31:32.585151 |
description | cbsk_log_tokio is a log tool, using tokio as the runtime |
homepage | |
repository | https://github.com/lifeRobot/cbsk/tree/master/libs/cbsk_log_tokio |
max_upload_size | |
id | 1352068 |
size | 24,827 |
cbsk_log is a log tool, the inspiration for this log writing library comes from fast_log
1.80.0
Cargo.toml:
cbsk_base = "2.0.2"
cbsk_log_tokio = "2.0.2"
main.rs:
use cbsk_base::{log, tokio};
use cbsk_log_tokio::cbsk_log::config::Config;
use cbsk_log_tokio::cbsk_log::model::log_size::LogSize;
use cbsk_log_tokio::config::FileSplitTrait;
use cbsk_log_tokio::packer::zip_packer::ZipPacker;
#[tokio::main]
async fn main() {
let config = Config::default().file_split("E:\\logs\\", LogSize::KB(5), ZipPacker::pack_end(|zip_path| {
Box::pin(async move {
println!("{zip_path}");
})
}));
cbsk_log_tokio::init(config).unwrap();
for i in 1..10000 {
log::info!("hello world, {i}");
}
log::logger().flush();
}
Cargo.toml:
cbsk_base = "2.0.2"
cbsk_log_tokio = "2.0.2"
main.rs:
use cbsk_base::{log, tokio};
use cbsk_log_tokio::cbsk_log::config::Config;
#[tokio::main]
async fn main() {
cbsk_log_tokio::init(Config::default().console()).unwrap();
for i in 1..10000 {
log::info!("hello world, {i}");
}
log::logger().flush();
}