================ @@ -308,52 +306,24 @@ Environment Host::GetEnvironment() { return env; } -/// Manages the lifecycle of a Windows Event's Source. -/// The destructor will call DeregisterEventSource. -/// This class is meant to be used with \ref llvm::ManagedStatic. -class WindowsEventLog { -public: - WindowsEventLog() : handle(RegisterEventSource(nullptr, L"lldb")) {} - - ~WindowsEventLog() { - if (handle) - DeregisterEventSource(handle); - } - - HANDLE GetHandle() const { return handle; } - -private: - HANDLE handle; -}; - -static llvm::ManagedStatic<WindowsEventLog> event_log; - void Host::SystemLog(Severity severity, llvm::StringRef message) { if (message.empty()) return; - HANDLE h = event_log->GetHandle(); - if (!h) - return; - - llvm::SmallVector<wchar_t, 1> argsUTF16; - if (UTF8ToUTF16(message.str(), argsUTF16)) - return; - - WORD event_type; + std::string log_prefix; switch (severity) { case lldb::eSeverityWarning: - event_type = EVENTLOG_WARNING_TYPE; + log_prefix = "[Warning] "; break; case lldb::eSeverityError: - event_type = EVENTLOG_ERROR_TYPE; + log_prefix = "[Error] "; break; case lldb::eSeverityInfo: default: - event_type = EVENTLOG_INFORMATION_TYPE; + log_prefix = "[Info] "; + break; } - LPCWSTR messages[1] = {argsUTF16.data()}; - ReportEventW(h, event_type, 0, 0, nullptr, std::size(messages), 0, messages, - nullptr); + std::string final_message = log_prefix + message.str(); + OutputDebugStringA(final_message.c_str()); ---------------- compnerd wrote:
I'm half tempted to say that this should be `(Twine{log_prefix} + message).str().c_str()` instead of the `std::string` and then calling `OutputDebugStringA`. https://github.com/llvm/llvm-project/pull/156474 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits