use super::errors::RuntimeError; use super::{FightOutcome, LogResult}; use std::io::Write; /// Write the given log result to the given stream, using ANSI colors. pub fn colored(mut f: W, item: &LogResult) -> Result<(), RuntimeError> { use colored::Colorize; writeln!(f, "{}: {:?}", "File".green(), item.log_file)?; let outcome = match item.outcome { FightOutcome::Success => "SUCCESS".green(), FightOutcome::Wipe => "WIPE".red(), }; writeln!( f, "{}: {} - {}: {} {}", "Date".green(), item.time.format("%Y-%m-%d %H:%M:%S %a"), "Boss".green(), item.boss_name, outcome, )?; for player in &item.players { writeln!( f, " {:2} {:20} {:19} {}", player.subgroup, player.account_name.yellow(), player.character_name.cyan(), player.profession )?; } writeln!(f)?; Ok(()) }