Skip to content

Commit

Permalink
rust remove: add tracing crate to remove command
Browse files Browse the repository at this point in the history
Summary:
start using tracing lib. better sooner than later.

When running with DEBUG level, we should at least know which states are running.

Reviewed By: MichaelCuevas

Differential Revision: D64548021

fbshipit-source-id: 7f6e48b031040bf932549871cd322bd2d6229b3a
  • Loading branch information
lXXXw authored and facebook-github-bot committed Oct 20, 2024
1 parent 713ad60 commit 52d1fe6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions eden/fs/cli_rs/edenfs-commands/src/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ use anyhow::Result;
use async_trait::async_trait;
use clap::Parser;
use dialoguer::Confirm;
use tracing::debug;
use tracing::error;
use tracing::info;
use tracing::trace;

use crate::ExitCode;
use crate::Subcommand;
Expand Down Expand Up @@ -85,7 +89,6 @@ impl Determination {
{
return Err(anyhow!("Rust remove(Determination) is not implemented!"));
}
// TODO: this is an example of indicating a terminal state
Ok(None)
}
}
Expand All @@ -110,12 +113,20 @@ impl State {
State::SanityCheck(SanityCheck {})
}

fn name(&self) -> &'static str {
match self {
State::SanityCheck(_) => "SanityCheck",
State::Determination(_) => "Determination",
}
}

/// Runs the actions defined for this state
/// There are three cases for the return value:
/// 1. Ok(Some(State)) - we succeed in moving to the next state
/// 2. Ok(None) - we are in a terminal state and the removal is successful
/// 3. Err - the removal failed
fn run(&self, context: &mut RemoveContext) -> Result<Option<State>> {
debug!("State {} running...", self.name());
match self {
State::SanityCheck(inner) => inner.next(context),
State::Determination(inner) => inner.next(context),
Expand Down Expand Up @@ -170,7 +181,7 @@ mod tests {
let temp_dir = tempdir().context("couldn't create temp dir").unwrap();
let path = temp_dir.path().join("test").join("nested").join("inner");
let prefix = path.parent().unwrap();
println!("creating dirs: {}", prefix.to_str().unwrap());
println!("creating dirs: {:?}", prefix.to_str().unwrap());
std::fs::create_dir_all(prefix).unwrap();
temp_dir
}
Expand Down

0 comments on commit 52d1fe6

Please sign in to comment.