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