[Lldb-commits] [lldb] [lldb] Log to system log instead of stderr from Host::SystemLog (PR #83366)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 28 21:09:32 PST 2024


================
@@ -89,8 +89,17 @@ using namespace lldb;
 using namespace lldb_private;
 
 #if !defined(__APPLE__)
+#if !defined(_WIN32)
+#include <syslog.h>
+void Host::SystemLog(llvm::StringRef message) {
+  openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);
+  syslog(LOG_INFO, "%s", message.data());
+  closelog();
----------------
JDevlieghere wrote:

Thanks Jordan. I've moved the `openlog` behind a `call_once` flag and omitted the `closelog`. 

I considered executing `syslog` on the debugger's thread pool but the fact that Core depends on Host means that would be a layering violation and there's no good place to manage the futures something like `std::async` would return. 

Right now the system log function is only used for the corresponding log handler which is purely opt-in. I do plan to use it in other places (e.g. the debugger diagnostics) but even then I expect it to be relatively low traffic. 

https://github.com/llvm/llvm-project/pull/83366


More information about the lldb-commits mailing list