pub(crate) use crate::utils::init_log::log_initialization;
pub(crate) use crate::utils::gen_log::{log_done, log_run_start};
pub(crate) use crate::utils::summary_log::{log_repeated_topologies, topo_hash};
use comfy_table::{ContentArrangement, Table, modifiers::UTF8_ROUND_CORNERS, presets::UTF8_FULL};
pub(crate) const TABLE_WIDTH: u16 = 160;
pub(crate) const COMPACT_TABLES: bool = false;
pub(crate) fn log_section_table(heading: &str, header: &[&str], rows: &[Vec<String>], width: u16) {
log::info!("");
log::info!("══ {heading} ══{}", "═".repeat(60usize.saturating_sub(heading.len() + 4)));
let mut table = Table::new();
if COMPACT_TABLES {
table
.load_preset(UTF8_FULL)
.apply_modifier(UTF8_ROUND_CORNERS)
.set_content_arrangement(ContentArrangement::Disabled);
table.column_iter_mut().for_each(|c| {
c.set_padding((0, 1));
});
} else {
table
.load_preset(UTF8_FULL)
.apply_modifier(UTF8_ROUND_CORNERS)
.set_content_arrangement(ContentArrangement::DynamicFullWidth)
.set_width(width);
table.column_iter_mut().for_each(|c| {
c.set_padding((2, 2));
});
}
table.set_header(header);
for row in rows {
table.add_row(row.clone());
}
for line in table.to_string().lines() {
log::info!(" {line}");
}
}