Skip to content

Commit

Permalink
launch.json typo && clearer logger formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Zztrans committed Jul 27, 2024
1 parent 6e80ca8 commit 49f3d75
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion judge-core/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion judger/src/handler/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
1 change: 1 addition & 0 deletions judger/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
18 changes: 17 additions & 1 deletion judger/src/option.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::path::PathBuf;

use chrono::Local;
use std::io::Write;
use structopt::StructOpt;

#[derive(StructOpt, Debug, Clone)]
Expand Down Expand Up @@ -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("<unnamed>"),
record.line().unwrap(),
&record.args()
)
})
.init();
}
8 changes: 7 additions & 1 deletion judger/src/worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 49f3d75

Please sign in to comment.