From 34f55321e0844049af7134faacc5cc2fa4c390ff Mon Sep 17 00:00:00 2001
From: Pietro Gagliardi <pietro10@mac.com>
Date: Thu, 7 May 2015 19:34:45 -0400
Subject: [PATCH] Added a [libui] and a newline to the message printed by
 complain().

---
 TODO.md        | 2 --
 darwin/util.m  | 2 ++
 unix/util.c    | 6 +++---
 windows/util.c | 2 ++
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/TODO.md b/TODO.md
index 55f7ed30..6a33ea49 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,5 +1,3 @@
-- make sure complain()s don't have \n at the end; add one on each platform
-	- add a `[libui]` to the beginning of the message
 - figure out what to do on Windows and GTK+ if we don't have menus but the user wants a menubar (zero-height widget? don't bother? complain?)
 - bin.c
 	- find a way to consolidate the duplicate code across OSs
diff --git a/darwin/util.m b/darwin/util.m
index 7d331fb4..c7441461 100644
--- a/darwin/util.m
+++ b/darwin/util.m
@@ -24,7 +24,9 @@ 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);
 	abort();
 }
diff --git a/unix/util.c b/unix/util.c
index f02f4380..523d4cb2 100644
--- a/unix/util.c
+++ b/unix/util.c
@@ -4,10 +4,10 @@
 void complain(const char *fmt, ...)
 {
 	va_list ap;
+	char *msg;
 
 	va_start(ap, fmt);
-	// there's no g_errorv() in glib 2.32, so do it manually instead
-	g_logv(G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, fmt, ap);
+	msg = g_strdup_vprintf(fmt, ap);
 	va_end(ap);
-	abort();		// just in case
+	g_error("[libui] %s\n", msg);
 }
diff --git a/windows/util.c b/windows/util.c
index eae4d0fb..c8705450 100644
--- a/windows/util.c
+++ b/windows/util.c
@@ -78,7 +78,9 @@ 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);
 	abort();
 }