impr: Further improve compile times

This commit is contained in:
WerWolv
2023-11-30 14:40:07 +01:00
parent 8ee234e5a6
commit a50bb39978
28 changed files with 89 additions and 79 deletions

View File

@@ -4,6 +4,9 @@
#include <wolv/io/file.hpp>
#include <chrono>
#include <fmt/chrono.h>
#if defined(OS_WINDOWS)
#include <Windows.h>
#endif
@@ -59,6 +62,22 @@ namespace hex::log::impl {
return logEntries;
}
void printPrefix(FILE *dest, const fmt::text_style &ts, const std::string &level) {
const auto now = fmt::localtime(std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()));
fmt::print(dest, "[{0:%H:%M:%S}] ", now);
if (impl::isRedirected())
fmt::print(dest, "{0} ", level);
else
fmt::print(dest, ts, "{0} ", level);
fmt::print(dest, "[{0}] ", IMHEX_PROJECT_NAME);
constexpr static auto ProjectNameLength = std::char_traits<char>::length(IMHEX_PROJECT_NAME);
fmt::print(dest, "{}", std::string(ProjectNameLength > 10 ? 0 : 10 - ProjectNameLength, ' '));
}
void assertionHandler(bool expr, const char* exprString, const char* file, int line) {
if (!expr) {
log::error("Assertion failed: {} at {}:{}", exprString, file, line);