diff options
| author | sumuel <samuel@yakubos.org> | 2026-08-17 20:44:55 +0000 |
|---|---|---|
| committer | sumuel <samuel@yakubos.org> | 2026-08-17 20:44:55 +0000 |
| commit | 76424950e373d3b04ac3dd13019151bfba3e8423 (patch) | |
| tree | 4c3cfdbda039e592b9186be3e28f8d7cfd439e8a /src/common/debug.h | |
Add the files
Diffstat (limited to 'src/common/debug.h')
| -rw-r--r-- | src/common/debug.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/common/debug.h b/src/common/debug.h new file mode 100644 index 0000000..a378fc8 --- /dev/null +++ b/src/common/debug.h @@ -0,0 +1,37 @@ +#pragma once + +#include "fastfetch.h" +#include "common/time.h" + +static inline const char* ffFindFileName(const char* file) { + const char* lastSlash = __builtin_strrchr(file, '/'); +#ifdef _WIN32 + if (lastSlash == NULL) { + lastSlash = __builtin_strrchr(file, '\\'); + } +#endif + if (lastSlash != NULL) { + return lastSlash + 1; + } + return file; +} + +#ifndef NDEBUG + #define FF_DEBUG_PRINT(file_, line_, format_, ...) \ + do { \ + if (instance.config.display.debugMode) \ + fprintf(stderr, "[%s%4d, %s] " format_ "\n", ffFindFileName(file_), line_, ffTimeToTimeStr(ffTimeGetNow()), ##__VA_ARGS__); \ + } while (0) +#else + #define FF_DEBUG_PRINT(file_, line_, format_, ...) \ + do { \ + } while (0) +#endif + +#define FF_DEBUG(format, ...) FF_DEBUG_PRINT(__FILE__, __LINE__, format, ##__VA_ARGS__) + +#if _WIN32 +const char* ffDebugWin32Error(DWORD errorCode); +const char* ffDebugNtStatus(NTSTATUS status); +const char* ffDebugHResult(HRESULT hr); +#endif |