File tree Expand file tree Collapse file tree 2 files changed +50
-6
lines changed Expand file tree Collapse file tree 2 files changed +50
-6
lines changed Original file line number Diff line number Diff line change @@ -88,12 +88,27 @@ int __pthread_fchdir(int fildes);
88
88
using namespace lldb ;
89
89
using namespace lldb_private ;
90
90
91
- #if !defined(__APPLE__)
92
- // The system log is currently only meaningful on Darwin, where this means
93
- // os_log. The meaning of a "system log" isn't as clear on other platforms, and
94
- // therefore we don't providate a default implementation. Vendors are free to
95
- // to implement this function if they have a use for it.
96
- void Host::SystemLog (Severity severity, llvm::StringRef message) {}
91
+ #if !defined(__APPLE__) && !defined(_WIN32)
92
+ #include < syslog.h>
93
+ void Host::SystemLog (Severity severity, llvm::StringRef message) {
94
+ static llvm::once_flag g_openlog_once;
95
+ llvm::call_once (g_openlog_once, [] {
96
+ openlog (" lldb" , LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);
97
+ });
98
+ int level = LOG_DEBUG;
99
+ switch (severity) {
100
+ case lldb::eSeverityInfo:
101
+ level = LOG_INFO;
102
+ break ;
103
+ case lldb::eSeverityWarning:
104
+ level = LOG_WARNING;
105
+ break ;
106
+ case lldb::eSeverityError:
107
+ level = LOG_ERR;
108
+ break ;
109
+ }
110
+ syslog (level, " %s" , message.data ());
111
+ }
97
112
#endif
98
113
99
114
#if !defined(__APPLE__) && !defined(_WIN32)
Original file line number Diff line number Diff line change 22
22
#include " lldb/Utility/StreamString.h"
23
23
#include " lldb/Utility/StructuredData.h"
24
24
25
+ #include " llvm/ADT/StringRef.h"
25
26
#include " llvm/Support/ConvertUTF.h"
26
27
27
28
// Windows includes
30
31
using namespace lldb ;
31
32
using namespace lldb_private ;
32
33
34
+ using llvm::sys::windows::UTF8ToUTF16;
35
+
33
36
static bool GetTripleForProcess (const FileSpec &executable,
34
37
llvm::Triple &triple) {
35
38
// Open the PE File as a binary file, and parse just enough information to
@@ -302,3 +305,29 @@ Environment Host::GetEnvironment() {
302
305
}
303
306
return env;
304
307
}
308
+
309
+ void Host::SystemLog (Severity severity, llvm::StringRef message) {
310
+ if (message.empty ())
311
+ return ;
312
+
313
+ std::string log_msg;
314
+ llvm::raw_string_ostream stream (log_msg);
315
+
316
+ switch (severity) {
317
+ case lldb::eSeverityWarning:
318
+ stream << " [Warning] " ;
319
+ break ;
320
+ case lldb::eSeverityError:
321
+ stream << " [Error] " ;
322
+ break ;
323
+ case lldb::eSeverityInfo:
324
+ default :
325
+ stream << " [Info] " ;
326
+ break ;
327
+ }
328
+
329
+ stream << message;
330
+ stream.flush ();
331
+
332
+ OutputDebugStringA (log_msg.c_str ());
333
+ }
You can’t perform that action at this time.
0 commit comments