···11use crate::types::*;
22use anyhow::Error;
33use reqwest::Client;
44+use tracing::{debug, info, warn};
4556pub async fn create_tracks_collection() -> Result<(), Error> {
67 let client = Client::new();
···38393940 let api_key = std::env::var("RB_TYPESENSE_API_KEY");
4041 if api_key.is_err() {
4141- println!("Warning: RB_TYPESENSE_API_KEY is not set.");
4242+ warn!("RB_TYPESENSE_API_KEY is not set.");
4243 return Ok(());
4344 }
4445 let api_key = api_key.unwrap();
···4950 .send()
5051 .await?;
51525252- println!("Create tracks collection response: {}", res.status());
5353+ debug!("Create tracks collection response: {}", res.status());
53545455 Ok(())
5556}
···78797980 let api_key = std::env::var("RB_TYPESENSE_API_KEY");
8081 if api_key.is_err() {
8181- println!("Warning: RB_TYPESENSE_API_KEY is not set.");
8282+ warn!("RB_TYPESENSE_API_KEY is not set.");
8283 return Ok(());
8384 }
8485 let api_key = api_key.unwrap();
···8990 .send()
9091 .await?;
91929292- println!("Create albums collection response: {}", res.status());
9393+ debug!("Create albums collection response: {}", res.status());
93949495 Ok(())
9596}
···113114114115 let api_key = std::env::var("RB_TYPESENSE_API_KEY");
115116 if api_key.is_err() {
116116- println!("Warning: RB_TYPESENSE_API_KEY is not set.");
117117+ warn!("RB_TYPESENSE_API_KEY is not set.");
117118 return Ok(());
118119 }
119120 let api_key = api_key.unwrap();
···124125 .send()
125126 .await?;
126127127127- println!("Create artists collection response: {}", res.status());
128128+ debug!("Create artists collection response: {}", res.status());
128129129130 Ok(())
130131}
···145146146147 let api_key = std::env::var("RB_TYPESENSE_API_KEY");
147148 if api_key.is_err() {
148148- println!("Warning: RB_TYPESENSE_API_KEY is not set.");
149149+ warn!("RB_TYPESENSE_API_KEY is not set.");
149150 return Ok(());
150151 }
151152 let api_key = api_key.unwrap();
···160161 .send()
161162 .await?;
162163163163- println!("Insert tracks response: {}", res.status());
164164+ info!("Insert tracks response: {}", res.status());
164165165166 Ok(())
166167}
···181182182183 let api_key = std::env::var("RB_TYPESENSE_API_KEY");
183184 if api_key.is_err() {
184184- println!("Warning: RB_TYPESENSE_API_KEY is not set.");
185185+ warn!("RB_TYPESENSE_API_KEY is not set.");
185186 return Ok(());
186187 }
187188 let api_key = api_key.unwrap();
···196197 .send()
197198 .await?;
198199199199- println!("Insert albums response: {}", res.status());
200200+ info!("Insert albums response: {}", res.status());
200201201202 Ok(())
202203}
···217218218219 let api_key = std::env::var("RB_TYPESENSE_API_KEY");
219220 if api_key.is_err() {
220220- println!("Warning: RB_TYPESENSE_API_KEY is not set.");
221221+ warn!("RB_TYPESENSE_API_KEY is not set.");
221222 return Ok(());
222223 }
223224 let api_key = api_key.unwrap();
···232233 .send()
233234 .await?;
234235235235- println!("Insert artists response: {}", res.status());
236236+ info!("Insert artists response: {}", res.status());
236237237238 Ok(())
238239}
···247248248249 let api_key = std::env::var("RB_TYPESENSE_API_KEY");
249250 if api_key.is_err() {
250250- println!("Warning: RB_TYPESENSE_API_KEY is not set.");
251251+ warn!("RB_TYPESENSE_API_KEY is not set.");
251252 return Ok(None);
252253 }
253254 let api_key = api_key.unwrap();
···272273 match serde_json::from_str::<TrackResult>(&text) {
273274 Ok(result) => Ok(Some(result)),
274275 Err(e) => {
275275- eprintln!("Failed to parse Typesense response: {}", e);
276276- eprintln!("Response body: {}", text);
276276+ warn!("Failed to parse Typesense response: {}", e);
277277+ warn!("Response body: {}", text);
277278 Err(e.into())
278279 }
279280 }
···289290290291 let api_key = std::env::var("RB_TYPESENSE_API_KEY");
291292 if api_key.is_err() {
292292- println!("Warning: RB_TYPESENSE_API_KEY is not set.");
293293+ warn!("RB_TYPESENSE_API_KEY is not set.");
293294 return Ok(None);
294295 }
295296 let api_key = api_key.unwrap();
···323324324325 let api_key = std::env::var("RB_TYPESENSE_API_KEY");
325326 if api_key.is_err() {
326326- println!("Warning: RB_TYPESENSE_API_KEY is not set.");
327327+ warn!("RB_TYPESENSE_API_KEY is not set.");
327328 return Ok(None);
328329 }
329330 let api_key = api_key.unwrap();
+4-3
crates/typesense/src/lib.rs
···22 fs,
33 process::{Command, Stdio},
44};
55+use tracing::info;
5667pub mod client;
78pub mod types;
···3031 if !data_dir.join("api-key").exists() {
3132 let api_key = uuid::Uuid::new_v4().to_string();
3233 fs::write(data_dir.join("api-key"), &api_key)?;
3333- println!("Generated new Typesense API key: {}", api_key);
3434+ info!("Generated new Typesense API key: {}", api_key);
3435 if std::env::var("RB_TYPESENSE_API_KEY").is_err() {
3536 std::env::set_var("RB_TYPESENSE_API_KEY", &api_key);
3637 }
3738 } else {
3839 let api_key = fs::read_to_string(data_dir.join("api-key"))?;
3939- println!("Using existing Typesense API key: {}", api_key);
4040+ info!("Using existing Typesense API key: {}", api_key);
4041 if std::env::var("RB_TYPESENSE_API_KEY").is_err() {
4142 std::env::set_var("RB_TYPESENSE_API_KEY", &api_key);
4243 }
4344 }
44454546 if cmd.wait()?.success() {
4646- println!("Typesense server is already installed and available in PATH.");
4747+ info!("Typesense server is already installed and available in PATH.");
4748 return Ok(());
4849 }
4950
···273273 SDL_DestroySemaphore(s);
274274#else
275275 SDL_AddEventWatch(sdl_event_filter, NULL);
276276+ /* On macOS the event thread is not created, so SDL_INIT_AUDIO is never
277277+ initialized there. Do it here so SDL_OpenAudioDevice can succeed. */
278278+ SDL_InitSubSystem(SDL_INIT_AUDIO);
276279#endif
277280}
278281