annotate Log.cpp @ 6:82f81d5b7221

Слияние
author Серик@ПончиК
date Tue, 09 Oct 2012 20:00:24 +0600
parents 8b8875f5b359
children
rev   line source
0
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
1 #include "Log.h"
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
2
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
3
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
4 #include <stdio.h>
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
5 #include <windows.h>
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
6 HANDLE hStdOut = nullptr;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
7
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
8
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
9
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
10
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
11 void Log::Initialize()
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
12 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
13 if (AllocConsole())
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
14 hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
15 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
16
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
17
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
18 void Log::Warning(const wchar_t *pFormat, ...)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
19 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
20 if (!hStdOut)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
21 return;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
22
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
23 va_list args;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
24 wchar_t pMsg[8192];
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
25
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
26 va_start(args, pFormat);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
27 vswprintf_s(pMsg, 8192, pFormat, args);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
28 va_end(args);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
29
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
30 DWORD w;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
31 WriteConsole(hStdOut, pMsg, lstrlenW(pMsg), &w, nullptr);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
32 WriteConsole(hStdOut, L"\r\n", 2, &w, nullptr);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
33 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
34