From 979ec4eb6499ce6a7c036b162c8391af8c41ff42 Mon Sep 17 00:00:00 2001 From: glyph Date: Thu, 24 Mar 2022 09:27:06 +0200 Subject: [PATCH] reintroduce logging statements --- .../src/routes/settings/scuttlebutt/configure.rs | 9 ++------- peach-web/src/utils/sbot.rs | 14 ++++++++------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/peach-web/src/routes/settings/scuttlebutt/configure.rs b/peach-web/src/routes/settings/scuttlebutt/configure.rs index d546a73..1a03187 100644 --- a/peach-web/src/routes/settings/scuttlebutt/configure.rs +++ b/peach-web/src/routes/settings/scuttlebutt/configure.rs @@ -208,13 +208,9 @@ pub fn handle_form(request: &Request, restart: bool) -> Response { repair: bool, })); - debug!("ip: {} port: {}", data.lis_ip, data.lis_port); - // concat the ip and port for listen address let lis = format!("{}:{}", data.lis_ip, data.lis_port); - debug!("{}", lis); - // instantiate `SbotConfig` from form data let config = SbotConfig { lis, @@ -235,14 +231,13 @@ pub fn handle_form(request: &Request, restart: bool) -> Response { match data.startup { true => { - // TODO: rouille - log integration - //info!("Enabling go-sbot.service"); + debug!("Enabling go-sbot.service"); if let Err(e) = sbot::systemctl_sbot_cmd("enable") { warn!("Failed to enable go-sbot.service: {}", e) } } false => { - // TODO: info!("Disabling go-sbot.service"); + debug!("Disabling go-sbot.service"); if let Err(e) = sbot::systemctl_sbot_cmd("disable") { warn!("Failed to disable go-sbot.service: {}", e) } diff --git a/peach-web/src/utils/sbot.rs b/peach-web/src/utils/sbot.rs index 0852662..3a0bb74 100644 --- a/peach-web/src/utils/sbot.rs +++ b/peach-web/src/utils/sbot.rs @@ -13,6 +13,7 @@ use async_std::task; use dirs; use futures::stream::TryStreamExt; use golgi::{api::friends::RelationshipQuery, blobs, messages::SsbMessageValue, Sbot}; +use log::debug; use peach_lib::sbot::SbotConfig; use rouille::input::post::BufferedFile; use temporary::Directory; @@ -33,7 +34,7 @@ pub fn systemctl_sbot_cmd(cmd: &str) -> io::Result { /// Executes a systemctl stop command followed by start command. /// Returns a redirect with a flash message stating the output of the restart attempt. pub fn restart_sbot_process() -> (String, String) { - // TODO: info!("Restarting go-sbot.service"); + debug!("Restarting go-sbot.service"); match systemctl_sbot_cmd("stop") { // if stop was successful, try to start the process Ok(_) => match systemctl_sbot_cmd("start") { @@ -63,6 +64,7 @@ pub fn restart_sbot_process() -> (String, String) { pub async fn init_sbot_with_config( sbot_config: &Option, ) -> Result { + debug!("Initialising an sbot client with configuration parameters"); // initialise sbot connection with ip:port and shscap from config file let sbot_client = match sbot_config { // TODO: panics if we pass `Some(conf.shscap)` as second arg @@ -143,7 +145,7 @@ pub fn create_invite(uses: u16) -> Result> { task::block_on(async { let mut sbot_client = init_sbot_with_config(&sbot_config).await?; - //TODO: debug!("Generating Scuttlebutt invite code"); + debug!("Generating Scuttlebutt invite code"); let invite_code = sbot_client.invite_create(uses).await?; Ok(invite_code) @@ -300,7 +302,7 @@ pub fn update_profile_info( if let Some(name) = new_name { // only update the name if it has changed if name != current_name { - // TODO: debug!("Publishing new Scuttlebutt profile name"); + debug!("Publishing a new Scuttlebutt profile name"); if let Err(e) = sbot_client.publish_name(&name).await { return Err(format!("Failed to update name: {}", e)); } else { @@ -312,7 +314,7 @@ pub fn update_profile_info( if let Some(description) = new_description { // only update the description if it has changed if description != current_description { - //debug!("Publishing new Scuttlebutt profile description"); + debug!("Publishing a new Scuttlebutt profile description"); if let Err(e) = sbot_client.publish_description(&description).await { return Err(format!("Failed to update description: {}", e)); } else { @@ -521,7 +523,7 @@ pub fn publish_public_post(text: String) -> Result { .await .map_err(|e| e.to_string())?; - // TODO: debug!("Publishing new Scuttlebutt public post"); + debug!("Publishing a new Scuttlebutt public post"); match sbot_client.publish_post(&text).await { Ok(_) => Ok("Published post".to_string()), Err(e) => Err(format!("Failed to publish post: {}", e)), @@ -539,7 +541,7 @@ pub fn publish_private_msg(text: String, recipients: Vec) -> Result