Skip to content

Commit

Permalink
feat: katana runner log path option (dojoengine#2015)
Browse files Browse the repository at this point in the history
* feat(katana-runner): add log path option

* fix: fmt
  • Loading branch information
EvolveArt authored May 29, 2024
1 parent 8cfb0ba commit 0ab7d21
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions crates/katana/runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ pub struct KatanaRunnerConfig {
pub block_time: Option<u64>,
/// The port to run the katana runner on, if None, a random free port is chosen.
pub port: Option<u16>,
/// The path where to log info, if None, logs are stored in a temp dir.
pub log_path: Option<PathBuf>,
}

impl Default for KatanaRunnerConfig {
Expand All @@ -56,6 +58,7 @@ impl Default for KatanaRunnerConfig {
port: None,
program_name: None,
run_name: None,
log_path: None,
}
}
}
Expand Down Expand Up @@ -102,14 +105,18 @@ impl KatanaRunner {

let stdout = child.stdout.take().context("failed to take subprocess stdout")?;

let log_dir = TempDir::new().unwrap();

let log_filename = PathBuf::from(format!(
"katana-{}.log",
config.run_name.clone().unwrap_or_else(|| port.to_string())
));

let log_file_path = log_dir.join(log_filename);
let log_file_path = if let Some(log_path) = config.log_path {
log_path
} else {
let log_dir = TempDir::new().unwrap();
log_dir.join(log_filename)
};

let log_file_path_sent = log_file_path.clone();

let (sender, receiver) = mpsc::channel();
Expand Down

0 comments on commit 0ab7d21

Please sign in to comment.