Revert "Added more robust debugger logging to the Windows backend, PROPERLY this time."

Bleh, still don't quite feel like it...

This reverts commit a105522e0a.
This commit is contained in:
Pietro Gagliardi 2015-06-09 18:08:41 -04:00
parent a105522e0a
commit 1e1a69f1bb
3 changed files with 13 additions and 59 deletions

View File

@ -15,7 +15,6 @@ osCFILES = \
windows/group.c \
windows/init.c \
windows/label.c \
windows/logging.c \
windows/main.c \
windows/menu.c \
windows/parent.c \

View File

@ -1,58 +0,0 @@
// 9 june 2015
#include "uipriv_windows.h"
// We can't use the private heap for these functions, since they are allowed to be run before uiInit() or after uiUninit().
static void nomemlog(void)
{
OutputDebugStringW(L"[libui] memory exhausted logging message");
DebugBreak();
abort(); // just in case
}
void uiLog(const char *format, ...)
{
va_list ap;
va_start(ap, format);
uiLogv(format, ap);
va_end(ap);
}
void uiLogv(const char *format, va_list ap)
{
va_list ap2;
int n;
char *buf;
va_copy(ap2, ap);
n = _vscprintf(format, ap2);
va_end(ap2);
// "[libui] message\0" == (8 + n + 1)
buf = (char *) malloc((8 + n + 1)
if (buf == NULL)
nomemlog();
buf[0] = '[';
buf[1] = 'l';
buf[2] = 'i';
buf[3] = 'b';
buf[4] = 'u';
buf[5] = 'i';
buf[6] = ']';
buf[7] = ' ';
vsnprintf_s(buf + 8, n + 1, n, format, ap);
// breaking the rules: we can't reliably tell that the encoding of debugging messages is UTF-8 like we could with everything else :/
OutputDebugStringA(buf);
free(buf);
}
void complain(const char *format, ...)
{
va_list ap;
va_start(ap, format);
uiLogv(format, av);
va_end(ap);
DebugBreak();
abort(); // just in case
}

View File

@ -34,6 +34,19 @@ int windowClassOf(HWND hwnd, ...)
return -1;
}
void complain(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
fprintf(stderr, "[libui] ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
va_end(ap);
DebugBreak();
abort(); // just in case
}
// wrapper around MapWindowRect() that handles the complex error handling
void mapWindowRect(HWND from, HWND to, RECT *r)
{