Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
biezhihua committed Jan 30, 2024
1 parent b179f37 commit 627776a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion soda_resource_tools_cli/.rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_width = 500
max_width = 150
disable_all_formatting = false
37 changes: 31 additions & 6 deletions soda_resource_tools_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,18 @@ fn init_lib_config_dev(lib_dir: &Path, rename_style: &RenameStyle) {
let mut config = soda::get_lib_config();
config.cache_path = lib_dir.join("cache").to_str().unwrap().to_string();
config.strong_match_rules_tv_path = lib_dir.join("config").join("mt_strong_match_rules_tv.json").to_str().unwrap().to_string();
config.strong_match_rules_movie_path = lib_dir.join("config").join("mt_strong_match_rules_movie.json").to_str().unwrap().to_string();
config.strong_match_regex_rules_path = lib_dir.join("config").join("mt_strong_match_regex_rules.json").to_str().unwrap().to_string();
config.strong_match_rules_movie_path = lib_dir
.join("config")
.join("mt_strong_match_rules_movie.json")
.to_str()
.unwrap()
.to_string();
config.strong_match_regex_rules_path = lib_dir
.join("config")
.join("mt_strong_match_regex_rules.json")
.to_str()
.unwrap()
.to_string();
config.strong_match_name_map_path = lib_dir.join("config").join("mt_strong_match_name_map.json").to_str().unwrap().to_string();
config.rename_style = Some(rename_style.clone());
config.metadata_skip_special = true;
Expand All @@ -244,7 +254,10 @@ fn init_config(config_dir: &Path) -> Result<(), SodaError> {

fn update_soda_config(local_soda_config_path: &std::path::PathBuf, remote_soda_config: &Value, config_dir: &std::path::Path) {
fs::write(local_soda_config_path, remote_soda_config.to_string()).unwrap();
reqwest::blocking::get("https://raw.githubusercontent.com/biezhihua/soda_cli/main/soda_config.bin").unwrap().copy_to(&mut fs::File::create(config_dir.join(remote_soda_config.get("bin").unwrap().as_str().unwrap())).unwrap()).unwrap();
reqwest::blocking::get("https://raw.githubusercontent.com/biezhihua/soda_cli/main/soda_config.bin")
.unwrap()
.copy_to(&mut fs::File::create(config_dir.join(remote_soda_config.get("bin").unwrap().as_str().unwrap())).unwrap())
.unwrap();
}

fn init_tracing(log_level: String, all_log: NonBlocking, metadata_log: NonBlocking) {
Expand All @@ -259,15 +272,27 @@ fn init_tracing(log_level: String, all_log: NonBlocking, metadata_log: NonBlocki
tracing_subscriber::registry()
.with(
// 收集INFO级别以上的soda_cli日志输出到控制台
tracing_subscriber::fmt::layer().with_timer(ChronoLocal::new("%Y-%m-%d %H:%M:%S".to_string())).with_filter(filter::LevelFilter::INFO).with_filter(filter::filter_fn(|metadata| metadata.target().starts_with("soda::info"))),
tracing_subscriber::fmt::layer()
.with_timer(ChronoLocal::new("%Y-%m-%d %H:%M:%S".to_string()))
.with_filter(filter::LevelFilter::INFO)
.with_filter(filter::filter_fn(|metadata| metadata.target().starts_with("soda::info"))),
)
.with(
// 收集DEBUG级别以上的日志到debug.log文件
tracing_subscriber::fmt::layer().with_timer(ChronoLocal::new("%Y-%m-%d %H:%M:%S".to_string())).with_writer(all_log).with_ansi(false).with_filter(filter),
tracing_subscriber::fmt::layer()
.with_timer(ChronoLocal::new("%Y-%m-%d %H:%M:%S".to_string()))
.with_writer(all_log)
.with_ansi(false)
.with_filter(filter),
)
.with(
// 收集INFO级别以上的日志到metadata_log文件
tracing_subscriber::fmt::layer().with_timer(ChronoLocal::new("%Y-%m-%d %H:%M:%S".to_string())).with_writer(metadata_log).with_ansi(false).with_filter(filter::LevelFilter::INFO).with_filter(filter::filter_fn(|metadata| metadata.target().starts_with("soda::metadata"))),
tracing_subscriber::fmt::layer()
.with_timer(ChronoLocal::new("%Y-%m-%d %H:%M:%S".to_string()))
.with_writer(metadata_log)
.with_ansi(false)
.with_filter(filter::LevelFilter::INFO)
.with_filter(filter::filter_fn(|metadata| metadata.target().starts_with("soda::metadata"))),
)
.init();
}
Expand Down

0 comments on commit 627776a

Please sign in to comment.