Skip to content

Commit d36c314

Browse files
authored
revert: explicitly write wide string characters to console (#193)
* revert: explicitly write wide string characters to console * update version number
1 parent 6c30340 commit d36c314

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

LogMonitor/src/LogMonitor/LogWriter.h

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@ class LogWriter final
1313
InitializeSRWLock(&m_stdoutLock);
1414

1515
DWORD dwMode;
16-
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
1716

18-
if (!GetConsoleMode(hConsole, &dwMode)) {
17+
if (!GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), &dwMode))
18+
{
1919
m_isConsole = false;
2020
}
21-
else {
22-
m_isConsole = true;
23-
}
21+
22+
m_isConsole = true;
2423

2524
_setmode(_fileno(stdout), _O_U8TEXT);
2625
};
@@ -30,7 +29,6 @@ class LogWriter final
3029
private:
3130
SRWLOCK m_stdoutLock;
3231
bool m_isConsole;
33-
HANDLE hConsole;
3432

3533
void FlushStdOut()
3634
{
@@ -66,14 +64,7 @@ public :
6664
{
6765
AcquireSRWLockExclusive(&m_stdoutLock);
6866

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());
7768
FlushStdOut();
7869

7970
ReleaseSRWLockExclusive(&m_stdoutLock);
@@ -85,14 +76,7 @@ public :
8576
{
8677
AcquireSRWLockExclusive(&m_stdoutLock);
8778

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());
9680
FlushStdOut();
9781

9882
ReleaseSRWLockExclusive(&m_stdoutLock);

LogMonitor/src/LogMonitor/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#define LM_MAJORNUMBER 2
1010
#define LM_MINORNUMBER 1
11-
#define LM_PATCHNUMBER 0
11+
#define LM_PATCHNUMBER 1
1212
// removed in support of semantic versioning - https://semver.org
1313
// major.minor.patch
1414
// #define LM_BUILDMINORVERSION 0

0 commit comments

Comments
 (0)