mirror of
https://gitlab.com/marcandre.lureau/qemu-display.git
synced 2024-12-22 13:45:18 +00:00
qemu-rdp: add -l option for logging
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
1e2cf6472a
commit
dfa9446d43
@ -8,6 +8,8 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
qemu-display = { path = "../qemu-display" }
|
||||
tracing = "0.1.37"
|
||||
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
|
||||
keycodemap = { path = "../keycodemap" }
|
||||
bytes = "1.4"
|
||||
rustls = { version = "0.21" }
|
||||
@ -15,6 +17,6 @@ rustls-pemfile = "1.0"
|
||||
tokio = { version = "1.28", features = ["full"] }
|
||||
tokio-rustls = "0.24"
|
||||
anyhow = "1.0"
|
||||
clap = { version = "3.2", features = ["derive"] }
|
||||
clap = { version = "4.2", features = ["derive", "cargo"] }
|
||||
async-trait = "0.1"
|
||||
ironrdp = { git = "https://github.com/Devolutions/IronRDP", features = ["server"] }
|
||||
|
@ -1,5 +1,5 @@
|
||||
use clap::clap_derive::ValueEnum;
|
||||
use clap::Parser;
|
||||
use clap::{crate_name, Parser};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
|
||||
pub enum SecurityProtocol {
|
||||
@ -43,6 +43,9 @@ 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,
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
use anyhow::Context;
|
||||
use qemu_display::zbus;
|
||||
|
||||
mod args;
|
||||
@ -7,6 +8,8 @@ mod server;
|
||||
async fn main() -> Result<(), anyhow::Error> {
|
||||
let mut args = args::parse();
|
||||
|
||||
setup_logging(args.log_file.as_str()).context("unable to initialize logging")?;
|
||||
|
||||
let dbus = match args.dbus_address.take() {
|
||||
None => zbus::Connection::session().await,
|
||||
Some(addr) => {
|
||||
@ -21,3 +24,35 @@ async fn main() -> Result<(), anyhow::Error> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn setup_logging(log_file: &str) -> anyhow::Result<()> {
|
||||
use std::fs::OpenOptions;
|
||||
|
||||
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 env_filter = EnvFilter::builder()
|
||||
.with_default_directive(LevelFilter::WARN.into())
|
||||
.with_env_var("QEMURDP_LOG_LEVEL")
|
||||
.from_env_lossy();
|
||||
|
||||
tracing_subscriber::registry()
|
||||
.with(fmt_layer)
|
||||
.with(env_filter)
|
||||
.try_init()
|
||||
.context("failed to set tracing global subscriber")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user