Skip to content

Conversation

Arshdeep54
Copy link

No description provided.

@Demigod345 Demigod345 changed the base branch from custom-logs to master April 12, 2025 18:59
Ok(())
}

pub fn add_user_to_groups(user: &str, groups: &[String]) -> Result<()> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this function be changed so that it is OS agnostic?

use crate::config::read_config;
use crate::utils::parse_offset;

pub fn log(filepath: &str, status: &str, message: &str) -> Result<()> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using a log library would be better instead of writing our own logger. That way we can also have fine control over the required log level.

src/update.rs Outdated

pub fn handle_update() -> Result<()> {
let mut users: Vec<String>= Vec::new();
logger::logln("in handle_update");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also wouldn't need these lines if we use a logging crate.

src/lib/utils.rs Outdated
use crate::{errors::*, logger};

use crate::errors::*;
pub const AUTH_LOG_PATH: &str = "/opt/watchdog/custom-logs/auth.logs";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these should be defined in another file, as they are not utilities.

src/ssh.rs Outdated
use lib::keyhouse::get_name;
use lib::notifier;
use lib::utils::clear_file;
//use lib::utils::clear_file;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove the unused use statement.

toml_edit="0.1.5"
nix = "0.9.0"
openssl = "0.10"
openssl-sys = "0.9.58"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see these used anywhere. Is there a reason for including openssl?

logger::logln(&format!("Projects: {:?}", projects));
Ok(projects)
} else {
logger::logln(&format!(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logging should ideally be done by the caller, after handling the returned error. Both logging it and returning the same error does not make sense.

@DarkPhoenix42
Copy link

nit: an empty line separating relevant sections of code would be nice to enhance readability. Also, it seems to me that some files have not been formatted. Although, that might just be because we use different formatting settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants