Mercurial > mm7
annotate Log.cpp @ 2327:5e4d90305d06
EventCastSpell removing duplicate code for handling empty pObjectList->pObjects array or not finding the correct value + moving everything into the main switch
author | Grumpy7 |
---|---|
date | Tue, 01 Apr 2014 23:20:15 +0200 |
parents | aff7a7b072b7 |
children | f4af3b203f65 |
rev | line source |
---|---|
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
1578
diff
changeset
|
1 #define _CRT_SECURE_NO_WARNINGS |
0 | 2 #include "Log.h" |
3 | |
4 #include <stdio.h> | |
5 #include <windows.h> | |
1481 | 6 |
0 | 7 HANDLE hStdOut = nullptr; |
8 | |
9 | |
10 void Log::Initialize() | |
11 { | |
12 if (AllocConsole()) | |
13 hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); | |
14 } | |
15 | |
16 | |
17 void Log::Warning(const wchar_t *pFormat, ...) | |
18 { | |
19 if (!hStdOut) | |
20 return; | |
21 | |
22 va_list args; | |
1566 | 23 wchar_t pMsg[8192]; |
0 | 24 |
25 va_start(args, pFormat); | |
1566 | 26 vswprintf_s(pMsg, 8192, pFormat, args); |
0 | 27 va_end(args); |
28 | |
1566 | 29 DWORD w; |
1578
56cc81b1ed49
workaround for crash on startup
Beri Levi berilevi@gmail.com
parents:
1566
diff
changeset
|
30 WriteConsoleW(hStdOut, pMsg, lstrlenW(pMsg), &w, nullptr); |
56cc81b1ed49
workaround for crash on startup
Beri Levi berilevi@gmail.com
parents:
1566
diff
changeset
|
31 WriteConsoleW(hStdOut, L"\r\n", 2, &w, nullptr); |
0 | 32 } |
1297 | 33 //----- (004BE386) -------------------------------------------------------- |
34 void __fastcall log_error(const char *pMessage) | |
35 { | |
36 const char *v1; // edi@1 | |
37 FILE *f; // eax@1 | |
38 FILE *v3; // esi@1 | |
39 | |
40 v1 = pMessage; | |
41 f = fopen("errorlog.txt", "a"); | |
42 v3 = f; | |
43 if ( f ) | |
44 { | |
45 fprintf(f, "%s\n", v1); | |
46 fclose(v3); | |
47 fflush(v3); | |
48 } | |
49 } |