From f0d817cf39987e7b7548863c86beac29440ab7c6 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 12 Jul 2023 02:04:57 +0100 Subject: Remove rang and use fmtlib for printing coloured messages. This supports more platforms (e.g. Haiku) and is actually still maintained unlike the former. All of this code should really be cleaned up for release (maybe by adding something like Anope's LOG_CONSOLE) but for now I've just replaced it with the fmtlib equivalent. --- src/modules.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/modules.cpp') diff --git a/src/modules.cpp b/src/modules.cpp index 74d8acf08..13c73cb28 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -30,9 +30,7 @@ */ -#include - -#include +#include #include "inspircd.h" #include "exitcodes.h" @@ -536,10 +534,12 @@ void ModuleManager::LoadAll() continue; this->NewServices = &servicemap[name]; - std::cout << "[" << rang::style::bold << rang::fg::green << "*" << rang::style::reset << "] Loading module:\t" << rang::style::bold << rang::fg::green << name << rang::style::reset << std::endl; + fmt::println("[{}] Loading module:\t{}", fmt::styled("*", fmt::emphasis::bold | fmt::fg(fmt::terminal_color::green)), name); if (!this->Load(name, true)) { - std::cout << std::endl << "[" << rang::style::bold << rang::fg::red << "*" << rang::style::reset << "] " << this->LastError() << std::endl << std::endl; + fmt::println(""); + fmt::println("[{}] {}", fmt::styled("*", fmt::emphasis::bold | fmt::fg(fmt::terminal_color::red)), LastError()); + fmt::println(""); ServerInstance->Exit(EXIT_STATUS_MODULE); } } @@ -558,7 +558,9 @@ void ModuleManager::LoadAll() { LastModuleError = "Unable to initialize " + modname + ": " + modexcept.GetReason(); ServerInstance->Logs.Error("MODULE", LastModuleError); - std::cout << std::endl << "[" << rang::style::bold << rang::fg::red << "*" << rang::style::reset << "] " << LastModuleError << std::endl << std::endl; + fmt::println(""); + fmt::println("[{}] {}", fmt::styled("*", fmt::emphasis::bold | fmt::fg(fmt::terminal_color::red)), LastModuleError); + fmt::println(""); ServerInstance->Exit(EXIT_STATUS_MODULE); } } @@ -580,7 +582,9 @@ void ModuleManager::LoadAll() { LastModuleError = "Unable to read the configuration for " + modname + ": " + modexcept.GetReason(); ServerInstance->Logs.Error("MODULE", LastModuleError); - std::cout << std::endl << "[" << rang::style::bold << rang::fg::red << "*" << rang::style::reset << "] " << LastModuleError << std::endl << std::endl; + fmt::println(""); + fmt::println("[{}] {}", fmt::styled("*", fmt::emphasis::bold | fmt::fg(fmt::terminal_color::red)), LastModuleError); + fmt::println(""); ServerInstance->Exit(EXIT_STATUS_CONFIG); } } -- cgit v1.3.1-10-gc9f91