Skip to content

Commit

Permalink
Switch logging to use tracing instead of log
Browse files Browse the repository at this point in the history
Tracing has support for intervals and a great os_log integration.
  • Loading branch information
JettChenT committed Sep 2, 2023
1 parent 60cfd95 commit e643d9d
Show file tree
Hide file tree
Showing 14 changed files with 297 additions and 8 deletions.
181 changes: 180 additions & 1 deletion Cargo.lock

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

8 changes: 7 additions & 1 deletion burrow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ edition = "2021"
crate-type = ["lib", "staticlib"]

[dependencies]
tokio = { version = "1.21", features = ["rt", "sync", "io-util", "macros"] }
anyhow = "1.0"
tokio = { version = "1.21", features = ["rt", "macros", "sync", "io-util"] }
tun = { version = "0.1", path = "../tun", features = ["serde"] }
clap = { version = "4.3.2", features = ["derive"] }
tracing = "0.1"
tracing-log = "0.1"
tracing-journald = "0.3"
tracing-oslog = {git = "https://github.com/Stormshield-robinc/tracing-oslog"}
tracing-subscriber = "0.3"
env_logger = "0.10"
log = "0.4"
serde = { version = "1", features = ["derive"] }
Expand Down
5 changes: 5 additions & 0 deletions burrow/src/ensureroot.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use tracing::instrument;

// Check capabilities on Linux
#[cfg(target_os = "linux")]
#[instrument]
pub fn ensure_root() {
use caps::{has_cap, CapSet, Capability};

Expand All @@ -19,6 +22,7 @@ pub fn ensure_root() {

// Check for root user on macOS
#[cfg(target_vendor = "apple")]
#[instrument]
pub fn ensure_root() {
use nix::unistd::Uid;

Expand All @@ -30,6 +34,7 @@ pub fn ensure_root() {
}

#[cfg(target_family = "windows")]
#[instrument]
pub fn ensure_root() {
todo!()
}
1 change: 1 addition & 0 deletions burrow/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![deny(missing_debug_implementations)]
pub mod ensureroot;

#[cfg(any(target_os = "linux", target_vendor = "apple"))]
Expand Down
Loading

0 comments on commit e643d9d

Please sign in to comment.