Skip to content

Commit c205742

Browse files
authored
feat: more logging, default to false (#684)
Closes #683
1 parent f4385da commit c205742

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

Cargo.toml

+3-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ bytes = "1.7"
4444
chrono = "0.4.39"
4545
clap = "4.5"
4646
cql2 = "0.3.0"
47-
duckdb = "=1.2.0"
47+
duckdb = "1.2.1"
4848
fluent-uri = "0.3.2"
4949
futures = "0.3.31"
5050
geo = "0.29.3"
@@ -53,7 +53,7 @@ geoarrow = "0.4.0-beta.4"
5353
geojson = "0.24.1"
5454
http = "1.1"
5555
jsonschema = { version = "0.29.0", default-features = false }
56-
libduckdb-sys = "=1.2.0"
56+
libduckdb-sys = "1.2.1"
5757
log = "0.4.25"
5858
mime = "0.3.17"
5959
mockito = "1.5"
@@ -78,7 +78,7 @@ stac-server = { version = "0.3.2", path = "crates/server" }
7878
syn = "2.0"
7979
tempfile = "3.16"
8080
thiserror = "2.0"
81-
tokio = "1.43"
81+
tokio = "1.44"
8282
tokio-postgres = "0.7.12"
8383
tokio-postgres-rustls = "0.13.0"
8484
tokio-stream = "0.1.16"
@@ -94,6 +94,4 @@ url = "2.3"
9494
webpki-roots = "0.26.8"
9595

9696
[patch.crates-io]
97-
duckdb = { git = "https://github.com/duckdb/duckdb-rs", rev = "5eeb1f01c278790ce1e2d24045f0096e9e2528e4" }
98-
libduckdb-sys = { git = "https://github.com/duckdb/duckdb-rs", rev = "5eeb1f01c278790ce1e2d24045f0096e9e2528e4" }
9997
geoarrow = { git = "https://github.com/geoarrow/geoarrow-rs/", rev = "2cd0d623e4b9f1ac3bc5ff6563ccce689a47c641" }

crates/cli/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use stac_server::Backend;
1010
use std::{collections::HashMap, io::Write, str::FromStr};
1111
use tokio::{io::AsyncReadExt, net::TcpListener, runtime::Handle};
1212
use tracing::metadata::Level;
13+
use tracing_subscriber::EnvFilter;
1314

1415
const DEFAULT_COLLECTION_ID: &str = "default-collection-id";
1516

@@ -263,7 +264,10 @@ impl Stacrs {
263264
pub async fn run(self, init_tracing_subscriber: bool) -> Result<()> {
264265
if init_tracing_subscriber {
265266
tracing_subscriber::fmt()
267+
.with_env_filter(EnvFilter::from_default_env())
266268
.with_max_level(self.log_level())
269+
.with_writer(std::io::stderr)
270+
.pretty()
267271
.init();
268272
}
269273
match self.command {

crates/duckdb/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1414
- Conditionally disable parsing the WKB ([#635](https://github.com/stac-utils/stac-rs/pull/635))
1515
- `Client.extensions` ([#665](https://github.com/stac-utils/stac-rs/pull/665))
1616
- `Config.install_extensions` ([#681](https://github.com/stac-utils/stac-rs/pull/681))
17+
- `Config.from_href` ([#684](https://github.com/stac-utils/stac-rs/pull/684))
1718

1819
### Removed
1920

crates/duckdb/src/lib.rs

+34-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ pub fn search(
2727
} else {
2828
search.limit = None;
2929
};
30-
let client = Client::new()?;
30+
let config = Config::from_href(href);
31+
let client = Client::with_config(config)?;
3132
client.search_to_json(href, search)
3233
}
3334

@@ -163,6 +164,26 @@ pub struct Extension {
163164
pub installed_from: Option<String>,
164165
}
165166

167+
impl Config {
168+
/// Creates a configuration from an href.
169+
///
170+
/// Use this to, e.g., autodetect s3 urls.
171+
///
172+
/// # Examples
173+
///
174+
/// ```
175+
/// use stac_duckdb::Config;
176+
/// let config = Config::from_href("s3://bucket/item.json");
177+
/// assert!(config.use_s3_credential_chain);
178+
/// ```
179+
pub fn from_href(s: &str) -> Config {
180+
Config {
181+
use_s3_credential_chain: s.starts_with("s3://"),
182+
..Default::default()
183+
}
184+
}
185+
}
186+
166187
impl Client {
167188
/// Creates a new client with no data sources.
168189
///
@@ -199,33 +220,42 @@ impl Client {
199220
pub fn with_config(config: Config) -> Result<Client> {
200221
let connection = Connection::open_in_memory()?;
201222
if let Some(ref custom_extension_repository) = config.custom_extension_repository {
223+
log::debug!("setting custom extension repository: {custom_extension_repository}");
202224
connection.execute(
203225
"SET custom_extension_repository = ?",
204226
[custom_extension_repository],
205227
)?;
206228
}
207229
if let Some(ref extension_directory) = config.extension_directory {
230+
log::debug!("setting extension directory: {extension_directory}");
208231
connection.execute("SET extension_directory = ?", [extension_directory])?;
209232
}
210233
if config.install_extensions {
234+
log::debug!("installing spatial");
211235
connection.execute("INSTALL spatial", [])?;
236+
log::debug!("installing icu");
212237
connection.execute("INSTALL icu", [])?;
213238
}
214239
connection.execute("LOAD spatial", [])?;
215240
connection.execute("LOAD icu", [])?;
216241
if config.use_httpfs && config.install_extensions {
242+
log::debug!("installing httpfs");
217243
connection.execute("INSTALL httpfs", [])?;
218244
}
219245
if config.use_s3_credential_chain {
220246
if config.install_extensions {
247+
log::debug!("installing aws");
221248
connection.execute("INSTALL aws", [])?;
222249
}
250+
log::debug!("creating s3 secret");
223251
connection.execute("CREATE SECRET (TYPE S3, PROVIDER CREDENTIAL_CHAIN)", [])?;
224252
}
225253
if config.use_azure_credential_chain {
226254
if config.install_extensions {
255+
log::debug!("installing azure");
227256
connection.execute("INSTALL azure", [])?;
228257
}
258+
log::debug!("creating azure secret");
229259
connection.execute("CREATE SECRET (TYPE azure, PROVIDER CREDENTIAL_CHAIN)", [])?;
230260
}
231261
Ok(Client { connection, config })
@@ -566,9 +596,9 @@ impl Default for Config {
566596
Config {
567597
use_hive_partitioning: false,
568598
convert_wkb: true,
569-
use_s3_credential_chain: true,
570-
use_azure_credential_chain: true,
571-
use_httpfs: true,
599+
use_s3_credential_chain: false,
600+
use_azure_credential_chain: false,
601+
use_httpfs: false,
572602
install_extensions: true,
573603
custom_extension_repository: None,
574604
extension_directory: None,

0 commit comments

Comments
 (0)