Mercurial > mm7
annotate Log.cpp @ 2187:9856c2f8f918
CastSpell continue
author | Ritor1 |
---|---|
date | Tue, 28 Jan 2014 17:25:58 +0600 |
parents | 56cc81b1ed49 |
children | aff7a7b072b7 |
rev | line source |
---|---|
0 | 1 #include "Log.h" |
2 | |
3 #include <stdio.h> | |
4 #include <windows.h> | |
1481 | 5 |
0 | 6 HANDLE hStdOut = nullptr; |
7 | |
8 | |
9 void Log::Initialize() | |
10 { | |
11 if (AllocConsole()) | |
12 hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); | |
13 } | |
14 | |
15 | |
16 void Log::Warning(const wchar_t *pFormat, ...) | |
17 { | |
18 if (!hStdOut) | |
19 return; | |
20 | |
21 va_list args; | |
1566 | 22 wchar_t pMsg[8192]; |
0 | 23 |
24 va_start(args, pFormat); | |
1566 | 25 vswprintf_s(pMsg, 8192, pFormat, args); |
0 | 26 va_end(args); |
27 | |
1566 | 28 DWORD w; |
1578
56cc81b1ed49
workaround for crash on startup
Beri Levi berilevi@gmail.com
parents:
1566
diff
changeset
|
29 WriteConsoleW(hStdOut, pMsg, lstrlenW(pMsg), &w, nullptr); |
56cc81b1ed49
workaround for crash on startup
Beri Levi berilevi@gmail.com
parents:
1566
diff
changeset
|
30 WriteConsoleW(hStdOut, L"\r\n", 2, &w, nullptr); |
0 | 31 } |
1297 | 32 //----- (004BE386) -------------------------------------------------------- |
33 void __fastcall log_error(const char *pMessage) | |
34 { | |
35 const char *v1; // edi@1 | |
36 FILE *f; // eax@1 | |
37 FILE *v3; // esi@1 | |
38 | |
39 v1 = pMessage; | |
40 f = fopen("errorlog.txt", "a"); | |
41 v3 = f; | |
42 if ( f ) | |
43 { | |
44 fprintf(f, "%s\n", v1); | |
45 fclose(v3); | |
46 fflush(v3); | |
47 } | |
48 } |