diff --git a/.vscode/launch.json b/.vscode/launch.json index d055f20..419be48 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -32,9 +32,9 @@ "program": "${workspaceFolder}/target/debug/judger", "args": [ "judge", - "--problem-slug", "hello_world", + "--problem-slug", "hello-world", "--language", "cpp", - "--src-path", "${workspaceFolder}/judger/workdirs/development/problem-package/hello_world/ans.cpp", + "--src-path", "${workspaceFolder}/judger/workdirs/development/problem-package/hello-world/ans.cpp", ], "stopAtEntry": false, "cwd": "${workspaceFolder}/judger/workdirs/development", diff --git a/judge-core/src/compiler.rs b/judge-core/src/compiler.rs index 4489e9a..ebfdf1c 100644 --- a/judge-core/src/compiler.rs +++ b/judge-core/src/compiler.rs @@ -170,7 +170,7 @@ impl Compiler { .output()?; if output.status.success() { let compile_output = String::from_utf8_lossy(&output.stdout).to_string(); - log::info!("Compile output: {}", compile_output); + log::debug!("Compile output: {}", compile_output); Ok(compile_output) } else { let error_output = String::from_utf8_lossy(&output.stderr).to_string(); diff --git a/judger/src/handler/state.rs b/judger/src/handler/state.rs index 8287192..1506628 100644 --- a/judger/src/handler/state.rs +++ b/judger/src/handler/state.rs @@ -19,7 +19,7 @@ pub fn set_busy() -> anyhow::Result<()> { let mut state = STATE .try_write() .map_err(|e| anyhow::anyhow!("Failed to lock state: {:?}", e))?; - log::info!("State: {:?}", *state); + log::info!("Current State: {:?}", *state); if *state == State::Busy { anyhow::bail!("Judge server is busy") } diff --git a/judger/src/main.rs b/judger/src/main.rs index c6db332..cb10836 100644 --- a/judger/src/main.rs +++ b/judger/src/main.rs @@ -142,6 +142,7 @@ async fn judge( let mut verdict = JudgeVerdict::Accepted; for idx in 0..judge.testdata_configs.len() { + log::debug!("Judge {}, Testcase {}!", problem_slug, idx); let judge_config = JudgeConfig { test_data: judge.testdata_configs[idx].clone(), program: judge.program_config.clone(), diff --git a/judger/src/option.rs b/judger/src/option.rs index 9231141..c65c342 100644 --- a/judger/src/option.rs +++ b/judger/src/option.rs @@ -1,5 +1,7 @@ use std::path::PathBuf; +use chrono::Local; +use std::io::Write; use structopt::StructOpt; #[derive(StructOpt, Debug, Clone)] @@ -77,5 +79,19 @@ pub fn load_option() -> JudgerOpt { } fn setup_logger() { - env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("debug")).init(); + let env = env_logger::Env::default().default_filter_or("debug"); + env_logger::Builder::from_env(env) + .format(|buf, record| { + writeln!( + buf, + "{} {:5} [{}:{}] {}", + Local::now().format("%Y-%m-%d %H:%M:%S"), + record.level(), + record.file().unwrap(), + // record.module_path().unwrap_or(""), + record.line().unwrap(), + &record.args() + ) + }) + .init(); } diff --git a/judger/src/worker/mod.rs b/judger/src/worker/mod.rs index 099310c..772bdcf 100644 --- a/judger/src/worker/mod.rs +++ b/judger/src/worker/mod.rs @@ -101,6 +101,12 @@ impl JudgeWorker { let mut verdict = JudgeVerdict::Accepted; for idx in 0..judge.testdata_configs.len() { + log::debug!( + "Judge {}, {}, Testcase {}!", + task.redis_stream_id, + task.problem_slug, + idx + ); let judge_config = JudgeConfig { test_data: judge.testdata_configs[idx].clone(), program: judge.program_config.clone(), @@ -188,7 +194,7 @@ impl JudgeWorker { src_language: language, src_path: runtime_path.clone().join(&src_file_name), })?; - log::debug!("Builder created: {:?}", builder); + log::info!("Builder created success: {:?}", builder); Ok(builder) }