12extern bool LivePrintOff;
35#define WIN32_LEAN_AND_MEAN
55 HANDLE console = GetStdHandle(-11);
56 GetConsoleMode(console, &mode);
58 SetConsoleMode(console, mode);
69 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
73 PyErr_SetString(PyExc_TypeError,
"BAD");
90 tv.tv_nsec = long(fmod(now, 1.0) * 1000000000.0f);
91 tv.tv_sec = (uint64_t)now;
93 printf(
"%s:%d %s %" PRIu64
".%09ld ", file, line,
95 (uint64_t)tv.tv_sec, tv.tv_nsec);
106class SynchronizedFile {
109 std::ofstream stream;
113 InitializeSRWLock(&SrwLock);
115 std::string path = std::string(LOG_THREAD_FILE) +
"threadID" + std::to_string(_threadid) +
".log";
116 std::filesystem::create_directories(LOG_THREAD_FILE);
119 if (!stream.is_open() || !stream.good())
121 log_bad(
"file failed to create %s\n", path);
123 stream <<
"Open Log " << path <<
"\n";
127 void write(
const char* file,
int line,
enum LOG_LEVEL level,
const char* message) {
130 AcquireSRWLockExclusive(&SrwLock);
131 stream << file <<
"::" << line <<
"::" << log_label(level) <<
" " << message;
133 ReleaseSRWLockExclusive(&SrwLock);
136 void save(
const char* file,
const char* message) {
139 AcquireSRWLockExclusive(&SrwLock);
141 std::string path = std::string(LOG_THREAD_FILE) + std::string(file) +
".save";
142 std::filesystem::create_directories(LOG_THREAD_FILE);
143 std::ofstream _stream;
145 if (!_stream.is_open() || !_stream.good())
147 log_bad(
"file failed to create %s\n", path);
152 ReleaseSRWLockExclusive(&SrwLock);
159static auto syncFile = std::make_shared<SynchronizedFile>();
161void log__save(
const char* file,
const char* fmt)
163 syncFile->save(file, fmt);
170 char message[512] = { 0 };
173 vsprintf_s(message, fmt, args);
175 syncFile->write(file, line, level, message);
186 printf(
"%s:%d %s ", file, line, log_label(level));
205 size_t length = strlen(text);
206 std::wstring text_wchar(length, L
'#');
209 mbstowcs(&text_wchar[0], text, length);
217 char message[512] = { 0 };
221 vsprintf_s(message, fmt, args);
226 on_button = MessageBox(NULL,
to_wchar((std::string(file) +
":" + std::to_string(line) +
" \n " + message).c_str()).c_str(),
228 on_button = MessageBox(NULL, (std::string(file) +
":" + std::to_string(line) +
" \n " + message).c_str(),
230 TEXT(
"!Bad!"), MB_YESNO | MB_ICONQUESTION);
232 if (on_button == IDYES)
233 MessageBox(NULL, TEXT(
"Be Killed!"),
234 TEXT(
"exit."), MB_OK);
235 else MessageBox(NULL, TEXT(
"Be Killed!"),
236 TEXT(
"exit."), MB_OK);
247 printf(
"%s:%d %s VkaCode::%s ", file, line, log_label(level),
errorString(code));
267 printf(
"%s:%d %s ", file, line, log_label(level));
283 char message[512] = { 0 };
284 std::string mg = std::string(file) +
"::" + std::to_string(line);
289 vsprintf_s(message, fmt, args);
292 mg += std::string(
" ") + message;
294 OutputDebugString(mg.c_str());
304#define STR(r) case VK_ ##r: return #r
310 STR(ERROR_OUT_OF_HOST_MEMORY);
311 STR(ERROR_OUT_OF_DEVICE_MEMORY);
312 STR(ERROR_INITIALIZATION_FAILED);
313 STR(ERROR_DEVICE_LOST);
314 STR(ERROR_MEMORY_MAP_FAILED);
315 STR(ERROR_LAYER_NOT_PRESENT);
316 STR(ERROR_EXTENSION_NOT_PRESENT);
317 STR(ERROR_FEATURE_NOT_PRESENT);
318 STR(ERROR_INCOMPATIBLE_DRIVER);
319 STR(ERROR_TOO_MANY_OBJECTS);
320 STR(ERROR_FORMAT_NOT_SUPPORTED);
321 STR(ERROR_SURFACE_LOST_KHR);
322 STR(ERROR_NATIVE_WINDOW_IN_USE_KHR);
324 STR(ERROR_OUT_OF_DATE_KHR);
325 STR(ERROR_INCOMPATIBLE_DISPLAY_KHR);
326 STR(ERROR_VALIDATION_FAILED_EXT);
327 STR(ERROR_INVALID_SHADER_NV);
330 return "UNKNOWN_ERROR_";
void log__thread(const char *file, int line, enum LOG_LEVEL level, const char *fmt,...)
void log__bad(const char *file, int line, enum LOG_LEVEL level, const char *fmt,...)
const char * errorString(VkResult errorCode)
void log_out(const char *file, int line, enum LOG_LEVEL level, const char *fmt,...)
std::wstring to_wchar(const char *text)
void log__vkabad(const char *file, int line, enum LOG_LEVEL level, VkResult code, const char *fmt,...)
void log__once(const char *file, int line, enum LOG_LEVEL level, const char *fmt,...)
void testit(const char *fmt,...)
void log__vs(const char *file, int line, enum LOG_LEVEL level, const char *fmt,...)
void log__save(const char *file, const char *fmt)