2025-03-26 09:46:44 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
2025-03-23 10:51:26 +08:00
|
|
|
#include "fastfetch.h"
|
2026-01-06 09:48:38 +08:00
|
|
|
#include "common/time.h"
|
2025-03-15 19:49:51 +08:00
|
|
|
|
2026-03-29 09:28:49 +08:00
|
|
|
static inline const char* ffFindFileName(const char* file) {
|
2025-03-15 23:35:58 +08:00
|
|
|
const char* lastSlash = __builtin_strrchr(file, '/');
|
2026-03-29 09:28:49 +08:00
|
|
|
#ifdef _WIN32
|
2026-07-10 18:08:04 +08:00
|
|
|
if (lastSlash == nullptr) {
|
2025-03-15 23:35:58 +08:00
|
|
|
lastSlash = __builtin_strrchr(file, '\\');
|
2026-03-29 09:28:49 +08:00
|
|
|
}
|
|
|
|
|
#endif
|
2026-07-10 18:08:04 +08:00
|
|
|
if (lastSlash != nullptr) {
|
2025-03-15 19:49:51 +08:00
|
|
|
return lastSlash + 1;
|
2026-03-29 09:28:49 +08:00
|
|
|
}
|
2025-03-15 19:49:51 +08:00
|
|
|
return file;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
2026-04-15 16:16:46 +08:00
|
|
|
#define FF_DEBUG_PRINT(file_, line_, format_, ...) \
|
2026-03-29 09:28:49 +08:00
|
|
|
do { \
|
|
|
|
|
if (instance.config.display.debugMode) \
|
2025-03-15 19:49:51 +08:00
|
|
|
fprintf(stderr, "[%s%4d, %s] " format_ "\n", ffFindFileName(file_), line_, ffTimeToTimeStr(ffTimeGetNow()), ##__VA_ARGS__); \
|
|
|
|
|
} while (0)
|
|
|
|
|
#else
|
2026-04-15 16:16:46 +08:00
|
|
|
#define FF_DEBUG_PRINT(file_, line_, format_, ...) \
|
2026-03-29 09:28:49 +08:00
|
|
|
do { \
|
|
|
|
|
} while (0)
|
2025-03-15 19:49:51 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define FF_DEBUG(format, ...) FF_DEBUG_PRINT(__FILE__, __LINE__, format, ##__VA_ARGS__)
|
2025-03-16 10:38:04 +08:00
|
|
|
|
2026-01-06 09:42:54 +08:00
|
|
|
#if _WIN32
|
2026-03-27 20:14:47 +08:00
|
|
|
const char* ffDebugWin32Error(DWORD errorCode);
|
2026-03-14 22:55:16 +08:00
|
|
|
const char* ffDebugNtStatus(NTSTATUS status);
|
2026-06-13 15:20:40 +08:00
|
|
|
const char* ffDebugConfigRet(unsigned long /*CONFIGRET*/ ret);
|
2026-03-27 20:14:47 +08:00
|
|
|
const char* ffDebugHResult(HRESULT hr);
|
2026-01-06 09:42:54 +08:00
|
|
|
#endif
|