Replace logvisor with spdlog

This commit is contained in:
2025-04-03 21:06:08 -06:00
parent b513a7f4e0
commit 9584303083
23 changed files with 276 additions and 267 deletions

View File

@@ -1,4 +1,6 @@
#include <nod/Util.hpp>
#include "Util.hpp"
#include <spdlog/spdlog.h>
#if _WIN32
#ifndef WIN32_LEAN_AND_MEAN
@@ -31,7 +33,7 @@ FILE* Fopen(const char* path, const char* mode, FileLockType lock) {
&ov);
#else
if (flock(fileno(fp), ((lock == FileLockType::Write) ? LOCK_EX : LOCK_SH) | LOCK_NB))
LogModule.report(logvisor::Error, FMT_STRING("flock {}: {}"), path, strerror(errno));
spdlog::error("flock {}: {}", path, strerror(errno));
#endif
}
@@ -46,21 +48,21 @@ bool CheckFreeSpace(const char* path, size_t reqSz) {
wchar_t* end = nullptr;
DWORD ret = GetFullPathNameW(wpath.get(), 1024, buf.data(), &end);
if (ret == 0 || ret > 1024) {
LogModule.report(logvisor::Error, FMT_STRING("GetFullPathNameW {}"), path);
spdlog::error("GetFullPathNameW {}", path);
return false;
}
if (end != nullptr) {
end[0] = L'\0';
}
if (!GetDiskFreeSpaceExW(buf.data(), &freeBytes, nullptr, nullptr)) {
LogModule.report(logvisor::Error, FMT_STRING("GetDiskFreeSpaceExW {}: {}"), path, GetLastError());
spdlog::error("GetDiskFreeSpaceExW {}: {}", path, GetLastError());
return false;
}
return reqSz < freeBytes.QuadPart;
#else
struct statvfs svfs;
if (statvfs(path, &svfs)) {
LogModule.report(logvisor::Error, FMT_STRING("statvfs {}: {}"), path, strerror(errno));
spdlog::error("statvfs {}: {}", path, strerror(errno));
return false;
}
return reqSz < svfs.f_frsize * svfs.f_bavail;