Mercurial > mm7
comparison Log.cpp @ 0:9c0607679772
init
author | Ritor1 |
---|---|
date | Sat, 12 Jan 2013 09:45:18 +0600 |
parents | |
children | 5450af4f57ef |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:9c0607679772 |
---|---|
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 |