From 752dc9365ccf1589698117f20fdb41989947aeb1 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Wed, 18 Jan 2023 19:59:23 +0200 Subject: [PATCH] feat: "logging" and a few deps --- Cargo.lock | 12 ++++++++++++ Cargo.toml | 2 ++ src/main.rs | 9 +++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fa57417..f63a189 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -826,6 +826,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "111.24.0+1.1.1s" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3498f259dab01178c6228c6b00dcef0ed2a2d5e20d648c017861227773ea4abd" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.80" @@ -835,6 +844,7 @@ dependencies = [ "autocfg", "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] @@ -1362,6 +1372,8 @@ name = "wallhavenapirandom" version = "0.1.0" dependencies = [ "actix-web", + "log", + "openssl", "rand", "reqwest", "serde", diff --git a/Cargo.toml b/Cargo.toml index 2173d8c..d9964e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,3 +11,5 @@ actix-web = "4.2.1" reqwest = { version = "0.11.13", features = ["json"] } serde = { version = "1.0.152", features = ["derive"] } rand = "0.8.5" +openssl = { version = "0.10.45", features = ["vendored"] } +log = "0.4.17" diff --git a/src/main.rs b/src/main.rs index e0df150..33792de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,18 +59,22 @@ async fn random(args: web::Path) -> impl Responder { "https://wallhaven.cc/api/v1/search?atleast={atl}&ratios={rats}&purity={pur}&categories={cats}&sorting=random&q={q}&apikey={api_key}" ); + log::info!("doing the thing with args 'atl={atl} rats={rats} pur={pur} cats={cats} q={q}'"); + let search_resp = reqwest::get(wh_url).await; match search_resp { Err(err) => { - println!("search_resp: {}", err); + log::error!( + "oh nej! we hast failed! like, in the 'search_resp' thingy. err is '{err}'" + ); } Ok(search_resp) => { let json = search_resp.json::().await; match json { Err(err) => { - println!("json: {}", err); + log::error!("rövhål! failed in the 'json' match. err is '{err}'"); } Ok(res) => { let imgs = res.data; @@ -90,6 +94,7 @@ async fn random(args: web::Path) -> impl Responder { #[actix_web::main] async fn main() -> std::io::Result<()> { + log::info!("startedth uppeth"); HttpServer::new(|| App::new().service(random)) .bind(("127.0.0.1", 3000))? .run() -- 2.44.1