mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-28 02:18:50 +00:00
Currently, each use of `Session` creates its own `Runtime`. That is unnecessary because some platforms already have a tokio runtime running. Instead of creating another one, we simply ask the caller to provide us with a `Handle` to an existing tokio runtime. For Android and iOS we spawn a new single-threaded runtime to satisfy this new requirement.
37 lines
1.1 KiB
Rust
37 lines
1.1 KiB
Rust
use clap::Args;
|
|
use tracing_log::LogTracer;
|
|
use tracing_subscriber::{
|
|
fmt, prelude::__tracing_subscriber_SubscriberExt, EnvFilter, Layer, Registry,
|
|
};
|
|
use url::Url;
|
|
|
|
pub fn setup_global_subscriber<L>(additional_layer: L)
|
|
where
|
|
L: Layer<Registry> + Send + Sync,
|
|
{
|
|
let subscriber = Registry::default()
|
|
.with(additional_layer.with_filter(EnvFilter::from_default_env()))
|
|
.with(fmt::layer().with_filter(EnvFilter::from_default_env()));
|
|
tracing::subscriber::set_global_default(subscriber).expect("Could not set global default");
|
|
LogTracer::init().unwrap();
|
|
}
|
|
|
|
/// Arguments common to all Firezone CLI components.
|
|
#[derive(Args, Clone)]
|
|
pub struct CommonArgs {
|
|
#[arg(
|
|
short = 'u',
|
|
long,
|
|
hide = true,
|
|
env = "FIREZONE_API_URL",
|
|
default_value = "wss://api.firezone.dev"
|
|
)]
|
|
pub api_url: Url,
|
|
/// Token generated by the portal to authorize websocket connection.
|
|
#[arg(env = "FIREZONE_TOKEN")]
|
|
pub token: String,
|
|
/// Friendly name to display in the UI
|
|
#[arg(short = 'n', long, env = "FIREZONE_NAME")]
|
|
pub firezone_name: Option<String>,
|
|
}
|