fix(logging): Restored RUST_LOG env functionality

This commit is contained in:
quexeky
2025-01-25 14:31:19 +11:00
parent 76bae3d926
commit 7a0cf4fbb6

View File

@ -48,7 +48,9 @@ use remote::commands::{
}; };
use remote::requests::make_request; use remote::requests::make_request;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::env;
use std::path::Path; use std::path::Path;
use std::str::FromStr;
use std::sync::Arc; use std::sync::Arc;
use std::{ use std::{
collections::HashMap, collections::HashMap,
@ -109,6 +111,8 @@ fn setup(handle: AppHandle) -> AppState<'static> {
))) )))
.build(); .build();
let log_level = env::var("RUST_LOG").unwrap_or(String::from("Info"));
let config = Config::builder() let config = Config::builder()
.appenders(vec![ .appenders(vec![
Appender::builder().build("logfile", Box::new(logfile)), Appender::builder().build("logfile", Box::new(logfile)),
@ -117,7 +121,7 @@ fn setup(handle: AppHandle) -> AppState<'static> {
.build( .build(
Root::builder() Root::builder()
.appenders(vec!["logfile", "console"]) .appenders(vec!["logfile", "console"])
.build(LevelFilter::Info), .build(LevelFilter::from_str(&log_level).expect("Invalid log level")),
) )
.unwrap(); .unwrap();