src/debug.cpp
changeset 6210 717cc12ac0a9
parent 5915 a39082f82ea2
child 6268 4b5241e5dd10
--- a/src/debug.cpp	Thu Feb 08 11:21:10 2007 +0000
+++ b/src/debug.cpp	Thu Feb 08 12:27:53 2007 +0000
@@ -8,6 +8,11 @@
 #include "debug.h"
 #include "functions.h"
 #include "string.h"
+#include "network/core/core.h"
+
+#if defined(ENABLE_NETWORK)
+SOCKET _debug_socket = INVALID_SOCKET;
+#endif /* ENABLE_NETWORK */
 
 int _debug_ai_level;
 int _debug_driver_level;
@@ -78,8 +83,18 @@
 		s = va_arg(va, const char*);
 		vsnprintf(buf, lengthof(buf), s, va);
 		va_end(va);
-		fprintf(stderr, "dbg: [%s] %s\n", dbg, buf);
-		IConsoleDebug(dbg, buf);
+#if defined(ENABLE_NETWORK)
+		if (_debug_socket != INVALID_SOCKET) {
+			char buf2[lengthof(buf) + 32];
+
+			snprintf(buf2, lengthof(buf2), "dbg: [%s] %s\n", dbg, buf);
+			send(_debug_socket, buf2, strlen(buf2), 0);
+		} else
+#endif /* ENABLE_NETWORK */
+		{
+			fprintf(stderr, "dbg: [%s] %s\n", dbg, buf);
+			IConsoleDebug(dbg, buf);
+		}
 	}
 }
 #endif /* NO_DEBUG_MESSAGES */