annotate Log.cpp @ 2103:2318216e5206

stru_AA1058[i]._494836() continue
author Ritor1
date Tue, 17 Dec 2013 23:11:49 +0600
parents 56cc81b1ed49
children aff7a7b072b7
rev   line source
0
Ritor1
parents:
diff changeset
1 #include "Log.h"
Ritor1
parents:
diff changeset
2
Ritor1
parents:
diff changeset
3 #include <stdio.h>
Ritor1
parents:
diff changeset
4 #include <windows.h>
1481
0356a84be1cf uses std funcs instead
Beri Levi berilevi@gmail.com
parents: 1297
diff changeset
5
0
Ritor1
parents:
diff changeset
6 HANDLE hStdOut = nullptr;
Ritor1
parents:
diff changeset
7
Ritor1
parents:
diff changeset
8
Ritor1
parents:
diff changeset
9 void Log::Initialize()
Ritor1
parents:
diff changeset
10 {
Ritor1
parents:
diff changeset
11 if (AllocConsole())
Ritor1
parents:
diff changeset
12 hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
Ritor1
parents:
diff changeset
13 }
Ritor1
parents:
diff changeset
14
Ritor1
parents:
diff changeset
15
Ritor1
parents:
diff changeset
16 void Log::Warning(const wchar_t *pFormat, ...)
Ritor1
parents:
diff changeset
17 {
Ritor1
parents:
diff changeset
18 if (!hStdOut)
Ritor1
parents:
diff changeset
19 return;
Ritor1
parents:
diff changeset
20
Ritor1
parents:
diff changeset
21 va_list args;
1566
1e5086f7d401 undoing 1481
Grumpy7
parents: 1481
diff changeset
22 wchar_t pMsg[8192];
0
Ritor1
parents:
diff changeset
23
Ritor1
parents:
diff changeset
24 va_start(args, pFormat);
1566
1e5086f7d401 undoing 1481
Grumpy7
parents: 1481
diff changeset
25 vswprintf_s(pMsg, 8192, pFormat, args);
0
Ritor1
parents:
diff changeset
26 va_end(args);
Ritor1
parents:
diff changeset
27
1566
1e5086f7d401 undoing 1481
Grumpy7
parents: 1481
diff changeset
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
Ritor1
parents:
diff changeset
31 }
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
32 //----- (004BE386) --------------------------------------------------------
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
33 void __fastcall log_error(const char *pMessage)
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
34 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
35 const char *v1; // edi@1
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
36 FILE *f; // eax@1
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
37 FILE *v3; // esi@1
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
38
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
39 v1 = pMessage;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
40 f = fopen("errorlog.txt", "a");
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
41 v3 = f;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
42 if ( f )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
43 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
44 fprintf(f, "%s\n", v1);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
45 fclose(v3);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
46 fflush(v3);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
47 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
48 }