annotate Log.cpp @ 1481:0356a84be1cf

uses std funcs instead
author Beri Levi berilevi@gmail.com
date Wed, 28 Aug 2013 23:47:39 +0300
parents 5450af4f57ef
children 1e5086f7d401
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;
Ritor1
parents:
diff changeset
22
Ritor1
parents:
diff changeset
23 va_start(args, pFormat);
1481
0356a84be1cf uses std funcs instead
Beri Levi berilevi@gmail.com
parents: 1297
diff changeset
24 vwprintf_s(pFormat, args);
0
Ritor1
parents:
diff changeset
25 va_end(args);
1481
0356a84be1cf uses std funcs instead
Beri Levi berilevi@gmail.com
parents: 1297
diff changeset
26 puts("\r\n");
0
Ritor1
parents:
diff changeset
27
Ritor1
parents:
diff changeset
28 }
Ritor1
parents:
diff changeset
29
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
30 //----- (004BE386) --------------------------------------------------------
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
31 void __fastcall log_error(const char *pMessage)
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
32 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
33 const char *v1; // edi@1
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
34 FILE *f; // eax@1
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
35 FILE *v3; // esi@1
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
36
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
37 v1 = pMessage;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
38 f = fopen("errorlog.txt", "a");
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
39 v3 = f;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
40 if ( f )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
41 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
42 fprintf(f, "%s\n", v1);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
43 fclose(v3);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
44 fflush(v3);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
45 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 0
diff changeset
46 }