comparison Log.cpp @ 0:8b8875f5b359

Initial commit
author Nomad
date Fri, 05 Oct 2012 16:07:14 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8b8875f5b359
1 #include "Log.h"
2
3
4 #include <stdio.h>
5 #include <windows.h>
6 HANDLE hStdOut = nullptr;
7
8
9
10
11 void Log::Initialize()
12 {
13 if (AllocConsole())
14 hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
15 }
16
17
18 void Log::Warning(const wchar_t *pFormat, ...)
19 {
20 if (!hStdOut)
21 return;
22
23 va_list args;
24 wchar_t pMsg[8192];
25
26 va_start(args, pFormat);
27 vswprintf_s(pMsg, 8192, pFormat, args);
28 va_end(args);
29
30 DWORD w;
31 WriteConsole(hStdOut, pMsg, lstrlenW(pMsg), &w, nullptr);
32 WriteConsole(hStdOut, L"\r\n", 2, &w, nullptr);
33 }
34