Skip to content

Commit e3b0b30

Browse files
committed
prototype with new proposed hooks
1 parent f563e95 commit e3b0b30

9 files changed

Lines changed: 2487 additions & 290 deletions

File tree

Cargo.lock

Lines changed: 123 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ thouart = { git = "https://github.com/oxidecomputer/thouart" }
6262
tokio = { version = "1.44.2", features = ["full"] }
6363
toml = "0.8.20"
6464
toml_edit = "0.22.24"
65+
tracing = "0.1.41"
66+
tracing-subscriber = { version = "0.3.19", features = ["env-filter", "json"] }
6567
url = "2.5.4"
6668
uuid = { version = "1.16.0", features = ["serde", "v4"] }
6769

@@ -70,7 +72,10 @@ uuid = { version = "1.16.0", features = ["serde", "v4"] }
7072
inherits = "release"
7173
lto = "thin"
7274

73-
#[patch."https://github.com/oxidecomputer/progenitor"]
74-
#progenitor = { path = "../progenitor/progenitor" }
75+
[patch."https://github.com/oxidecomputer/progenitor"]
76+
progenitor = { path = "../progenitor/progenitor" }
7577
#[patch."https://github.com/oxidecomputer/typify"]
7678
#typify = { path = "../typify/typify" }
79+
80+
[patch.crates-io]
81+
progenitor-client = { path = "../progenitor/progenitor-client" }

cli/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ thouart = { workspace = true }
4949
toml = { workspace = true }
5050
toml_edit = { workspace = true }
5151
tokio = { workspace = true }
52+
tracing = { workspace = true }
53+
tracing-subscriber = { workspace = true }
5254
url = { workspace = true }
5355
uuid = { workspace = true }
5456

cli/src/cli_builder.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{any::TypeId, collections::BTreeMap, marker::PhantomData, net::IpAddr,
99
use anyhow::{bail, Result};
1010
use async_trait::async_trait;
1111
use clap::{Arg, ArgMatches, Command, CommandFactory, FromArgMatches};
12-
use log::LevelFilter;
12+
use tracing_subscriber::EnvFilter;
1313

1414
use crate::{
1515
context::Context,
@@ -229,11 +229,20 @@ impl<'a> NewCli<'a> {
229229
timeout,
230230
} = OxideCli::from_arg_matches(&matches).expect("failed to parse OxideCli from args");
231231

232-
let mut log_builder = env_logger::builder();
233-
if debug {
234-
log_builder.filter_level(LevelFilter::Debug);
235-
}
236-
log_builder.init();
232+
let env_filter = if debug {
233+
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("oxide=debug"))
234+
} else {
235+
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"))
236+
};
237+
238+
tracing_subscriber::fmt()
239+
.with_env_filter(env_filter)
240+
.with_writer(std::io::stderr)
241+
.json()
242+
.flatten_event(true)
243+
.with_current_span(false)
244+
.with_span_list(false)
245+
.init();
237246

238247
let mut client_config = ClientConfig::default();
239248

cli/src/cmd_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use anyhow::{anyhow, bail, Result};
1313
use async_trait::async_trait;
1414
use clap::Parser;
1515
use futures::{StreamExt, TryStreamExt};
16-
use oxide::Client;
16+
use oxide::{Client, ClientInfo};
1717
use serde::Deserialize;
1818
use serde_json::Value;
1919

cli/src/cmd_version.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use anyhow::Result;
88
use async_trait::async_trait;
99
use clap::Parser;
10-
use oxide::Client;
10+
use oxide::{Client, ClientInfo};
1111

1212
use crate::println_nopipe;
1313
use crate::{context::Context, RunnableCmd};
@@ -26,7 +26,7 @@ pub struct CmdVersion;
2626
impl RunnableCmd for CmdVersion {
2727
async fn run(&self, _ctx: &Context) -> Result<()> {
2828
let cli_version = built_info::PKG_VERSION;
29-
let api_version = Client::new("").api_version();
29+
let api_version = Client::api_version();
3030

3131
println_nopipe!("Oxide CLI {}", cli_version);
3232

sdk/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ thiserror = { workspace = true }
2525
tokio = { workspace = true }
2626
toml = { workspace = true }
2727
toml_edit = { workspace = true }
28+
tracing = { workspace = true }
2829
uuid = { workspace = true }
2930

3031
[dev-dependencies]

0 commit comments

Comments
 (0)