Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set RUST_LOG for aardvark and keep aardvark stderr open with debug log level #218

Merged
merged 2 commits into from
Feb 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/dns/aardvark.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::network::types;
use log::log_enabled;
use nix::sys::signal::{self, Signal};
use nix::unistd::Pid;
use std::collections::HashMap;
Expand All @@ -9,6 +10,7 @@ use std::io::prelude::*;
use std::io::Result;
use std::net::IpAddr;
use std::net::Ipv4Addr;
use std::os::unix::prelude::FromRawFd;
use std::path::Path;
use std::process::{Command, Stdio};

Expand Down Expand Up @@ -100,10 +102,17 @@ impl Aardvark {

log::debug!("start aardvark-dns: {:?}", aardvark_args);

let output = match log_enabled!(log::Level::Debug) {
true => Stdio::null(),
false => unsafe { Stdio::from_raw_fd(2) },
};

Command::new(&aardvark_args[0])
.args(&aardvark_args[1..])
.stdout(Stdio::null())
.stderr(Stdio::null())
.stderr(output)
// set RUST_LOG for aardvark
.env("RUST_LOG", log::max_level().as_str())
.spawn()?;

Ok(())
Expand Down