@@ -13,14 +13,13 @@ class LogWriter final
13
13
InitializeSRWLock (&m_stdoutLock);
14
14
15
15
DWORD dwMode;
16
- hConsole = GetStdHandle (STD_OUTPUT_HANDLE);
17
16
18
- if (!GetConsoleMode (hConsole, &dwMode)) {
17
+ if (!GetConsoleMode (GetStdHandle (STD_OUTPUT_HANDLE), &dwMode))
18
+ {
19
19
m_isConsole = false ;
20
20
}
21
- else {
22
- m_isConsole = true ;
23
- }
21
+
22
+ m_isConsole = true ;
24
23
25
24
_setmode (_fileno (stdout), _O_U8TEXT);
26
25
};
@@ -30,7 +29,6 @@ class LogWriter final
30
29
private:
31
30
SRWLOCK m_stdoutLock;
32
31
bool m_isConsole;
33
- HANDLE hConsole;
34
32
35
33
void FlushStdOut ()
36
34
{
@@ -66,14 +64,7 @@ public :
66
64
{
67
65
AcquireSRWLockExclusive (&m_stdoutLock);
68
66
69
- std::wstring output = LogMessage + L" \n " ;
70
-
71
- if (m_isConsole) {
72
- WriteConsoleW (hConsole, output.c_str (), wcslen (output.c_str ()), NULL , NULL );
73
- } else {
74
- wprintf (output.c_str ());
75
- }
76
-
67
+ wprintf (L" %s\n " , LogMessage.c_str ());
77
68
FlushStdOut ();
78
69
79
70
ReleaseSRWLockExclusive (&m_stdoutLock);
@@ -85,14 +76,7 @@ public :
85
76
{
86
77
AcquireSRWLockExclusive (&m_stdoutLock);
87
78
88
- std::wstring output = LogMessage + L" \n " ;
89
-
90
- if (m_isConsole) {
91
- WriteConsoleW (hConsole, output.c_str (), wcslen (output.c_str ()), NULL , NULL );
92
- } else {
93
- wprintf (output.c_str ());
94
- }
95
-
79
+ wprintf (L" %s\n " , LogMessage.c_str ());
96
80
FlushStdOut ();
97
81
98
82
ReleaseSRWLockExclusive (&m_stdoutLock);
0 commit comments