qemu-rdp: simplify logging

Drop the --log-file argument, simply log to std.

Adjust environment name to follow IRONRDP_LOG style.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2024-04-10 12:59:48 +04:00
parent 726c893298
commit 187f680599
3 changed files with 6 additions and 20 deletions

View File

@ -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"

View File

@ -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,

View File

@ -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!("couldnt 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()