Browse Source

Change callback's signature

LouYihua 7 years ago
parent
commit
cd2357d34a
3 changed files with 6 additions and 7 deletions
  1. 3 4
      util.c
  2. 2 2
      util.h
  3. 1 1
      win32/win32.cpp

+ 3 - 4
util.c

@@ -580,10 +580,9 @@ UTIL_Platform_Quit(
 * Logging utilities
 */
 
-static LOGLEVEL _min_loglevel = LOGLEVEL_WARNING;
-
-static void(*_log_callback)(const char *, const char *) = NULL;
+static LOGCALLBACK _log_callback = NULL;
 static int _max_log_length = 0;
+static LOGLEVEL _min_loglevel = LOGLEVEL_WARNING;
 
 static const char * const _loglevel_str[] = {
 	"[VERBOSE]",
@@ -631,7 +630,7 @@ UTIL_LogOutput(
 	vsnprintf(buf + 31, maxloglen + 1, fmt, va);
 	va_end(va);
 
-	callback(buf, buf + 31);
+	callback(level, buf, buf + 31);
 	free(buf);
 }
 

+ 2 - 2
util.h

@@ -140,8 +140,6 @@ UTIL_Platform_Quit(
  * Logging utilities
  */
 
-typedef void(*LOGCALLBACK)(const char *, const char *);
-
 typedef enum LOGLEVEL
 {
 	LOGLEVEL_MIN,
@@ -154,6 +152,8 @@ typedef enum LOGLEVEL
 	LOGLEVEL_MAX = LOGLEVEL_FATAL,
 } LOGLEVEL;
 
+typedef void(*LOGCALLBACK)(LOGLEVEL, const char *, const char *);
+
 void
 UTIL_LogSetOutput(
 	LOGCALLBACK    callback,

+ 1 - 1
win32/win32.cpp

@@ -287,7 +287,7 @@ extern "C" int UTIL_Platform_Init(int argc, char* argv[])
 {
 #if defined(_DEBUG)
 	// Defaults log to debug output on debug builds
-	UTIL_LogSetOutput([](const char* str, const char* _)->void {
+	UTIL_LogSetOutput([](LOGLEVEL, const char* str, const char*)->void {
 		OutputDebugStringA(str);
 	}, 1024);
 #endif