Radish alpha
r
rad:z39mP9rQAaGmERfUMPULfPUi473tY
Radicle terminal user interface
Radicle
Git
bin: Improve log messages
Erik Kundt committed 3 months ago
commit 96f49a851d9e388e880594277b07dc1963c459ca
parent f6b08db
6 files changed +16 -22
modified bin/commands/inbox.rs
@@ -188,7 +188,7 @@ pub async fn run(options: Options, ctx: impl radicle_cli::terminal::Context) ->
            if let Err(err) = crate::log::enable() {
                println!("{err}");
            }
-
            log::info!("Starting inbox listing interface in project {rid}..");
+
            log::info!("Starting inbox listing app in project {rid}..");

            let mut state = PreviousState::default();
            loop {
@@ -213,9 +213,7 @@ pub async fn run(options: Options, ctx: impl radicle_cli::terminal::Context) ->
                        .map(|o| serde_json::to_string(&o).unwrap_or_default())
                        .unwrap_or_default();

-
                    log::info!("About to print to `stderr`: {selection}");
-
                    log::info!("Exiting inbox listing interface..");
-

+
                    log::info!("Exiting inbox listing app..");
                    eprint!("{selection}");
                } else if let Some(selection) = selection {
                    if let Some(operation) = selection.operation.clone() {
modified bin/commands/issue.rs
@@ -250,7 +250,7 @@ pub async fn run(options: Options, ctx: impl Context) -> anyhow::Result<()> {
            if let Err(err) = crate::log::enable() {
                println!("{err}");
            }
-
            log::info!("Starting issue listing interface in project {rid}..");
+
            log::info!("Starting issue listing app in project {rid}..");

            #[derive(Default)]
            struct PreviousState {
@@ -286,8 +286,7 @@ pub async fn run(options: Options, ctx: impl Context) -> anyhow::Result<()> {
                        .map(|o| serde_json::to_string(&o).unwrap_or_default())
                        .unwrap_or_default();

-
                    log::info!("Exiting issue listing interface..");
-

+
                    log::info!("Exiting issue listing app..");
                    eprint!("{selection}");
                } else if let Some(selection) = selection {
                    if let Some(operation) = selection.operation.clone() {
modified bin/commands/patch.rs
@@ -307,13 +307,13 @@ pub async fn run(options: Options, ctx: impl radicle_cli::terminal::Context) ->

    match options.op {
        Operation::List { opts } => {
-
            log::info!("Starting patch selection interface in project {rid}..");
+
            log::info!("Starting patch listing app in project {rid}..");

            let rid = options.repo.unwrap_or(rid);
            interface::list(opts.clone(), ctx.profile()?, rid).await?;
        }
        Operation::Review { ref opts } => {
-
            log::info!("Starting patch review interface in project {rid}..");
+
            log::info!("Starting patch review app in project {rid}..");

            let profile = ctx.profile()?;
            let rid = options.repo.unwrap_or(rid);
@@ -391,8 +391,7 @@ mod interface {
                    .map(|o| serde_json::to_string(&o).unwrap_or_default())
                    .unwrap_or_default();

-
                log::info!("About to print to `stderr`: {selection}");
-
                log::info!("Exiting patch list interface..");
+
                log::info!("Exiting patch list app..");

                eprint!("{selection}");

modified bin/commands/patch/review.rs
@@ -595,8 +595,6 @@ impl store::Update<Message> for App<'_> {
    type Return = Response;

    fn update(&mut self, message: Message) -> Option<Exit<Self::Return>> {
-
        log::info!("Received message: {message:?}");
-

        match message {
            Message::ShowMain => {
                let mut state = self.state.lock().unwrap();
@@ -641,15 +639,15 @@ impl store::Update<Message> for App<'_> {
            }
            Message::Accept => {
                match self.accept_selected_hunk() {
-
                    Ok(()) => log::info!("Accepted selected hunk."),
-
                    Err(err) => log::info!("An error occured while accepting hunk: {err}"),
+
                    Ok(()) => log::debug!("Accepted selected hunk ({:?}).", self.selected_hunk()),
+
                    Err(err) => log::error!("An error occured while accepting hunk: {err}"),
                }
                None
            }
            Message::Reject => {
                match self.reject_selected_hunk() {
-
                    Ok(()) => log::info!("Rejected selected hunk."),
-
                    Err(err) => log::info!("An error occured while rejecting hunk: {err}"),
+
                    Ok(()) => log::debug!("Rejected selected hunk ({:?}).", self.selected_hunk()),
+
                    Err(err) => log::error!("An error occured while rejecting hunk: {err}"),
                }
                None
            }
modified bin/ui/items/notification.rs
@@ -176,8 +176,8 @@ impl NotificationKind {
                } else if typed_id.is_identity() {
                    let Ok(identity) = Identity::get(id, repo) else {
                        log::error!(
-
                            target: "items",
-
                            "Error retrieving identity {id} for notification {}", notification.id
+
                            "Error retrieving identity {id} for notification {}",
+
                            notification.id
                        );
                        return Ok(None);
                    };
@@ -187,8 +187,8 @@ impl NotificationKind {
                        .and_then(|id| identity.revision(&id))
                    else {
                        log::error!(
-
                            target: "items",
-
                            "Error retrieving identity revision for notification {}", notification.id
+
                            "Error retrieving identity revision for notification {}",
+
                            notification.id
                        );
                        return Ok(None);
                    };
modified bin/ui/items/patch.rs
@@ -613,7 +613,7 @@ impl From<(&Repository, &Review, &HunkDiff)> for HunkItem<'_> {
                            let ranges = DiffLineRanges::from(hunk);
                            let index = DiffLineIndex::from(location);

-
                            log::warn!("Checking comment {comment:?} at {index:?}");
+
                            log::debug!("Checking comment {comment:?} at {index:?}");

                            return index.is_start_of(&ranges)
                                || index.is_inside_of(&ranges)