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