| Index: remoting/host/logging_mac.cc
|
| diff --git a/remoting/host/logging_mac.cc b/remoting/host/logging_mac.cc
|
| index 39e007d409b528d5fe9b38307afe9ebc84dd8d94..ae6870c728334553ee03107304c4da3ad988e044 100644
|
| --- a/remoting/host/logging_mac.cc
|
| +++ b/remoting/host/logging_mac.cc
|
| @@ -33,12 +33,19 @@ typedef base::ScopedGeneric<aslmsg, ScopedAslMsgTraits> ScopedAslMsg;
|
| // Logging message handler that writes to syslog.
|
| // The log can be obtained by running the following in a terminal:
|
| // syslog -k Facility org.chromium.chromoting
|
| -bool LogMessageToAsl(
|
| - logging::LogSeverity severity,
|
| - const char* file,
|
| - int line,
|
| - size_t message_start,
|
| - const std::string& message) {
|
| +class LogMessageListener : logging::LogMessageListener {
|
| + void OnMessage(logging::LogSeverity severity,
|
| + const char* file,
|
| + int line,
|
| + size_t message_start,
|
| + const std::string& message) override;
|
| +};
|
| +
|
| +void LogMessageListener::OnMessage(logging::LogSeverity severity,
|
| + const char* file,
|
| + int line,
|
| + size_t message_start,
|
| + const std::string& message) {
|
| int level;
|
| switch(severity) {
|
| case logging::LOG_INFO:
|
| @@ -60,29 +67,28 @@ bool LogMessageToAsl(
|
|
|
| ScopedAslMsg asl_message(asl_new(ASL_TYPE_MSG));
|
| if (!asl_message.is_valid())
|
| - return false;
|
| + return;
|
|
|
| if (asl_set(asl_message.get(), ASL_KEY_FACILITY,
|
| kChromotingLoggingFacility) != 0)
|
| - return false;
|
| + return;
|
|
|
| if (asl_set(asl_message.get(), ASL_KEY_LEVEL,
|
| base::IntToString(level).c_str()) != 0)
|
| - return false;
|
| + return;
|
|
|
| // Restrict read access to the message to root and the current user.
|
| if (asl_set(asl_message.get(), ASL_KEY_READ_UID,
|
| base::IntToString(geteuid()).c_str()) != 0)
|
| - return false;
|
| + return;
|
|
|
| if (asl_set(asl_message.get(), ASL_KEY_MSG,
|
| message.c_str() + message_start) != 0)
|
| - return false;
|
| + return;
|
|
|
| asl_send(nullptr, asl_message.get());
|
|
|
| // Don't prevent message from being logged by traditional means.
|
| - return false;
|
| }
|
|
|
| } // namespace
|
| @@ -94,7 +100,9 @@ void InitHostLogging() {
|
| logging::InitLogging(settings);
|
|
|
| // Write logs to syslog as well.
|
| - logging::SetLogMessageHandler(LogMessageToAsl);
|
| + // Intentionally leak the listener
|
| + auto* listener = new LogMessageListener();
|
| + CHECK(listener);
|
| }
|
|
|
| } // namespace remoting
|
|
|