master > master: code-rust - debug logging auslagern

This commit is contained in:
RD 2022-04-14 05:16:53 +02:00
parent b377120ea8
commit 37f05d1ff0

View File

@ -67,10 +67,7 @@ fn tarjan_visit<T>(gph: &Graph<T>, v: &T, ctx: &mut Context<T>)
} }
} }
ctx.set_state(v, State::FINISHED); ctx.set_state(v, State::FINISHED);
if ctx.debug { ctx.log_info(&v);
let info = ctx.get_info(&v);
log_debug!("node, index, component: ({}, {}, {})", info.node, info.index, info.root);
}
if ctx.get_index(v) == ctx.get_root(v) { if ctx.get_index(v) == ctx.get_root(v) {
let mut component: Vec<T> = Vec::new(); let mut component: Vec<T> = Vec::new();
@ -155,21 +152,27 @@ impl<T> Context<T>
self.update_infos(u, info); self.update_infos(u, info);
} }
fn get_info(self: &mut Self, u: &T) -> NodeInformation<T> { fn get_info(self: &Self, u: &T) -> NodeInformation<T> {
return *self.infos.get(u).unwrap(); return *self.infos.get(u).unwrap();
} }
fn get_state(self: &mut Self, u: &T) -> State { fn get_state(self: &Self, u: &T) -> State {
return self.get_info(u).state; return self.get_info(u).state;
} }
fn get_root(self: &mut Self, u: &T) -> usize { fn get_root(self: &Self, u: &T) -> usize {
return self.get_info(u).root; return self.get_info(u).root;
} }
fn get_index(self: &mut Self, u: &T) -> usize { fn get_index(self: &Self, u: &T) -> usize {
return self.get_info(u).index; return self.get_info(u).index;
} }
fn log_info(self: &Self, u: &T) {
if !self.debug { return; }
let info = self.get_info(&u);
log_debug!("node, index, component: ({}, {}, {})", info.node, info.index, info.root);
}
} }
impl<T> NodeInformation<T> impl<T> NodeInformation<T>