diff --git a/Cargo.lock b/Cargo.lock index c7f590b..6304889 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -228,6 +228,7 @@ dependencies = [ "futures-util", "knuffel", "mastodon-async", + "paris", "tokio", ] @@ -814,6 +815,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "paris" +version = "1.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fecab3723493c7851f292cb060f3ee1c42f19b8d749345d0d7eaf3fd19aa62d" + [[package]] name = "parking_lot" version = "0.12.1" diff --git a/Cargo.toml b/Cargo.toml index bbaff66..43d7fae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,9 +9,10 @@ edition = "2021" futures-util = "0.3.28" knuffel = "3.0.0" mastodon-async = { version = "1.2.1", features = ["toml", "mt"] } +paris = { version = "1.5.15", features = ["macros", "timestamps"] } tokio = { version = "1.27.0", features = ["full"] } [[bin]] name = "f3" -path = "src/main.rs" \ No newline at end of file +path = "src/main.rs" diff --git a/src/main.rs b/src/main.rs index c18a9f0..eddcc7e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,8 @@ use mastodon_async::helpers::cli::authenticate; use mastodon_async::helpers::toml; use mastodon_async::prelude::*; use mastodon_async::Result as MResult; +use paris::info; +use paris::Logger; use std::fs::File; use std::io::{self, Write}; @@ -77,10 +79,7 @@ async fn do_the_thing() -> MResult<()> { .. }, } => { - println!( - "got a follow request from {} (@{})", - account.display_name, account.acct - ); + let mut log = Logger::new(); let mut builder = StatusBuilder::new(); builder @@ -93,9 +92,20 @@ async fn do_the_thing() -> MResult<()> { let status = builder.build()?; - client.new_status(status).await?; + let res = client.new_status(status).await?; + log.info(format!( + "got a follow request from {} (@{})", + account.display_name, account.acct + )) + .info(format!(" reply is at {}", res.uri)); } - _ => (), + Event::Notification(n) => info!( + "got other notification of type {:?} from @{}", + n.notification_type, n.account.acct + ), + Event::Update(u) => info!("got update event: {:?}", u), + Event::Delete(d) => info!("got delete event: {:?}", d), + Event::FiltersChanged => info!("filters changed"), } Ok(()) }