Change default logs directory to ~/.attractor/logs

Logs from `attractor run` were cluttering project directories. Now defaults
to ~/.attractor/logs/attractor-run-TIMESTAMP instead of ./attractor-run-TIMESTAMP.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-02-24 09:58:20 -05:00
parent 3d8e17aedf
commit c9b7bee2da
4 changed files with 45 additions and 3 deletions

1
.gitignore vendored
View file

@ -1,3 +1,2 @@
target
.env
attractor-run-*

39
Cargo.lock generated
View file

@ -167,6 +167,7 @@ dependencies = [
"chrono",
"clap",
"dialoguer",
"dirs",
"dotenvy",
"futures",
"http-body-util",
@ -544,6 +545,27 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
[[package]]
name = "dirs"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"
dependencies = [
"dirs-sys",
]
[[package]]
name = "dirs-sys"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
dependencies = [
"libc",
"option-ext",
"redox_users",
"windows-sys 0.61.2",
]
[[package]]
name = "displaydoc"
version = "0.2.5"
@ -1525,6 +1547,12 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe"
[[package]]
name = "option-ext"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
[[package]]
name = "outref"
version = "0.5.2"
@ -1798,6 +1826,17 @@ dependencies = [
"bitflags",
]
[[package]]
name = "redox_users"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac"
dependencies = [
"getrandom 0.2.17",
"libredox",
"thiserror 2.0.18",
]
[[package]]
name = "ref-cast"
version = "1.0.25"

View file

@ -37,6 +37,7 @@ async-trait.workspace = true
futures.workspace = true
chrono = { workspace = true, features = ["serde"] }
nom = "7"
dirs = "6"
dialoguer.workspace = true
axum = { version = "0.8", optional = true }
tower = { version = "0.5", optional = true }

View file

@ -1,4 +1,3 @@
use std::path::PathBuf;
use std::sync::{Arc, Mutex};
use std::time::Instant;
@ -60,7 +59,11 @@ pub async fn run_command(args: RunArgs, styles: &'static Styles) -> anyhow::Resu
// 2. Create logs directory
let logs_dir = args.logs_dir.unwrap_or_else(|| {
PathBuf::from(format!(
let base = dirs::home_dir()
.expect("could not determine home directory")
.join(".attractor")
.join("logs");
base.join(format!(
"attractor-run-{}",
Local::now().format("%Y%m%d-%H%M%S")
))