Skip to content

Commit

Permalink
refactor: use env_logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Mufanc committed Feb 7, 2024
1 parent 15c2151 commit b0e8c0c
Show file tree
Hide file tree
Showing 5 changed files with 253 additions and 31 deletions.
219 changes: 207 additions & 12 deletions daemon/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ path = "src/daemon.rs"
[dependencies]
anyhow = "1.0.75"
ctor = "0.2.5"
env_logger = "0.11"
goblin = "0.7.1"
log = "0.4"
nix = { version = "0.27.1", features = ["socket", "process", "signal"] }
once_cell = "1.19.0"
tokio = { version = "1", features = ["full"] }
Expand Down
7 changes: 3 additions & 4 deletions daemon/src/configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ use std::env;
use nix::unistd::getpid;
use crate::configs::Operation::OpenLink;

const DAEMON_ADDRESS_ENV: &str = "QWRAPPER_DAEMON";
const DAEMON_ADDRESS_PREFIX: &str = "qwrapper-daemon-";
pub const DAEMON_ADDRESS_ENV: &str = "QWRAPPER_DAEMON";
pub const DAEMON_ADDRESS_PREFIX: &str = "qwrapper-daemon-";


pub fn server_address() -> String {
if let Ok(addr) = env::var(DAEMON_ADDRESS_ENV) {
addr
} else {
env::set_var(DAEMON_ADDRESS_ENV, format!("{}{}", DAEMON_ADDRESS_PREFIX, getpid()));
server_address()
format!("{}{}", DAEMON_ADDRESS_PREFIX, getpid())
}
}

Expand Down
Loading

0 comments on commit b0e8c0c

Please sign in to comment.