async logger holder

This commit is contained in:
rustdesk 2022-04-21 21:51:53 +08:00
parent ccffa14450
commit 1e120eef18
3 changed files with 18 additions and 16 deletions

4
Cargo.lock generated
View File

@ -4148,9 +4148,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]] [[package]]
name = "uuid" name = "uuid"
version = "0.8.2" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" checksum = "8cfcd319456c4d6ea10087ed423473267e1a071f3bc0aa89f80d60997843c6f0"
dependencies = [ dependencies = [
"getrandom", "getrandom",
] ]

View File

@ -41,7 +41,7 @@ rubato = { version = "0.12", optional = true }
samplerate = { version = "0.2", optional = true } samplerate = { version = "0.2", optional = true }
async-trait = "0.1" async-trait = "0.1"
crc32fast = "1.3" crc32fast = "1.3"
uuid = { version = "0.8", features = ["v4"] } uuid = { version = "1.0.0", features = ["v4"] }
clap = "3.0" clap = "3.0"
rpassword = "6.0" rpassword = "6.0"
base64 = "0.13" base64 = "0.13"

View File

@ -16,6 +16,8 @@ fn main() {
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli")))] #[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli")))]
fn main() { fn main() {
// https://docs.rs/flexi_logger/latest/flexi_logger/error_info/index.html#write
let mut _async_logger_holder: Option<flexi_logger::LoggerHandle> = None;
let mut args = Vec::new(); let mut args = Vec::new();
let mut i = 0; let mut i = 0;
for arg in std::env::args() { for arg in std::env::args() {
@ -43,19 +45,19 @@ fn main() {
} }
} }
use flexi_logger::*; use flexi_logger::*;
Logger::try_with_env_or_str("debug") if let Ok(x) = Logger::try_with_env_or_str("debug") {
.map(|x| { _async_logger_holder = x
x.log_to_file(FileSpec::default().directory(path)) .log_to_file(FileSpec::default().directory(path))
.format(opt_format) .write_mode(WriteMode::Async)
.rotate( .format(opt_format)
Criterion::Age(Age::Day), .rotate(
Naming::Timestamps, Criterion::Age(Age::Day),
Cleanup::KeepLogFiles(6), Naming::Timestamps,
) Cleanup::KeepLogFiles(6),
.start() )
.ok(); .start()
}) .ok();
.ok(); }
} }
if args.is_empty() { if args.is_empty() {
std::thread::spawn(move || start_server(false, false)); std::thread::spawn(move || start_server(false, false));