Browse Source

add more logging

main
xenua 2 years 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 = [
"futures-util", "futures-util",
"knuffel", "knuffel",
"mastodon-async", "mastodon-async",
"paris",
"tokio", "tokio",
] ]
@ -814,6 +815,12 @@ dependencies = [
"vcpkg", "vcpkg",
] ]
[[package]]
name = "paris"
version = "1.5.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fecab3723493c7851f292cb060f3ee1c42f19b8d749345d0d7eaf3fd19aa62d"
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.12.1" version = "0.12.1"

3
Cargo.toml

@ -9,9 +9,10 @@ edition = "2021"
futures-util = "0.3.28" futures-util = "0.3.28"
knuffel = "3.0.0" knuffel = "3.0.0"
mastodon-async = { version = "1.2.1", features = ["toml", "mt"] } mastodon-async = { version = "1.2.1", features = ["toml", "mt"] }
paris = { version = "1.5.15", features = ["macros", "timestamps"] }
tokio = { version = "1.27.0", features = ["full"] } tokio = { version = "1.27.0", features = ["full"] }
[[bin]] [[bin]]
name = "f3" name = "f3"
path = "src/main.rs" path = "src/main.rs"

22
src/main.rs

@ -4,6 +4,8 @@ use mastodon_async::helpers::cli::authenticate;
use mastodon_async::helpers::toml; use mastodon_async::helpers::toml;
use mastodon_async::prelude::*; use mastodon_async::prelude::*;
use mastodon_async::Result as MResult; use mastodon_async::Result as MResult;
use paris::info;
use paris::Logger;
use std::fs::File; use std::fs::File;
use std::io::{self, Write}; use std::io::{self, Write};
@ -77,10 +79,7 @@ async fn do_the_thing() -> MResult<()> {
.. ..
}, },
} => { } => {
println!( let mut log = Logger::new();
"got a follow request from {} (@{})",
account.display_name, account.acct
);
let mut builder = StatusBuilder::new(); let mut builder = StatusBuilder::new();
builder builder
@ -93,9 +92,20 @@ async fn do_the_thing() -> MResult<()> {
let status = builder.build()?; 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(()) Ok(())
} }

Loading…
Cancel
Save