refactor: make linter happy

also add a few unused coprocessor instructions

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2023-09-14 01:07:41 +05:30
parent 387f3c8f07
commit 3cf5cbd024
19 changed files with 394 additions and 240 deletions

View File

@@ -3,54 +3,55 @@
#include <fmt/ostream.h>
#include <iostream>
namespace logger {
inline std::ostream& stream = std::clog;
using fmt::print;
using std::clog;
namespace logger {
namespace ansi {
static constexpr char RED[] = "\033[31m";
static constexpr char YELLOW[] = "\033[33m";
static constexpr char MAGENTA[] = "\033[35m";
static constexpr char WHITE[] = "\033[37m";
static constexpr char BOLD[] = "\033[1m";
static constexpr char RESET[] = "\033[0m";
static constexpr std::string_view RED = "\033[31m";
static constexpr std::string_view YELLOW = "\033[33m";
static constexpr std::string_view MAGENTA = "\033[35m";
static constexpr std::string_view WHITE = "\033[37m";
static constexpr std::string_view BOLD = "\033[1m";
static constexpr std::string_view RESET = "\033[0m";
}
template<typename... Args>
inline void
log_raw(const fmt::format_string<Args...>& fmt, Args&&... args) {
fmt::println(stream, fmt, std::forward<Args>(args)...);
fmt::println(clog, fmt, std::forward<Args>(args)...);
}
template<typename... Args>
inline void
log_debug(const fmt::format_string<Args...>& fmt, Args&&... args) {
fmt::print(stream, "{}{}[DEBUG] ", ansi::MAGENTA, ansi::BOLD);
print(clog, "{}{}[DEBUG] ", ansi::MAGENTA, ansi::BOLD);
log_raw(fmt, std::forward<Args>(args)...);
fmt::print(stream, ansi::RESET);
print(clog, ansi::RESET);
}
template<typename... Args>
inline void
log_info(const fmt::format_string<Args...>& fmt, Args&&... args) {
fmt::print(stream, "{}[INFO] ", ansi::WHITE);
print(clog, "{}[INFO] ", ansi::WHITE);
log_raw(fmt, std::forward<Args>(args)...);
fmt::print(stream, ansi::RESET);
print(clog, ansi::RESET);
}
template<typename... Args>
inline void
log_warn(const fmt::format_string<Args...>& fmt, Args&&... args) {
fmt::print(stream, "{}[WARN] ", ansi::YELLOW);
print(clog, "{}[WARN] ", ansi::YELLOW);
log_raw(fmt, std::forward<Args>(args)...);
fmt::print(stream, ansi::RESET);
print(clog, ansi::RESET);
}
template<typename... Args>
inline void
log_error(const fmt::format_string<Args...>& fmt, Args&&... args) {
fmt::print(stream, "{}{}[ERROR] ", ansi::RED, ansi::BOLD);
print(clog, "{}{}[ERROR] ", ansi::RED, ansi::BOLD);
log_raw(fmt, std::forward<Args>(args)...);
fmt::print(stream, ansi::RESET);
print(clog, ansi::RESET);
}
}