Просмотр исходного кода

Fixed Logger to log in VS Debug Output, if compiled as Debug. Documented Logger a bit.

Joachim Meyer 11 лет назад
Родитель
Сommit
148efdb33a
2 измененных файлов с 27 добавлено и 5 удалено
  1. 20 1
      Core/Contents/Include/PolyLogger.h
  2. 7 4
      Core/Contents/Source/PolyLogger.cpp

+ 20 - 1
Core/Contents/Include/PolyLogger.h

@@ -34,15 +34,34 @@ namespace Polycode {
 			String message;
 			
 	};
-
+	
+	/**
+	* Logs information to the console, should only be called through Logger::
+	*/
 	class _PolyExport Logger : public EventDispatcher {
 		public:
+			/**
+			* Default constructor
+			*/
 			Logger();
 			virtual ~Logger();
 
+			/**
+			* Dispatches LoggerEvent and calls Logger::log()
+			* @param message String to log
+			*/
 			void logBroadcast(String message);
 
+			/**
+			* Logs information to the console or debug window of VS (only available if compiled as debug)
+			* @param format c-strings to log, put the params into the first using: "%s", 2. param is set as 1. %s, 3. param is set as 2. %s, and so on
+			*/
 			static void log(const char *format, ...);
+
+			/**
+			* Logs information through wcout
+			* @param str The c-string to log
+			*/
 			static void logw(const char *str);
 	};
 }

+ 7 - 4
Core/Contents/Source/PolyLogger.cpp

@@ -21,6 +21,9 @@
 */
 
 #include "PolyLogger.h"
+#ifdef _MSC_VER
+#include <windows.h>
+#endif
 #include <stdio.h>
 #include <stdarg.h>
 #include <string>
@@ -60,18 +63,18 @@ void Logger::log(const char *format, ...) {
 	vfprintf(stderr, format, args);
 	va_end(args);
 
-#ifdef MSVC
+#ifdef _MSC_VER
 #ifdef _DEBUG
-	
+
 	char buffer[4096];
 	va_start(args, format);
 	vsprintf(buffer, format, args);
 	va_end(args);
 
-	WCHAR wbuf[4096];
+	wchar_t wbuf[4096];
 	int i = 0;
 	while(buffer[i] != '\0') {
-		wbuf[i] = (WCHAR)buffer[i];
+		wbuf[i] = (wchar_t)buffer[i];
 		++i;
 	}
 	wbuf[i] = L'\0';