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);
8888using namespace lldb ;
8989using namespace lldb_private ;
9090
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+ }
97112#endif
98113
99114#if !defined(__APPLE__) && !defined(_WIN32)
Original file line number Diff line number Diff line change 2222#include " lldb/Utility/StreamString.h"
2323#include " lldb/Utility/StructuredData.h"
2424
25+ #include " llvm/ADT/StringRef.h"
2526#include " llvm/Support/ConvertUTF.h"
2627
2728// Windows includes
3031using namespace lldb ;
3132using namespace lldb_private ;
3233
34+ using llvm::sys::windows::UTF8ToUTF16;
35+
3336static bool GetTripleForProcess (const FileSpec &executable,
3437 llvm::Triple &triple) {
3538 // Open the PE File as a binary file, and parse just enough information to
@@ -302,3 +305,29 @@ Environment Host::GetEnvironment() {
302305 }
303306 return env;
304307}
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