Files
fastfetch/src/common/debug.h
T

39 lines
1.4 KiB
C
Raw Normal View History

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"
2026-03-29 09:28:49 +08:00
static inline const char* ffFindFileName(const char* file) {
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) {
lastSlash = __builtin_strrchr(file, '\\');
2026-03-29 09:28:49 +08:00
}
#endif
2026-07-10 18:08:04 +08:00
if (lastSlash != nullptr) {
return lastSlash + 1;
2026-03-29 09:28:49 +08:00
}
return file;
}
#ifndef NDEBUG
#define FF_DEBUG_PRINT(file_, line_, format_, ...) \
2026-03-29 09:28:49 +08:00
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_, ...) \
2026-03-29 09:28:49 +08:00
do { \
} while (0)
#endif
#define FF_DEBUG(format, ...) FF_DEBUG_PRINT(__FILE__, __LINE__, format, ##__VA_ARGS__)
2026-01-06 09:42:54 +08:00
#if _WIN32
2026-03-27 20:14:47 +08:00
const char* ffDebugWin32Error(DWORD errorCode);
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