|
22 | 22 | #include "lldb/Utility/StreamString.h"
|
23 | 23 | #include "lldb/Utility/StructuredData.h"
|
24 | 24 |
|
25 |
| -#include "llvm/ADT/SmallVector.h" |
26 | 25 | #include "llvm/ADT/StringRef.h"
|
27 | 26 | #include "llvm/Support/ConvertUTF.h"
|
28 |
| -#include "llvm/Support/ManagedStatic.h" |
29 | 27 |
|
30 | 28 | // Windows includes
|
31 | 29 | #include <tlhelp32.h>
|
@@ -308,52 +306,28 @@ Environment Host::GetEnvironment() {
|
308 | 306 | return env;
|
309 | 307 | }
|
310 | 308 |
|
311 |
| -/// Manages the lifecycle of a Windows Event's Source. |
312 |
| -/// The destructor will call DeregisterEventSource. |
313 |
| -/// This class is meant to be used with \ref llvm::ManagedStatic. |
314 |
| -class WindowsEventLog { |
315 |
| -public: |
316 |
| - WindowsEventLog() : handle(RegisterEventSource(nullptr, L"lldb")) {} |
317 |
| - |
318 |
| - ~WindowsEventLog() { |
319 |
| - if (handle) |
320 |
| - DeregisterEventSource(handle); |
321 |
| - } |
322 |
| - |
323 |
| - HANDLE GetHandle() const { return handle; } |
324 |
| - |
325 |
| -private: |
326 |
| - HANDLE handle; |
327 |
| -}; |
328 |
| - |
329 |
| -static llvm::ManagedStatic<WindowsEventLog> event_log; |
330 |
| - |
331 | 309 | void Host::SystemLog(Severity severity, llvm::StringRef message) {
|
332 | 310 | if (message.empty())
|
333 | 311 | return;
|
334 | 312 |
|
335 |
| - HANDLE h = event_log->GetHandle(); |
336 |
| - if (!h) |
337 |
| - return; |
338 |
| - |
339 |
| - llvm::SmallVector<wchar_t, 1> argsUTF16; |
340 |
| - if (UTF8ToUTF16(message.str(), argsUTF16)) |
341 |
| - return; |
| 313 | + std::string log_msg; |
| 314 | + llvm::raw_string_ostream stream(log_msg); |
342 | 315 |
|
343 |
| - WORD event_type; |
344 | 316 | switch (severity) {
|
345 | 317 | case lldb::eSeverityWarning:
|
346 |
| - event_type = EVENTLOG_WARNING_TYPE; |
| 318 | + stream << "[Warning] "; |
347 | 319 | break;
|
348 | 320 | case lldb::eSeverityError:
|
349 |
| - event_type = EVENTLOG_ERROR_TYPE; |
| 321 | + stream << "[Error] "; |
350 | 322 | break;
|
351 | 323 | case lldb::eSeverityInfo:
|
352 | 324 | default:
|
353 |
| - event_type = EVENTLOG_INFORMATION_TYPE; |
| 325 | + stream << "[Info] "; |
| 326 | + break; |
354 | 327 | }
|
355 | 328 |
|
356 |
| - LPCWSTR messages[1] = {argsUTF16.data()}; |
357 |
| - ReportEventW(h, event_type, 0, 0, nullptr, std::size(messages), 0, messages, |
358 |
| - nullptr); |
| 329 | + stream << message; |
| 330 | + stream.flush(); |
| 331 | + |
| 332 | + OutputDebugStringA(log_msg.c_str()); |
359 | 333 | }
|
0 commit comments