Skip to content

Backport always-on log changes #10484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 5 additions & 34 deletions lldb/source/Host/common/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,40 +89,11 @@ using namespace lldb;
using namespace lldb_private;

#if !defined(__APPLE__)
#if !defined(_WIN32)
#include <syslog.h>
void Host::SystemLog(Severity severity, llvm::StringRef message) {
static llvm::once_flag g_openlog_once;
llvm::call_once(g_openlog_once, [] {
openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);
});
int level = LOG_DEBUG;
switch (severity) {
case lldb::eSeverityInfo:
level = LOG_INFO;
break;
case lldb::eSeverityWarning:
level = LOG_WARNING;
break;
case lldb::eSeverityError:
level = LOG_ERR;
break;
}
syslog(level, "%s", message.data());
}
#else
void Host::SystemLog(Severity severity, llvm::StringRef message) {
switch (severity) {
case lldb::eSeverityInfo:
case lldb::eSeverityWarning:
llvm::outs() << message;
break;
case lldb::eSeverityError:
llvm::errs() << message;
break;
}
}
#endif
// The system log is currently only meaningful on Darwin, where this means
// os_log. The meaning of a "system log" isn't as clear on other platforms, and
// therefore we don't providate a default implementation. Vendors are free to
// to implement this function if they have a use for it.
void Host::SystemLog(Severity severity, llvm::StringRef message) {}
#endif

#if !defined(__APPLE__) && !defined(_WIN32)
Expand Down