#include "log.hpp" #include #include #include #include #include namespace t5de::log { namespace { std::FILE* open() { wchar_t temp[MAX_PATH + 1]; const DWORD length = GetTempPathW(MAX_PATH + 1, temp); if (length == 0 || length > MAX_PATH) { return nullptr; } // Shared, so it can be read while the client runs. return _wfsopen((std::filesystem::path(temp) / L"t5de-renderer.log").c_str(), L"w", _SH_DENYNO); } } // namespace void write(std::string_view line) { static std::mutex mutex; static std::FILE* file = open(); const std::scoped_lock lock(mutex); if (file != nullptr) { std::fwrite(line.data(), 1, line.size(), file); std::fputc('\n', file); std::fflush(file); } } } // namespace t5de::log