diff --git a/server/Cargo.lock b/server/Cargo.lock index d414b157..6db1e2d2 100644 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -2363,6 +2363,7 @@ version = "1.1.0" dependencies = [ "derive_builder", "geojson", + "log", "reqwest", "serde", "serde_json", diff --git a/server/algorithms/src/utils.rs b/server/algorithms/src/utils.rs index 191e708e..5df424f4 100644 --- a/server/algorithms/src/utils.rs +++ b/server/algorithms/src/utils.rs @@ -29,7 +29,7 @@ where content = content.trim_end_matches(",").to_string(); let mut output = File::create(path)?; write!(output, "{}", content)?; - // println!("Saved {} to file with {} coords", file_name, input.len()); + // log::info!("Saved {} to file with {} coords", file_name, input.len()); Ok(()) } @@ -38,7 +38,7 @@ pub fn debug_string(file_name: &str, input: &String) -> std::io::Result<()> { let path = format!("./debug_files/{}", file_name); let mut output = File::create(path)?; write!(output, "{}", input)?; - // println!("Saved {} to file with {} coords", file_name, input.len()); + // log::info!("Saved {} to file with {} coords", file_name, input.len()); Ok(()) } diff --git a/server/api/src/private/instance.rs b/server/api/src/private/instance.rs index f8d5e93e..9e71efde 100644 --- a/server/api/src/private/instance.rs +++ b/server/api/src/private/instance.rs @@ -18,7 +18,7 @@ use crate::{ #[get("/from_scanner")] async fn from_scanner(conn: web::Data) -> Result { - log::info!("\n[INSTANCE-ALL] Scanner Type: {}", conn.scanner_type); + log::info!("[INSTANCE-ALL] Scanner Type: {}", conn.scanner_type); let instances = if conn.scanner_type == ScannerType::Unown { area::Query::all(&conn.controller).await @@ -27,7 +27,7 @@ async fn from_scanner(conn: web::Data) -> Result { } .map_err(actix_web::error::ErrorInternalServerError)?; - log::info!("[INSTANCE_ALL] Returning {} instances\n", instances.len()); + log::info!("[INSTANCE_ALL] Returning {} instances", instances.len()); Ok(HttpResponse::Ok().json(Response { data: Some(json!(instances)), message: "ok".to_string(), @@ -39,7 +39,7 @@ async fn from_scanner(conn: web::Data) -> Result { #[get("/from_koji")] async fn from_koji(conn: web::Data) -> Result { - log::info!("\n[INSTANCE-ALL] Scanner Type: {}", conn.scanner_type); + log::info!("[INSTANCE-ALL] Scanner Type: {}", conn.scanner_type); let fences = geofence::Query::get_all_no_fences(&conn.koji) .await @@ -66,7 +66,7 @@ async fn from_koji(conn: web::Data) -> Result { }) }); - log::info!("[INSTANCE_ALL] Returning {} instances\n", fences.len()); + log::info!("[INSTANCE_ALL] Returning {} instances", fences.len()); Ok(HttpResponse::Ok().json(Response { data: Some(json!(fences)), message: "ok".to_string(), diff --git a/server/api/src/private/points.rs b/server/api/src/private/points.rs index 001fbca3..2b5e4eb8 100644 --- a/server/api/src/private/points.rs +++ b/server/api/src/private/points.rs @@ -18,7 +18,7 @@ async fn all( let category = category.into_inner(); log::info!( - "\n[DATA_ALL] Scanner Type: {} | Category: {}", + "[DATA_ALL] Scanner Type: {} | Category: {}", conn.scanner_type, category ); @@ -31,7 +31,7 @@ async fn all( } .map_err(actix_web::error::ErrorInternalServerError)?; - log::info!("[DATA-ALL] Returning {} {}s\n", all_data.len(), category); + log::info!("[DATA-ALL] Returning {} {}s", all_data.len(), category); Ok(HttpResponse::Ok().json(all_data)) } @@ -45,7 +45,7 @@ async fn bound( let payload = payload.into_inner(); log::info!( - "\n[DATA_BOUND] Scanner Type: {} | Category: {}", + "[DATA_BOUND] Scanner Type: {} | Category: {}", conn.scanner_type, category ); @@ -58,11 +58,7 @@ async fn bound( } .map_err(actix_web::error::ErrorInternalServerError)?; - log::info!( - "[DATA-BOUND] Returning {} {}s\n", - bound_data.len(), - category - ); + log::info!("[DATA-BOUND] Returning {} {}s", bound_data.len(), category); Ok(HttpResponse::Ok().json(bound_data)) } @@ -83,7 +79,7 @@ async fn by_area( } = payload.into_inner().init(None); log::info!( - "\n[DATA_AREA] Scanner Type: {} | Category: {}", + "[DATA_AREA] Scanner Type: {} | Category: {}", conn.scanner_type, category ); @@ -101,7 +97,7 @@ async fn by_area( .await .map_err(actix_web::error::ErrorInternalServerError)?; - log::info!("[DATA-AREA] Returning {} {}s\n", area_data.len(), category); + log::info!("[DATA-AREA] Returning {} {}s", area_data.len(), category); Ok(HttpResponse::Ok().json(area_data)) } @@ -122,7 +118,7 @@ async fn area_stats( } = payload.into_inner().init(None); log::info!( - "\n[DATA_AREA] Scanner Type: {} | Category: {}", + "[DATA_AREA] Scanner Type: {} | Category: {}", conn.scanner_type, category ); @@ -146,7 +142,7 @@ async fn area_stats( .map_err(actix_web::error::ErrorInternalServerError)?; log::info!( - "[DATA-AREA] Returning {} Total: {}\n", + "[DATA-AREA] Returning {} Total: {}", category, area_data.total ); diff --git a/server/api/src/public/v1/geofence.rs b/server/api/src/public/v1/geofence.rs index 4e0de9af..7c2fd8a4 100644 --- a/server/api/src/public/v1/geofence.rs +++ b/server/api/src/public/v1/geofence.rs @@ -24,7 +24,7 @@ async fn all( .await .map_err(actix_web::error::ErrorInternalServerError)?; - println!("[PUBLIC_API] Returning {} instances\n", fc.features.len()); + log::info!("[PUBLIC_API] Returning {} instances", fc.features.len()); Ok(HttpResponse::Ok().json(Response { data: Some(json!(fc)), message: "Success".to_string(), @@ -52,7 +52,7 @@ async fn get_area( .map_err(actix_web::error::ErrorInternalServerError)?; log::info!( - "[PUBLIC_API] Returning feature for {:?}\n", + "[PUBLIC_API] Returning feature for {:?}", feature.property("name") ); Ok(utils::response::send( @@ -112,7 +112,7 @@ async fn save_scanner( .await .map_err(actix_web::error::ErrorInternalServerError)?; } - println!("Rows Updated: {}, Rows Inserted: {}", updates, inserts); + log::info!("Rows Updated: {}, Rows Inserted: {}", updates, inserts); Ok(HttpResponse::Ok().json(Response { data: Some(json!({ "updates": updates, "inserts": inserts })), @@ -167,7 +167,7 @@ async fn reference_data(conn: web::Data) -> Result .await .map_err(actix_web::error::ErrorInternalServerError)?; - log::info!("[GEOFENCES_ALL] Returning {} instances\n", fences.len()); + log::info!("[GEOFENCES_ALL] Returning {} instances", fences.len()); Ok(HttpResponse::Ok().json(Response { data: Some(json!(fences)), message: "Success".to_string(), @@ -210,10 +210,7 @@ async fn specific_return_type( .await .map_err(actix_web::error::ErrorInternalServerError)?; - println!( - "[GEOFENCES_ALL] Returning {} instances\n", - fc.features.len() - ); + log::info!("[GEOFENCES_ALL] Returning {} instances", fc.features.len()); Ok(utils::response::send(fc, return_type, None, false, None)) } @@ -231,10 +228,7 @@ async fn specific_project( .await .map_err(actix_web::error::ErrorInternalServerError)?; - println!( - "[GEOFENCES_FC_ALL] Returning {} instances\n", - features.len() - ); + log::info!("[GEOFENCES_FC_ALL] Returning {} instances", features.len()); Ok(utils::response::send( features.to_collection(None, None), return_type, diff --git a/server/api/src/public/v1/route.rs b/server/api/src/public/v1/route.rs index e2c63d10..5ee65f2b 100644 --- a/server/api/src/public/v1/route.rs +++ b/server/api/src/public/v1/route.rs @@ -23,7 +23,7 @@ async fn all( .await .map_err(actix_web::error::ErrorInternalServerError)?; - log::info!("[PUBLIC_API] Returning {} routes\n", fc.features.len()); + log::info!("[PUBLIC_API] Returning {} routes", fc.features.len()); Ok(HttpResponse::Ok().json(Response { data: Some(json!(fc)), message: "Success".to_string(), @@ -51,7 +51,7 @@ async fn get_area( .map_err(actix_web::error::ErrorInternalServerError)?; log::info!( - "[PUBLIC_API] Returning feature for {:?}\n", + "[PUBLIC_API] Returning feature for {:?}", feature.property("name") ); Ok(utils::response::send( @@ -69,7 +69,7 @@ async fn reference_data(conn: web::Data) -> Result .await .map_err(actix_web::error::ErrorInternalServerError)?; - log::info!("[ROUTE_REF] Returning {} instances\n", fences.len()); + log::info!("[ROUTE_REF] Returning {} instances", fences.len()); Ok(HttpResponse::Ok().json(Response { data: Some(json!(fences)), message: "Success".to_string(), @@ -173,10 +173,7 @@ async fn specific_return_type( .await .map_err(actix_web::error::ErrorInternalServerError)?; - log::info!( - "[GEOFENCES_ALL] Returning {} instances\n", - fc.features.len() - ); + log::info!("[GEOFENCES_ALL] Returning {} instances", fc.features.len()); Ok(utils::response::send(fc, return_type, None, false, None)) } @@ -197,10 +194,7 @@ async fn specific_geofence( .await .map_err(actix_web::error::ErrorInternalServerError)?; - log::info!( - "[GEOFENCES_FC_ALL] Returning {} instances\n", - features.len() - ); + log::info!("[GEOFENCES_FC_ALL] Returning {} instances", features.len()); Ok(utils::response::send( features.to_collection(None, None), return_type, diff --git a/server/model/src/api/mod.rs b/server/model/src/api/mod.rs index cc1fca8b..f488c0f4 100644 --- a/server/model/src/api/mod.rs +++ b/server/model/src/api/mod.rs @@ -204,7 +204,7 @@ impl BBox { vec![self.max_x, self.min_y], vec![self.min_x, self.min_y], ]] - // println!( + // log::info!( // "{}, {}\n{}, {}\n{}, {}\n{}, {}\n{}, {}\n", // self.min_y, // self.min_x, diff --git a/server/model/src/api/multi_struct.rs b/server/model/src/api/multi_struct.rs index 8fce5fb7..bc7f4122 100644 --- a/server/model/src/api/multi_struct.rs +++ b/server/model/src/api/multi_struct.rs @@ -30,7 +30,7 @@ impl ToMultiVec for MultiStruct { impl ToPointStruct for MultiStruct { fn to_struct(self) -> point_struct::PointStruct { - println!("`to_struct()` was called on a SingleVec and this was likely unintentional, did you mean to map over the values first?"); + log::info!("`to_struct()` was called on a SingleVec and this was likely unintentional, did you mean to map over the values first?"); point_struct::PointStruct { lat: self[0][0].lat, lon: self[0][0].lon, diff --git a/server/model/src/api/multi_vec.rs b/server/model/src/api/multi_vec.rs index 77e33a73..51a3678f 100644 --- a/server/model/src/api/multi_vec.rs +++ b/server/model/src/api/multi_vec.rs @@ -85,7 +85,7 @@ impl ToMultiVec for MultiVec { impl ToPointStruct for MultiVec { fn to_struct(self) -> point_struct::PointStruct { - println!("`to_struct()` was called on a MultiVec and this was likely unintentional, did you mean to map over the values first?"); + log::warn!("`to_struct()` was called on a MultiVec and this was likely unintentional, did you mean to map over the values first?"); point_struct::PointStruct { lat: self[0][0][0], lon: self[1][0][1], diff --git a/server/model/src/api/poracle.rs b/server/model/src/api/poracle.rs index 1d628cf1..a4589e14 100644 --- a/server/model/src/api/poracle.rs +++ b/server/model/src/api/poracle.rs @@ -154,7 +154,7 @@ impl ToFeature for Poracle { UnknownId::String(id) => match id.parse::() { Ok(id) => id, Err(err) => { - println!("Parse Error: {:?}", err); + log::error!("Parse Error: {:?}", err); 0 } }, diff --git a/server/model/src/api/single_struct.rs b/server/model/src/api/single_struct.rs index 654ada4c..4c1352a0 100644 --- a/server/model/src/api/single_struct.rs +++ b/server/model/src/api/single_struct.rs @@ -31,7 +31,7 @@ impl ToMultiVec for SingleStruct { impl ToPointStruct for SingleStruct { fn to_struct(self) -> point_struct::PointStruct { - println!("`to_struct()` was called on a SingleVec and this was likely unintentional, did you mean to map over the values first?"); + log::warn!("`to_struct()` was called on a SingleVec and this was likely unintentional, did you mean to map over the values first?"); point_struct::PointStruct { lat: self[0].lat, lon: self[0].lon, diff --git a/server/model/src/db/project.rs b/server/model/src/db/project.rs index e0853f31..1a6c5bba 100644 --- a/server/model/src/db/project.rs +++ b/server/model/src/db/project.rs @@ -113,7 +113,7 @@ impl Query { let results: Vec = match paginator.fetch_page(args.page).await { Ok(results) => results, Err(err) => { - println!("[project] Error paginating, {:?}", err); + log::error!("[project] Error paginating, {:?}", err); vec![] } }; diff --git a/server/nominatim/Cargo.toml b/server/nominatim/Cargo.toml index c1c12bb8..a352ffb8 100644 --- a/server/nominatim/Cargo.toml +++ b/server/nominatim/Cargo.toml @@ -14,6 +14,7 @@ reqwest = "0.11.22" serde = { version = "1.0.189", features = ["derive"] } serde_json = "1.0.107" serde_urlencoded = "0.7.1" +log = "0.4.20" url = "2.4.1" derive_builder = "0.12.0" thiserror = "1.0.50" diff --git a/server/nominatim/src/reverse.rs b/server/nominatim/src/reverse.rs index c0096305..573c0183 100644 --- a/server/nominatim/src/reverse.rs +++ b/server/nominatim/src/reverse.rs @@ -1,8 +1,7 @@ use crate::client::Client; use crate::error::Error; use crate::serde_utils::{ - serialize_as_string, serialize_bool_as_string, - serialize_vector_as_string_opt, + serialize_as_string, serialize_bool_as_string, serialize_vector_as_string_opt, }; use crate::types::Response; use crate::util::RequestBuilderHelper; @@ -97,10 +96,7 @@ impl Client { /// always have a similar enough address to the coordinate you were /// requesting. For example, in dense city areas it may belong to a /// completely different street. - pub async fn reverse( - &self, - query: ReverseQuery, - ) -> Result { + pub async fn reverse(&self, query: ReverseQuery) -> Result { let mut url = self.base_url.join("reverse")?; url.set_query(Some(&serde_urlencoded::to_string(&query).unwrap())); @@ -114,7 +110,7 @@ impl Client { let text = response.text().await?; - println!("{}", text); + log::info!("{}", text); Ok(serde_json::from_str(&text)?) }