Browse Source

add more logging

main
xenua 1 year ago
parent
commit
b6c565e744
Signed by: xenua
GPG Key ID: 8F93B68BD37255B8
  1. 7
      Cargo.lock
  2. 3
      Cargo.toml
  3. 22
      src/main.rs

7
Cargo.lock generated

@ -228,6 +228,7 @@ dependencies = [ @@ -228,6 +228,7 @@ dependencies = [
"futures-util",
"knuffel",
"mastodon-async",
"paris",
"tokio",
]
@ -814,6 +815,12 @@ dependencies = [ @@ -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"

3
Cargo.toml

@ -9,9 +9,10 @@ edition = "2021" @@ -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"
path = "src/main.rs"

22
src/main.rs

@ -4,6 +4,8 @@ use mastodon_async::helpers::cli::authenticate; @@ -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<()> { @@ -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<()> { @@ -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(())
}

Loading…
Cancel
Save