initialise a memory structure or smth

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2023-09-11 10:23:46 +05:30
parent 84c68a4e00
commit 332f0b87d6
26 changed files with 763 additions and 163 deletions

49
src/util/log.cc Normal file
View File

@@ -0,0 +1,49 @@
#include "log.hh"
namespace logging {
namespace ansi {
static const char* RED = "\033[31m";
static const char* YELLOW = "\033[33m";
static const char* MAGENTA = "\033[35m";
static const char* WHITE = "\033[37m";
static const char* BOLD = "\033[1m";
static const char* RESET = "\033[0m";
}
Logger::Logger(std::ostream& os)
: os(os){};
void
Logger::set_level(Level level) {
switch (level) {
case Level::Debug:
os << ansi::MAGENTA << ansi::BOLD << "[DEBUG] ";
break;
case Level::Info:
os << ansi::WHITE << "[INFO] ";
break;
case Level::Warn:
os << ansi::YELLOW << "[WARN] ";
break;
case Level::Error:
os << ansi::RED << ansi::BOLD << "[ERROR] ";
break;
// unreachable
default: {
}
}
}
void
Logger::reset_level() {
os << ansi::RESET;
}
}
// Global logger
logging::Logger logger;