Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: katana runner log path option #2015

Merged
merged 3 commits into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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 @@
port: None,
program_name: None,
run_name: None,
log_path: None,
}
}
}
Expand Down Expand Up @@ -102,14 +105,18 @@

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

Check warning on line 114 in crates/katana/runner/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/katana/runner/src/lib.rs#L114

Added line #L114 was not covered by tests
} 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
Loading