Skip to content

Commit

Permalink
feat: use cfg_if
Browse files Browse the repository at this point in the history
  • Loading branch information
pk5ls20 committed Feb 5, 2025
1 parent 9fd61fc commit 2736e4f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ tracing.workspace = true
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
console-subscriber = { version = "0.4.1", optional = true }
tokio.workspace = true
cfg-if = "1.0.0"

[features]
default = []
Expand Down
11 changes: 5 additions & 6 deletions examples/multi-login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::io::Write;

#[tokio::main]
async fn main() {
#[cfg(feature = "tokio-tracing")]
{
cfg_if::cfg_if! {
if #[cfg(feature = "tokio-tracing")] {
use tracing_subscriber::prelude::*;
let console_layer = console_subscriber::spawn();
tracing_subscriber::registry()
Expand All @@ -15,12 +15,11 @@ async fn main() {
)
.init();
tracing::info!("tokio-tracing initialized.");
}
#[cfg(not(feature = "tokio-tracing"))]
{
tracing_subscriber::fmt()
} else {
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::new("info"))
.init();
}
}
let config = ClientConfig::default();
let device = DeviceInfo::load("device.json").unwrap_or_else(|_| {
Expand Down

0 comments on commit 2736e4f

Please sign in to comment.