aboutsummaryrefslogtreecommitdiff
path: root/src/k2v-client
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-05-18 00:07:54 +0200
committerAlex Auvolat <alex@adnab.me>2023-05-18 11:18:21 +0200
commit4420db731020bf7123f2bb80b076da581836f900 (patch)
tree103270ccca9d9a26c220fce528b9a3c397fb2703 /src/k2v-client
parent746b0090e4ad02e98b08aa1cfefd77a22d9490fe (diff)
downloadgarage-4420db731020bf7123f2bb80b076da581836f900.tar.gz
garage-4420db731020bf7123f2bb80b076da581836f900.zip
add tracing to k2v-client
Diffstat (limited to 'src/k2v-client')
-rw-r--r--src/k2v-client/Cargo.toml6
-rw-r--r--src/k2v-client/bin/k2v-cli.rs9
2 files changed, 13 insertions, 2 deletions
diff --git a/src/k2v-client/Cargo.toml b/src/k2v-client/Cargo.toml
index 4212a00a..79af5242 100644
--- a/src/k2v-client/Cargo.toml
+++ b/src/k2v-client/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "k2v-client"
-version = "0.0.2"
+version = "0.0.3"
authors = ["Trinity Pointard <trinity.pointard@gmail.com>", "Alex Auvolat <alex@adnab.me>"]
edition = "2018"
license = "AGPL-3.0"
@@ -24,10 +24,12 @@ tokio = { version = "1.0", default-features = false, features = ["rt", "rt-multi
# cli deps
clap = { version = "4.1", optional = true, features = ["derive", "env"] }
format_table = { workspace = true, optional = true }
+tracing = { version = "0.1", optional = true }
+tracing-subscriber = { version = "0.3", optional = true, features = ["env-filter"] }
[features]
-cli = ["clap", "tokio/fs", "tokio/io-std", "format_table"]
+cli = ["clap", "tokio/fs", "tokio/io-std", "tracing", "tracing-subscriber", "format_table"]
[lib]
path = "lib.rs"
diff --git a/src/k2v-client/bin/k2v-cli.rs b/src/k2v-client/bin/k2v-cli.rs
index 76388752..984b4192 100644
--- a/src/k2v-client/bin/k2v-cli.rs
+++ b/src/k2v-client/bin/k2v-cli.rs
@@ -397,6 +397,15 @@ impl Filter {
#[tokio::main]
async fn main() -> Result<(), Error> {
+ if std::env::var("RUST_LOG").is_err() {
+ std::env::set_var("RUST_LOG", "warn")
+ }
+
+ tracing_subscriber::fmt()
+ .with_writer(std::io::stderr)
+ .with_env_filter(tracing_subscriber::filter::EnvFilter::from_default_env())
+ .init();
+
let args = Args::parse();
let region = Region::Custom {