Skip to content

Commit

Permalink
edit path
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxiujia committed Jan 7, 2022
1 parent 0dd3ea0 commit f9555e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ license = "MIT"


[features]
default = ["zip"]
default = ["zip","cogo"]
gzip = ["flate2"]

[dependencies]
Expand All @@ -28,7 +28,7 @@ crossbeam-utils = "0.8"
crossbeam = "0.8"
crossbeam-channel = "0.5"
parking_lot = "0.11"
cogo = "0.1"
cogo = {version = "0.1", optional = true }


zip = { version = "0.5", optional = true }
Expand Down
8 changes: 3 additions & 5 deletions src/fast_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ use std::result::Result::Ok;
use std::time::{SystemTime, Duration};
use std::sync::Arc;
use std::sync::mpsc::SendError;
use cogo::coroutine::{Builder, yield_now};
use cogo::go;

lazy_static! {
static ref LOG_SENDER: RwLock<Option<LoggerSender>> = RwLock::new(Option::None);
Expand Down Expand Up @@ -198,13 +196,13 @@ pub fn init_custom_log(
}
appender.do_log(msg.as_ref());
} else {
yield_now();
cogo::coroutine::yield_now();
}
}
});
} else {
// if is network appender, use thread spawn
go!(Builder::new().stack_size(2*0x1000),move ||{
cogo::go!(cogo::coroutine::Builder::new().stack_size(2*0x1000),move ||{
loop{
if let Ok(msg) = recever.recv(){
if msg.command.eq(&Command::CommandExit) {
Expand All @@ -231,7 +229,7 @@ pub fn init_custom_log(
break;
}
} else {
yield_now();
cogo::coroutine::yield_now();
}
}
});
Expand Down
10 changes: 3 additions & 7 deletions src/plugin/file_split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ use crate::appender::{Command, FastLogRecord, LogAppender};
use crate::consts::LogSize;
use std::ops::Sub;
use std::time::Duration;
use cogo::go;
use cogo::std::sync::mpsc::{Receiver, Sender};


use zip::result::ZipResult;
use crate::error::LogError;

Expand Down Expand Up @@ -131,7 +127,7 @@ pub struct FileSplitAppenderData {
max_split_bytes: usize,
dir_path: String,
file: File,
sender: Sender<LogPack>,
sender: cogo::std::sync::mpmc::Sender<LogPack>,
rolling_type: RollingType,
//cache data
temp_bytes: usize,
Expand Down Expand Up @@ -214,7 +210,7 @@ impl FileSplitAppender {
temp_bytes = m.len() as usize;
}
file.seek(SeekFrom::Start(temp_bytes as u64));
let (sender, receiver) = cogo::std::sync::mpsc::channel();
let (sender, receiver) = cogo::chan!();
spawn_saver(file_name,receiver, packer);
Self {
cell: RefCell::new(FileSplitAppenderData {
Expand Down Expand Up @@ -248,7 +244,7 @@ impl LogAppender for FileSplitAppender {
}

///spawn an saver thread to save log file or zip file
fn spawn_saver(temp_name: &str, r: Receiver<LogPack>, packer: Box<dyn Packer>) {
fn spawn_saver(temp_name: &str, r: cogo::std::sync::mpmc::Receiver<LogPack>, packer: Box<dyn Packer>) {
let temp = temp_name.to_string();
std::thread::spawn(move || {
loop {
Expand Down

0 comments on commit f9555e3

Please sign in to comment.