summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorD. Scott Boggs <scott@tams.tech>2023-06-05 07:43:49 -0400
committerD. Scott Boggs <scott@tams.tech>2023-09-01 07:54:19 -0400
commit80d1bbe5727be1c271f81fff31451ce182139c6f (patch)
tree715c0a173946978f6cf6deb5cd2d11b578101169
parent6d9375dde8a73a14683bd2cf3dc6b70ed0f52662 (diff)
Update example to use tracing instead of femme
-rw-r--r--examples/upload_photo.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/examples/upload_photo.rs b/examples/upload_photo.rs
index 49e5b34..16820f9 100644
--- a/examples/upload_photo.rs
+++ b/examples/upload_photo.rs
@@ -2,11 +2,24 @@
#![cfg_attr(not(feature = "toml"), allow(unused_imports))]
mod register;
use mastodon_async::{prelude::*, Result};
+use std::fs::File;
+use tracing_subscriber::{fmt, EnvFilter};
#[cfg(feature = "toml")]
async fn run() -> Result<()> {
+ let file = File::create("logfile.txt")?;
+ let (non_blocking, _guard) = tracing_appender::non_blocking(file);
+ let filter = EnvFilter::default()
+ .add_directive("hyper=info".parse().unwrap())
+ .add_directive("reqwest=info".parse().unwrap())
+ .add_directive("mastodon_async=trace".parse().unwrap());
+ fmt()
+ .with_env_filter(filter)
+ .with_writer(non_blocking)
+ .json()
+ .init();
+
use register::bool_input;
- femme::with_level(femme::LevelFilter::Info);
let mastodon = register::get_mastodon_data().await?;
let input = register::read_line("Enter the path to the photo you'd like to post: ")?;
let description = register::read_line("describe the media? ")?;