annotate Log.cpp @ 1456:5c95f2246c2a

TE mostly working
author Gloval
date Wed, 14 Aug 2013 00:40:23 +0400
parents 5450af4f57ef
children 0356a84be1cf
rev   line source
0
Ritor1
parents:
diff changeset
1 #include "Log.h"
Ritor1
parents:
diff changeset
2
Ritor1
parents:
diff changeset
3
Ritor1
parents:
diff changeset
4 #include <stdio.h>
Ritor1
parents:
diff changeset
5 #include <windows.h>
Ritor1
parents:
diff changeset
6 HANDLE hStdOut = nullptr;
Ritor1
parents:
diff changeset
7
Ritor1
parents:
diff changeset
8
Ritor1
parents:
diff changeset
9
Ritor1
parents:
diff changeset
10
Ritor1
parents:
diff changeset
11 void Log::Initialize()
Ritor1
parents:
diff changeset
12 {
Ritor1
parents:
diff changeset
13 if (AllocConsole())
Ritor1
parents:
diff changeset
14 hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
Ritor1
parents:
diff changeset
15 }
Ritor1
parents:
diff changeset
16
Ritor1
parents:
diff changeset
17
Ritor1
parents:
diff changeset
18 void Log::Warning(const wchar_t *pFormat, ...)
Ritor1
parents:
diff changeset
19 {
Ritor1
parents:
diff changeset
20 if (!hStdOut)
Ritor1
parents:
diff changeset
21 return;
Ritor1
parents:
diff changeset
22
Ritor1
parents:
diff changeset
23 va_list args;
Ritor1
parents:
diff changeset
24 wchar_t pMsg[8192];
Ritor1
parents:
diff changeset
25
Ritor1
parents:
diff changeset
26 va_start(args, pFormat);
Ritor1
parents:
diff changeset
27 vswprintf_s(pMsg, 8192, pFormat, args);
Ritor1
parents:
diff changeset
28 va_end(args);
Ritor1
parents:
diff changeset
29
Ritor1
parents:
diff changeset
30 DWORD w;
Ritor1
parents:
diff changeset
31 WriteConsole(hStdOut, pMsg, lstrlenW(pMsg), &w, nullptr);
Ritor1
parents:
diff changeset
32 WriteConsole(hStdOut, L"\r\n", 2, &w, nullptr);
Ritor1
parents:
diff changeset
33 }
Ritor1
parents:
diff changeset
34
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
35 //----- (004BE386) --------------------------------------------------------
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
36 void __fastcall log_error(const char *pMessage)
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
37 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
38 const char *v1; // edi@1
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
39 FILE *f; // eax@1
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
40 FILE *v3; // esi@1
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
41
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
42 v1 = pMessage;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
43 f = fopen("errorlog.txt", "a");
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
44 v3 = f;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
45 if ( f )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
46 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
47 fprintf(f, "%s\n", v1);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
48 fclose(v3);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
49 fflush(v3);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
50 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
51 }