diff Log.cpp @ 0:8b8875f5b359

Initial commit
author Nomad
date Fri, 05 Oct 2012 16:07:14 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Log.cpp	Fri Oct 05 16:07:14 2012 +0200
@@ -0,0 +1,34 @@
+#include "Log.h"
+
+
+#include <stdio.h>
+#include <windows.h>
+HANDLE hStdOut = nullptr;
+
+
+
+
+void Log::Initialize()
+{
+  if (AllocConsole())
+    hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
+}
+
+
+void Log::Warning(const wchar_t *pFormat, ...)
+{
+  if (!hStdOut)
+    return;
+
+  va_list args;
+  wchar_t pMsg[8192];
+
+  va_start(args, pFormat);
+  vswprintf_s(pMsg, 8192, pFormat, args);
+  va_end(args);
+
+  DWORD w;
+  WriteConsole(hStdOut, pMsg, lstrlenW(pMsg), &w, nullptr);
+  WriteConsole(hStdOut, L"\r\n", 2, &w, nullptr);
+}
+