Mercurial > mm7
comparison Engine/Log.cpp @ 2499:68cdef6879a0
engine folder
author | Ritor1 |
---|---|
date | Fri, 19 Sep 2014 02:57:42 +0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2498:92eeeb5200f2 | 2499:68cdef6879a0 |
---|---|
1 #define _CRTDBG_MAP_ALLOC | |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
5 #define _CRT_SECURE_NO_WARNINGS | |
6 #include "Log.h" | |
7 | |
8 #include <stdio.h> | |
9 #include <windows.h> | |
10 | |
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; | |
27 wchar_t pMsg[8192]; | |
28 | |
29 va_start(args, pFormat); | |
30 vswprintf_s(pMsg, 8192, pFormat, args); | |
31 va_end(args); | |
32 | |
33 DWORD w; | |
34 WriteConsoleW(hStdOut, pMsg, lstrlenW(pMsg), &w, nullptr); | |
35 WriteConsoleW(hStdOut, L"\r\n", 2, &w, nullptr); | |
36 } | |
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 } |