stellarUCI Chess engine written in C++20 |
git clone git://git.dimitrijedobrota.com/stellar.git |
Log | Files | Refs | README | LICENSE | |
logger.hpp (708B)
1 #ifndef STELLAR_ARENA_LOGGER_H 2 #define STELLAR_ARENA_LOGGER_H 3 4 #include "utils.hpp" 5 #include <cerrno> 6 #include <cstring> 7 #include <format> 8 9 namespace logger { 10 11 enum Level { 12 Critical, 13 Arena, 14 Debug, 15 Info, 16 }; 17 18 static Level active = Debug; 19 inline void set_level(const Level lvl) { active = lvl; } 20 21 inline void log(const std::string &message, const Level lvl = Arena) { 22 static const std::string name[] = {"crit", "arena", "debug", "info"}; 23 if (lvl > active) return; 24 std::cerr << std::format("[ {:>5} ] {}\n", name[to_underlying(lvl)], message); 25 } 26 27 inline void error(const char *call) { log(std::format("{}, {}", call, std::strerror(errno)), Critical); } 28 29 } // namespace logger 30 31 #endif