diff --git a/Cargo.lock b/Cargo.lock index 4aa76be6f..31b96c45c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1970,6 +1970,7 @@ dependencies = [ "forge-client", "forgejo-api", "hive-agent-sock", + "hive-log", "hive-sock-client", "reqwest", "serde", @@ -1977,7 +1978,6 @@ dependencies = [ "time", "tokio", "tracing", - "tracing-subscriber", "url", ] @@ -2094,6 +2094,7 @@ name = "hive-priv" version = "0.1.0" dependencies = [ "anyhow", + "hive-log", "hive-priv-sock", "hive-types", "libc", @@ -2102,7 +2103,6 @@ dependencies = [ "serde_json", "tokio", "tracing", - "tracing-subscriber", ] [[package]] @@ -5273,6 +5273,7 @@ version = "0.1.0" dependencies = [ "anyhow", "axum", + "hive-log", "hive-types", "reqwest", "rustix", @@ -5283,7 +5284,6 @@ dependencies = [ "swarm-secret-client", "tokio", "tracing", - "tracing-subscriber", ] [[package]] @@ -5442,12 +5442,12 @@ dependencies = [ "axum", "clap", "futures-util", + "hive-log", "sha2 0.11.1", "swarm-agent-verify", "swarm-secret-client", "tokio", "tracing", - "tracing-subscriber", ] [[package]] @@ -5467,11 +5467,11 @@ version = "0.1.0" dependencies = [ "anyhow", "clap", + "hive-log", "swarm-matrix-client", "swarm-secret-client", "tokio", "tracing", - "tracing-subscriber", ] [[package]] @@ -5495,13 +5495,13 @@ dependencies = [ "axum", "chrono", "clap", + "hive-log", "mockall", "serde", "subtle", "swarm-secret-client", "tokio", "tracing", - "tracing-subscriber", ] [[package]] @@ -5514,6 +5514,7 @@ dependencies = [ "clap", "data-encoding", "futures-util", + "hive-log", "nats-jwt", "nkeys", "reqwest", @@ -5526,7 +5527,6 @@ dependencies = [ "swarm-wire", "tokio", "tracing", - "tracing-subscriber", ] [[package]] diff --git a/hive-forge-notify/Cargo.toml b/hive-forge-notify/Cargo.toml index a4e09248c..eb1663256 100644 --- a/hive-forge-notify/Cargo.toml +++ b/hive-forge-notify/Cargo.toml @@ -19,6 +19,7 @@ backon.workspace = true forgejo-api.workspace = true hive-agent-sock.workspace = true forge-client.workspace = true +hive-log.workspace = true hive-sock-client.workspace = true reqwest.workspace = true serde.workspace = true @@ -26,7 +27,6 @@ serde_json.workspace = true time.workspace = true tokio.workspace = true tracing.workspace = true -tracing-subscriber.workspace = true url.workspace = true [dev-dependencies] diff --git a/hive-forge-notify/src/lib.rs b/hive-forge-notify/src/lib.rs index 168bdc17c..7fb95d813 100644 --- a/hive-forge-notify/src/lib.rs +++ b/hive-forge-notify/src/lib.rs @@ -50,16 +50,7 @@ pub fn agent_socket() -> std::path::PathBuf { /// Install the tracing subscriber both binaries use: `RUST_LOG` when set, /// `info` otherwise. pub fn init_tracing() { - tracing_subscriber::fmt() - .with_env_filter( - tracing_subscriber::EnvFilter::try_from_env("RUST_LOG") - .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")), - ) - // This is a systemd-managed daemon — stdout always goes to journald, - // never a human terminal, and journald doesn't strip ANSI escapes: - // they land in victorialogs as raw byte-array spam otherwise. - .with_ansi(false) - .init(); + hive_log::init(); } /// Read `HYPERHIVE_STATE_DIR`, the directory holding the agent's diff --git a/hive-priv/Cargo.toml b/hive-priv/Cargo.toml index 618038613..44bace4f3 100644 --- a/hive-priv/Cargo.toml +++ b/hive-priv/Cargo.toml @@ -9,6 +9,7 @@ workspace = true [dependencies] anyhow.workspace = true +hive-log.workspace = true hive-priv-sock.workspace = true hive-types.workspace = true libc.workspace = true @@ -16,7 +17,6 @@ rustix.workspace = true serde_json.workspace = true tokio.workspace = true tracing.workspace = true -tracing-subscriber.workspace = true [dev-dependencies] mockall.workspace = true diff --git a/hive-priv/src/main.rs b/hive-priv/src/main.rs index 4eca3d278..1fc56f5eb 100644 --- a/hive-priv/src/main.rs +++ b/hive-priv/src/main.rs @@ -67,15 +67,7 @@ async fn main() -> Result<()> { std::process::exit(code); } - tracing_subscriber::fmt() - .with_env_filter( - tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| "info".into()), - ) - // This is a systemd-managed daemon — stdout always goes to journald, - // never a human terminal, and journald doesn't strip ANSI escapes: - // they land in victorialogs as raw byte-array spam otherwise. - .with_ansi(false) - .init(); + hive_log::init(); container_config::init_exe()?; let listener = socket_listener()?; diff --git a/swarm-authelia-bridge/Cargo.toml b/swarm-authelia-bridge/Cargo.toml index 226fc8ade..95150b3e7 100644 --- a/swarm-authelia-bridge/Cargo.toml +++ b/swarm-authelia-bridge/Cargo.toml @@ -9,6 +9,7 @@ name = "swarm-authelia-bridge" path = "src/main.rs" [dependencies] +hive-log.workspace = true hive-types.workspace = true anyhow.workspace = true axum.workspace = true @@ -23,7 +24,6 @@ swarm-authelia-bridge-sock.workspace = true swarm-secret-client.workspace = true tokio.workspace = true tracing.workspace = true -tracing-subscriber.workspace = true [lints] workspace = true diff --git a/swarm-authelia-bridge/src/main.rs b/swarm-authelia-bridge/src/main.rs index f748d7781..dbdec29d4 100644 --- a/swarm-authelia-bridge/src/main.rs +++ b/swarm-authelia-bridge/src/main.rs @@ -107,15 +107,7 @@ struct AppState { #[tokio::main] async fn main() -> Result<()> { let stop = swarm_secret_client::shutdown_signal(); - tracing_subscriber::fmt() - .with_env_filter( - tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| "info".into()), - ) - // This is a systemd-managed daemon — stdout always goes to journald, - // never a human terminal, and journald doesn't strip ANSI escapes: - // they land in victorialogs as raw byte-array spam otherwise. - .with_ansi(false) - .init(); + hive_log::init(); let health = swarm_secret_client::health::Health::from_env( "SWARM_AUTHELIA_BRIDGE_HEALTH_ADDR", diff --git a/swarm-logs-auth/Cargo.toml b/swarm-logs-auth/Cargo.toml index ff5079ffc..a7729f9db 100644 --- a/swarm-logs-auth/Cargo.toml +++ b/swarm-logs-auth/Cargo.toml @@ -11,13 +11,13 @@ path = "src/main.rs" anyhow.workspace = true axum.workspace = true clap.workspace = true +hive-log.workspace = true # The verdict cache's key: a digest of the bearer, never the bearer. sha2.workspace = true swarm-agent-verify.workspace = true swarm-secret-client.workspace = true tokio.workspace = true tracing.workspace = true -tracing-subscriber.workspace = true [lints] workspace = true diff --git a/swarm-logs-auth/src/main.rs b/swarm-logs-auth/src/main.rs index 6cebbb6de..dc59d5a16 100644 --- a/swarm-logs-auth/src/main.rs +++ b/swarm-logs-auth/src/main.rs @@ -201,14 +201,7 @@ async fn handle( async fn main() -> anyhow::Result<()> { let stop = swarm_secret_client::shutdown_signal(); swarm_secret_client::install_crypto_provider(); - tracing_subscriber::fmt() - .with_env_filter( - tracing_subscriber::EnvFilter::try_from_default_env() - .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")), - ) - // stdout is journald, which keeps ANSI escapes as raw bytes. - .with_ansi(false) - .init(); + hive_log::init(); let args = Args::parse(); let health = swarm_secret_client::health::Health::start( swarm_secret_client::health::STALE_AFTER, diff --git a/swarm-matrix-ctl/Cargo.toml b/swarm-matrix-ctl/Cargo.toml index 65bab94be..d1cee1f5a 100644 --- a/swarm-matrix-ctl/Cargo.toml +++ b/swarm-matrix-ctl/Cargo.toml @@ -14,6 +14,7 @@ anyhow.workspace = true # next thing that has to run in the matrix container is a subcommand here, not a # new crate. clap.workspace = true +hive-log.workspace = true # The token generator, shared with `swarm-controller`. swarm-matrix-client.workspace = true # The agreement this binary is one end of: where the credential lives, what the @@ -21,7 +22,6 @@ swarm-matrix-client.workspace = true swarm-secret-client.workspace = true tokio.workspace = true tracing.workspace = true -tracing-subscriber.workspace = true [lints] workspace = true diff --git a/swarm-matrix-ctl/src/main.rs b/swarm-matrix-ctl/src/main.rs index 59edd9daf..ee21b5e7d 100644 --- a/swarm-matrix-ctl/src/main.rs +++ b/swarm-matrix-ctl/src/main.rs @@ -51,12 +51,7 @@ enum Appservice { #[tokio::main] async fn main() -> Result<()> { - tracing_subscriber::fmt() - .with_env_filter( - tracing_subscriber::EnvFilter::try_from_default_env() - .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")), - ) - .init(); + hive_log::init(); match Cli::parse().command { Command::Appservice(Appservice::Render) => appservice::render().await, diff --git a/swarm-metrics-auth/Cargo.toml b/swarm-metrics-auth/Cargo.toml index 1e5a52643..635635f9f 100644 --- a/swarm-metrics-auth/Cargo.toml +++ b/swarm-metrics-auth/Cargo.toml @@ -13,13 +13,13 @@ axum.workspace = true # The read time in the fallback log line. chrono.workspace = true clap.workspace = true +hive-log.workspace = true serde.workspace = true # Comparing the presented bearer with the stored one. subtle.workspace = true swarm-secret-client.workspace = true tokio.workspace = true tracing.workspace = true -tracing-subscriber.workspace = true [lints] workspace = true diff --git a/swarm-metrics-auth/src/main.rs b/swarm-metrics-auth/src/main.rs index 9a52f9f32..0e63d24e5 100644 --- a/swarm-metrics-auth/src/main.rs +++ b/swarm-metrics-auth/src/main.rs @@ -288,14 +288,7 @@ async fn handle(State(responder): State>>, headers: HeaderM async fn main() -> anyhow::Result<()> { let stop = swarm_secret_client::shutdown_signal(); swarm_secret_client::install_crypto_provider(); - tracing_subscriber::fmt() - .with_env_filter( - tracing_subscriber::EnvFilter::try_from_default_env() - .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")), - ) - // stdout is journald, which keeps ANSI escapes as raw bytes. - .with_ansi(false) - .init(); + hive_log::init(); let args = Args::parse(); let health = swarm_secret_client::health::Health::start( swarm_secret_client::health::STALE_AFTER, diff --git a/swarm-nats-auth/Cargo.toml b/swarm-nats-auth/Cargo.toml index d5347a239..88ad082dc 100644 --- a/swarm-nats-auth/Cargo.toml +++ b/swarm-nats-auth/Cargo.toml @@ -16,6 +16,7 @@ clap.workspace = true data-encoding.workspace = true # StreamExt::next on the subscription: async-nats returns a Stream. futures-util.workspace = true +hive-log.workspace = true # `xkeys` for the callout xkey: opening sealed requests and sealing replies. nkeys = { workspace = true, features = ["xkeys"] } reqwest.workspace = true @@ -36,7 +37,6 @@ swarm-agent-verify.workspace = true swarm-wire.workspace = true tokio.workspace = true tracing.workspace = true -tracing-subscriber.workspace = true [dev-dependencies] # A loopback stand-in `IdP` for `oidc_secret`'s test of a non-2xx diff --git a/swarm-nats-auth/src/main.rs b/swarm-nats-auth/src/main.rs index 68030379c..987911873 100644 --- a/swarm-nats-auth/src/main.rs +++ b/swarm-nats-auth/src/main.rs @@ -189,16 +189,7 @@ struct Args { async fn main() -> anyhow::Result<()> { let stop = swarm_secret_client::shutdown_signal(); swarm_secret_client::install_crypto_provider(); - tracing_subscriber::fmt() - .with_env_filter( - tracing_subscriber::EnvFilter::try_from_default_env() - .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")), - ) - // This is a systemd-managed daemon — stdout always goes to journald, - // never a human terminal, and journald doesn't strip ANSI escapes: - // they land in victorialogs as raw byte-array spam otherwise. - .with_ansi(false) - .init(); + hive_log::init(); let cli = Cli::parse(); match (cli.command, cli.responder) { (