make server logging show messages in the frontend

now you can use the log crate and get messages in the frontend.
This commit is contained in:
Brandon W Maister 2024-07-31 10:43:02 -04:00
parent 8135f163f2
commit 18da61ed32
6 changed files with 91 additions and 25 deletions

View file

@ -82,6 +82,10 @@ async fn server_main<
}
pub async fn run_server() {
env_logger::Builder::from_env(
env_logger::Env::new().filter_or("FWD_LOG", "warn"),
)
.init();
let stdin = tokio::io::stdin();
let stdout = tokio::io::stdout();
if let Err(e) = server_main(stdin, stdout).await {

View file

@ -1,5 +1,7 @@
use anyhow::Result;
use log::{error, warn};
#[cfg_attr(not(target_os = "linux"), allow(unused))]
use log::error;
use log::warn;
use std::collections::HashMap;
use crate::message::PortDesc;
@ -8,9 +10,10 @@ use crate::message::PortDesc;
mod procfs;
pub async fn get_entries() -> Result<Vec<PortDesc>> {
#[allow(unused)]
#[cfg_attr(not(target_os = "linux"), allow(unused_mut))]
let mut attempts = 0;
#[cfg_attr(not(target_os = "linux"), allow(unused_mut))]
let mut result: HashMap<u16, PortDesc> = HashMap::new();
#[cfg(target_os = "linux")]