diff --git a/qemu-rdp/Cargo.toml b/qemu-rdp/Cargo.toml index 4c3852d..4266ee5 100644 --- a/qemu-rdp/Cargo.toml +++ b/qemu-rdp/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] qemu-display = { path = "../qemu-display" } -tracing = "0.1.37" +tracing.workspace = true tracing-subscriber = { version = "0.3.16", features = ["env-filter"] } keycodemap = { path = "../keycodemap" } bytes = "1.4" diff --git a/qemu-rdp/src/args.rs b/qemu-rdp/src/args.rs index 4e82f58..da73e45 100644 --- a/qemu-rdp/src/args.rs +++ b/qemu-rdp/src/args.rs @@ -1,5 +1,5 @@ use clap::clap_derive::ValueEnum; -use clap::{crate_name, Parser}; +use clap::Parser; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] pub enum SecurityProtocol { @@ -43,9 +43,6 @@ pub struct ServerArgs { #[derive(Parser, Debug)] pub struct Args { - #[clap(short, long, value_parser, default_value_t = format!("{}.log", crate_name!()))] - pub log_file: String, - #[clap(flatten)] pub server: ServerArgs, diff --git a/qemu-rdp/src/main.rs b/qemu-rdp/src/main.rs index 8d3b054..7dfd6d6 100644 --- a/qemu-rdp/src/main.rs +++ b/qemu-rdp/src/main.rs @@ -9,7 +9,7 @@ mod util; async fn main() -> Result<(), anyhow::Error> { let mut args = args::parse(); - setup_logging(args.log_file.as_str()).context("unable to initialize logging")?; + setup_logging().context("unable to initialize logging")?; let dbus = match args.dbus_address.take() { None => zbus::Connection::session().await, @@ -26,27 +26,16 @@ async fn main() -> Result<(), anyhow::Error> { Ok(()) } -fn setup_logging(log_file: &str) -> anyhow::Result<()> { - use std::fs::OpenOptions; - +fn setup_logging() -> anyhow::Result<()> { use tracing::metadata::LevelFilter; use tracing_subscriber::prelude::*; use tracing_subscriber::EnvFilter; - let file = OpenOptions::new() - .create(true) - .append(true) - .open(log_file) - .with_context(|| format!("couldn’t open {log_file}"))?; - - let fmt_layer = tracing_subscriber::fmt::layer() - .compact() - .with_ansi(false) - .with_writer(file); + let fmt_layer = tracing_subscriber::fmt::layer().compact(); let env_filter = EnvFilter::builder() .with_default_directive(LevelFilter::WARN.into()) - .with_env_var("QEMURDP_LOG_LEVEL") + .with_env_var("QEMURDP_LOG") .from_env_lossy(); tracing_subscriber::registry()