mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-01-14 00:18:03 -05:00
Co-authored-by: colin <102356659+colinlyguo@users.noreply.github.com> Co-authored-by: Rohit Narurkar <rohit.narurkar@proton.me> Co-authored-by: colinlyguo <colinlyguo@scroll.io> Co-authored-by: colinlyguo <colinlyguo@users.noreply.github.com> Co-authored-by: Mengran Lan <mengran@scroll.io> Co-authored-by: amoylan2 <amoylan2@users.noreply.github.com> Co-authored-by: Mengran Lan <lanmengran@qq.com> Co-authored-by: Suuuuuuperrrrr fred <FredrikaPhililip@proton.me> Co-authored-by: sbaizet <74511063+sbaizet-ledger@users.noreply.github.com> Co-authored-by: caseylove <casey4love@foxmail.com> Co-authored-by: BoxChen <13927203+nishuzumi@users.noreply.github.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Co-authored-by: georgehao <georgehao@users.noreply.github.com>
33 lines
984 B
Rust
33 lines
984 B
Rust
use env_logger::Env;
|
|
use std::{fs::OpenOptions, sync::Once};
|
|
|
|
use crate::types::{ProverType, TaskType};
|
|
|
|
static LOG_INIT: Once = Once::new();
|
|
|
|
/// Initialize log
|
|
pub fn log_init(log_file: Option<String>) {
|
|
LOG_INIT.call_once(|| {
|
|
let mut builder = env_logger::Builder::from_env(Env::default().default_filter_or("info"));
|
|
if let Some(file_path) = log_file {
|
|
let target = Box::new(
|
|
OpenOptions::new()
|
|
.write(true)
|
|
.create(true)
|
|
.truncate(false)
|
|
.open(file_path)
|
|
.expect("Can't create log file"),
|
|
);
|
|
builder.target(env_logger::Target::Pipe(target));
|
|
}
|
|
builder.init();
|
|
});
|
|
}
|
|
|
|
pub fn get_task_types(prover_type: ProverType) -> Vec<TaskType> {
|
|
match prover_type {
|
|
ProverType::Chunk => vec![TaskType::Chunk],
|
|
ProverType::Batch => vec![TaskType::Batch, TaskType::Bundle],
|
|
}
|
|
}
|