-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
3 changed files
with
30 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "quincy" | ||
version = "0.9.1" | ||
version = "0.9.2" | ||
authors = ["Jakub Kubík <[email protected]>"] | ||
license = "MIT" | ||
description = "QUIC-based VPN" | ||
|
@@ -84,6 +84,11 @@ once_cell = "^1.17" | |
[target.'cfg(not(target_env = "msvc"))'.dependencies] | ||
jemallocator = "0.5" | ||
|
||
# Windows formatting | ||
[target.'cfg(windows)'.dependencies] | ||
tracing-subscriber = { version = "^0.3.17", features = ["env-filter", "ansi"] } | ||
nu-ansi-term = "^0.50.0" | ||
|
||
[dev-dependencies] | ||
rstest = "^0.18.0" | ||
tracing-test = { version = "^0.2.4", features = ["no-env-filter"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
use tracing::Subscriber; | ||
use tracing_subscriber::layer::SubscriberExt; | ||
use tracing_subscriber::fmt::SubscriberBuilder; | ||
use tracing_subscriber::EnvFilter; | ||
|
||
/// Returns a new `tracing` subscriber with the specified log level. | ||
/// | ||
/// ### Arguments | ||
/// - `log_level` - the log level to use | ||
pub fn log_subscriber(log_level: &str) -> impl Subscriber { | ||
let registry = tracing_subscriber::Registry::default(); | ||
let fmt_layer = tracing_subscriber::fmt::Layer::new(); | ||
// Enable ANSI color support on Windows. | ||
#[cfg(windows)] | ||
let with_ansi = nu_ansi_term::enable_ansi_support().is_ok(); | ||
|
||
#[cfg(not(windows))] | ||
let with_ansi = false; | ||
|
||
let filter_layer = EnvFilter::try_new(log_level).unwrap(); | ||
|
||
registry.with(filter_layer).with(fmt_layer) | ||
SubscriberBuilder::default() | ||
.with_env_filter(filter_layer) | ||
.with_ansi(with_ansi) | ||
.finish() | ||
} |