代码拉取完成,页面将自动刷新
本程序仿照杰哥的fast_log进行copy!
the fast log . This crate uses #![forbid(unsafe_code)] to ensure everything is implemented in 100% Safe Rust.
一款追求极致速度的日志实现,使用crossbeam 无锁channel提高一倍效率(相对于标准库的mpsc),使用channel异步写日志。完全使用safe 代码实现,无不安全代码
-----------------
log data-> | main channel(crossbeam) | ->
-----------------
---------------- ----------------------
-> |coroutines channel(may)| -> background coroutines | appender1 |
---------------- ----------------------
---------------- ----------------------
-> |coroutines channel(may)| -> background coroutines | appender2 |
---------------- ----------------------
---------------- ----------------------
-> |coroutines channel(may)| -> background coroutines | appender3 |
---------------- ----------------------
---------------- ----------------------
-> |coroutines channel(may)| -> background coroutines | appender4 |
---------------- ----------------------
log = "0.4"
venom_log="0.1"
use venom_log::{init};
use log::{error, info, warn};
fn main(){
let log = venom_log::init(Config::new().console()).unwrap();
log::info!("Commencing yak shaving{}", 0);
info!("Commencing yak shaving");
}
#[test]
use venom_log::plugin::file_split::RollingType;
use venom_log::consts::LogSize;
use venom_log::plugin::packer::LogPacker;
#[test]
pub fn test_file_compation() {
venom_log::init(Config::new()
.console()
.file_split("target/logs/",
LogSize::MB(1),
RollingType::All,
LogPacker{})).unwrap();
for _ in 0..200000 {
info!("Commencing yak shaving");
}
sleep(Duration::from_secs(1));
}
use venom_log::{LogAppender};
use log::{error, info, warn};
pub struct CustomLog{}
impl LogAppender for CustomLog{
fn do_log(&mut self, record: &VenomLogRecord) {
print!("{}",record);
}
}
fn main(){
let wait = venom_log::init(Config::new().custom(CustomLog {})).unwrap();
info!("Commencing yak shaving");
sleep(std::time::Duration::from_secs(1));
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。