reintroduce logging statements

This commit is contained in:
glyph 2022-03-24 09:27:06 +02:00
parent d9019d6a4b
commit 979ec4eb64
2 changed files with 10 additions and 13 deletions

View File

@ -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)
}

View File

@ -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<Output> {
/// 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<SbotConfig>,
) -> Result<Sbot, PeachWebError> {
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<String, Box<dyn Error>> {
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<String, String> {
.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<String>) -> Result<Stri
.await
.map_err(|e| e.to_string())?;
// TODO: debug!("Publishing a new Scuttlebutt private message");
debug!("Publishing a new Scuttlebutt private message");
match sbot_client
.publish_private(text.to_string(), recipients)
.await