stellarUCI Chess engine written in C++20 |
git clone git://git.dimitrijedobrota.com/stellar.git |
Log | Files | Refs | README | LICENSE |
logger.hpp (713B)
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>
7 #include <iostream>
9 namespace logger {
11 enum Level {
12 Critical,
13 Arena,
14 Debug,
15 Info,
16 };
18 static Level active = Debug;
19 inline void set_level(const Level lvl) { active = lvl; }
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[lvl], message);
25 }
27 inline void error(const char *call) { log(std::format("{}, {}", call, std::strerror(errno)), Critical); }
29 } // namespace logger
31 #endif