Added logging
This commit is contained in:
@@ -24,18 +24,16 @@ pub fn extract_cuddle(config: CuddleConfig) -> anyhow::Result<Arc<Mutex<Vec<Cudd
|
||||
let fetch_policy = config.get_fetch_policy()?;
|
||||
if let CuddleFetchPolicy::Always = fetch_policy {
|
||||
if let Err(res) = std::fs::remove_dir_all(curr_dir) {
|
||||
println!("{}", res);
|
||||
panic!("{}", res)
|
||||
}
|
||||
}
|
||||
|
||||
// Load main cuddle file
|
||||
let cuddle_yaml = find_root_cuddle()?;
|
||||
// TODO: Set trace
|
||||
println!("{}", cuddle_yaml);
|
||||
let cuddle_plan = serde_yaml::from_str::<CuddlePlan>(cuddle_yaml.as_str())?;
|
||||
log::trace!(cuddle_yaml=log::as_debug!(cuddle_yaml); "Find root cuddle");
|
||||
|
||||
// TODO: Set debug
|
||||
println!("{:?}", cuddle_plan);
|
||||
let cuddle_plan = serde_yaml::from_str::<CuddlePlan>(cuddle_yaml.as_str())?;
|
||||
log::debug!(cuddle_plan=log::as_debug!(cuddle_yaml); "parse cuddle plan");
|
||||
|
||||
let context: Arc<Mutex<Vec<CuddleContext>>> = Arc::new(Mutex::new(Vec::new()));
|
||||
context.lock().unwrap().push(CuddleContext {
|
||||
@@ -51,7 +49,7 @@ pub fn extract_cuddle(config: CuddleConfig) -> anyhow::Result<Arc<Mutex<Vec<Cudd
|
||||
))
|
||||
}
|
||||
CuddleBase::Bool(false) => {
|
||||
println!("plan is root skipping")
|
||||
log::debug!("plan is root: skipping");
|
||||
}
|
||||
CuddleBase::String(parent_plan) => {
|
||||
let destination_path = create_cuddle_local()?;
|
||||
@@ -65,13 +63,6 @@ pub fn extract_cuddle(config: CuddleConfig) -> anyhow::Result<Arc<Mutex<Vec<Cudd
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(ctx) = context.clone().lock() {
|
||||
// TODO: set trace
|
||||
println!("{:?}", ctx)
|
||||
} else {
|
||||
return Err(anyhow::anyhow!("could not acquire lock"));
|
||||
}
|
||||
|
||||
Ok(context)
|
||||
}
|
||||
|
||||
@@ -80,7 +71,7 @@ fn create_cuddle_local() -> anyhow::Result<PathBuf> {
|
||||
curr_dir.push(".cuddle/");
|
||||
|
||||
if curr_dir.exists() {
|
||||
println!(".cuddle already exists skipping");
|
||||
log::debug!(".cuddle/ already exists: skipping");
|
||||
return Ok(curr_dir);
|
||||
}
|
||||
|
||||
@@ -94,7 +85,7 @@ fn create_cuddle(path: PathBuf) -> anyhow::Result<PathBuf> {
|
||||
curr_dir.push(".cuddle/");
|
||||
|
||||
if curr_dir.exists() {
|
||||
println!(".cuddle already exists skipping");
|
||||
log::debug!(".cuddle/ already exists: skipping");
|
||||
return Ok(curr_dir);
|
||||
}
|
||||
|
||||
@@ -124,7 +115,7 @@ fn pull_parent_cuddle_into_local(
|
||||
.fetch_options(fo)
|
||||
.clone(&parent_cuddle, &destination)?;
|
||||
|
||||
println!("pulled: {}", parent_cuddle);
|
||||
log::debug!(parent_cuddle=log::as_display!(parent_cuddle); "pulled repository");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -150,7 +141,7 @@ fn recurse_parent(path: PathBuf, context: Arc<Mutex<Vec<CuddleContext>>>) -> any
|
||||
))
|
||||
}
|
||||
CuddleBase::Bool(false) => {
|
||||
println!("plan is root, finishing up");
|
||||
log::debug!("plan is root: finishing up");
|
||||
return Ok(());
|
||||
}
|
||||
CuddleBase::String(parent_plan) => {
|
||||
|
Reference in New Issue
Block a user