diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/apub_util/ingest.rs | 2 | ||||
-rw-r--r-- | src/apub_util/mod.rs | 8 | ||||
-rw-r--r-- | src/main.rs | 17 | ||||
-rw-r--r-- | src/migrate.rs | 4 | ||||
-rw-r--r-- | src/routes/api/mod.rs | 12 | ||||
-rw-r--r-- | src/routes/apub/communities.rs | 2 | ||||
-rw-r--r-- | src/routes/apub/mod.rs | 2 | ||||
-rw-r--r-- | src/tasks.rs | 2 |
8 files changed, 25 insertions, 24 deletions
diff --git a/src/apub_util/ingest.rs b/src/apub_util/ingest.rs index fb23e5a..e85cdfd 100644 --- a/src/apub_util/ingest.rs +++ b/src/apub_util/ingest.rs @@ -194,7 +194,7 @@ pub async fn ingest_object( ); } } else { - eprintln!("Warning: recieved follow for unknown community"); + log::error!("Warning: recieved follow for unknown community"); } } } diff --git a/src/apub_util/mod.rs b/src/apub_util/mod.rs index 61f9532..7b5414d 100644 --- a/src/apub_util/mod.rs +++ b/src/apub_util/mod.rs @@ -726,7 +726,7 @@ pub fn spawn_announce_community_post( match local_community_post_announce_ap(community, post_local_id, post_ap_id, &ctx.host_url_apub) { Err(err) => { - eprintln!("Failed to create Announce: {:?}", err); + log::error!("Failed to create Announce: {:?}", err); } Ok(announce) => { crate::spawn_task(enqueue_send_to_community_followers( @@ -879,7 +879,7 @@ pub fn spawn_enqueue_send_community_follow_accept( }; let accept = community_follow_accept_to_ap(community_ap_id, follower, follow_ap_id)?; - println!("{:?}", accept); + log::debug!("{:?}", accept); let body = serde_json::to_string(&accept)?; @@ -1400,8 +1400,8 @@ pub async fn check_signature_for_actor( }) }).transpose()?; - println!("signature: {:?}", signature); - println!("found_key: {:?}", found_key.is_some()); + log::debug!("signature: {:?}", signature); + log::debug!("found_key: {:?}", found_key.is_some()); let signature = hancock::Signature::parse(signature)?; diff --git a/src/main.rs b/src/main.rs index 913104d..7b2ab5d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -545,7 +545,7 @@ impl Translator { &mut errors, ); if !errors.is_empty() { - eprintln!("Errors in translation: {:?}", errors); + log::error!("Errors in translation: {:?}", errors); } out @@ -578,7 +578,7 @@ pub fn get_lang_for_req(req: &impl ReqParts) -> Translator { match err { fluent::FluentError::Overriding { .. } => {} _ => { - eprintln!("Failed to add language resource: {:?}", err); + log::error!("Failed to add language resource: {:?}", err); break; } } @@ -661,7 +661,7 @@ pub async fn is_local_user(db: &tokio_postgres::Client, user: UserLocalID) -> Re pub fn spawn_task<F: std::future::Future<Output = Result<(), Error>> + Send + 'static>(task: F) { use futures::future::TryFutureExt; tokio::spawn(task.map_err(|err| { - eprintln!("Error in task: {:?}", err); + log::error!("Error in task: {:?}", err); })); } @@ -682,7 +682,7 @@ pub fn on_local_community_add_post( post_ap_id: url::Url, ctx: Arc<crate::RouteContext>, ) { - println!("on_community_add_post"); + log::debug!("on_community_add_post"); crate::apub_util::spawn_announce_community_post(community, post_local_id, post_ap_id, ctx); } @@ -703,7 +703,7 @@ pub fn on_local_community_add_comment( pub fn on_post_add_comment(comment: CommentInfo<'static>, ctx: Arc<crate::RouteContext>) { use futures::future::TryFutureExt; - println!("on_post_add_comment"); + log::debug!("on_post_add_comment"); spawn_task(async move { let db = ctx.db_pool.get().await?; @@ -910,6 +910,7 @@ pub fn on_post_add_comment(comment: CommentInfo<'static>, ctx: Arc<crate::RouteC } fn main() -> Result<(), Box<dyn std::error::Error>> { + env_logger::init(); let mut args = std::env::args(); args.next(); // discard first element match args.next().as_deref() { @@ -1100,7 +1101,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error>> { Err(Error::UserError(res)) => res, Err(Error::RoutingError(err)) => err.to_simple_response(), Err(Error::Internal(err)) => { - eprintln!("Error: {:?}", err); + log::error!("Error: {:?}", err); simple_response( hyper::StatusCode::INTERNAL_SERVER_ERROR, @@ -1108,7 +1109,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error>> { ) } Err(Error::InternalStr(err)) => { - eprintln!("Error: {}", err); + log::error!("Error: {}", err); simple_response( hyper::StatusCode::INTERNAL_SERVER_ERROR, @@ -1116,7 +1117,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error>> { ) } Err(Error::InternalStrStatic(err)) => { - eprintln!("Error: {}", err); + log::error!("Error: {}", err); simple_response( hyper::StatusCode::INTERNAL_SERVER_ERROR, diff --git a/src/migrate.rs b/src/migrate.rs index 1d2ccd0..b3b754d 100644 --- a/src/migrate.rs +++ b/src/migrate.rs @@ -74,7 +74,7 @@ pub fn run(mut args: std::env::Args) { match action { "up" => { - println!("Applying migrations..."); + log::debug!("Applying migrations..."); migrant_lib::Migrator::with_config(&config) .all(true) .swallow_completion(true) @@ -82,7 +82,7 @@ pub fn run(mut args: std::env::Args) { .expect("Failed to apply migrations"); } "down" => { - println!("Unapplying migration..."); + log::debug!("Unapplying migration..."); migrant_lib::Migrator::with_config(&config) .direction(migrant_lib::Direction::Down) .all(false) diff --git a/src/routes/api/mod.rs b/src/routes/api/mod.rs index ca54ca9..b72f814 100644 --- a/src/routes/api/mod.rs +++ b/src/routes/api/mod.rs @@ -274,7 +274,7 @@ async fn route_unstable_actors_lookup( _req: hyper::Request<hyper::Body>, ) -> Result<hyper::Response<hyper::Body>, crate::Error> { let (query,) = params; - println!("lookup {}", query); + log::debug!("lookup {}", query); let lookup = parse_lookup(&query)?; @@ -289,14 +289,14 @@ async fn route_unstable_actors_lookup( rel: Some("self".into()), })? ); - println!("{}", uri); + log::debug!("{}", uri); let res = ctx .http_client .request(hyper::Request::get(uri).body(Default::default())?) .await?; if res.status() == hyper::StatusCode::NOT_FOUND { - println!("not found"); + log::debug!("not found"); None } else { let res = crate::res_to_error(res).await?; @@ -578,7 +578,7 @@ async fn route_unstable_objects_lookup( _req: hyper::Request<hyper::Body>, ) -> Result<hyper::Response<hyper::Body>, crate::Error> { let (query,) = params; - println!("lookup {}", query); + log::debug!("lookup {}", query); let lookup = parse_lookup(&query)?; @@ -593,14 +593,14 @@ async fn route_unstable_objects_lookup( rel: Some("self".into()), })? ); - println!("{}", uri); + log::debug!("{}", uri); let res = ctx .http_client .request(hyper::Request::get(uri).body(Default::default())?) .await?; if res.status() == hyper::StatusCode::NOT_FOUND { - println!("not found"); + log::debug!("not found"); None } else { let res = crate::res_to_error(res).await?; diff --git a/src/routes/apub/communities.rs b/src/routes/apub/communities.rs index 4a6e5f0..dd249f7 100644 --- a/src/routes/apub/communities.rs +++ b/src/routes/apub/communities.rs @@ -112,7 +112,7 @@ async fn handler_communities_get( .and_then(|bytes| match std::str::from_utf8(bytes) { Ok(key) => Some(key), Err(err) => { - eprintln!("Warning: public_key is not UTF-8: {:?}", err); + log::error!("Warning: public_key is not UTF-8: {:?}", err); None } }); diff --git a/src/routes/apub/mod.rs b/src/routes/apub/mod.rs index e5178ce..d6a9583 100644 --- a/src/routes/apub/mod.rs +++ b/src/routes/apub/mod.rs @@ -143,7 +143,7 @@ async fn handler_users_get( .and_then(|bytes| match std::str::from_utf8(bytes) { Ok(key) => Some(key), Err(err) => { - eprintln!("Warning: public_key is not UTF-8: {:?}", err); + log::error!("Warning: public_key is not UTF-8: {:?}", err); None } }); diff --git a/src/tasks.rs b/src/tasks.rs index be866bd..b802f35 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -82,7 +82,7 @@ impl<'a> TaskDef for DeliverToInbox<'a> { let res = crate::res_to_error(ctx.http_client.request(req).await?).await?; - println!("{:?}", res); + log::debug!("{:?}", res); Ok(()) } |