Files
djhackersdev_bemanitools/src/main/core/log-ext.c
T
icex2 7a6c3af9c8 feat: Add log-ext, handle win last errors
Helper to easily deal with GetLastError, log it and
make the application fail
2024-08-15 11:34:33 +02:00

27 lines
587 B
C

#include <windows.h>
#include "iface-core/log.h"
void core_log_ext_win_last_error_log(const char *module, bt_core_log_message_t log_message)
{
LPSTR buffer;
DWORD last_error;
last_error = GetLastError();
FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
last_error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR) &buffer,
0,
NULL);
log_message(module, "Last error (%08X): %s", last_error, buffer);
LocalFree(buffer);
}