Index: system_logging.cc |
diff --git a/system_logging.cc b/system_logging.cc |
index 578951418500d2f2d7782f327a1d13fe3bdf1418..543ef78ff29279ccaa1e15a1a344e36935ccf195 100644 |
--- a/system_logging.cc |
+++ b/system_logging.cc |
@@ -2,12 +2,14 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include <stdarg.h> |
+#include "crash-reporter/system_logging.h" |
+ |
#include <syslog.h> |
-#include "crash-reporter/system_logging.h" |
+#include "base/stringprintf.h" |
std::string SystemLoggingImpl::identity_; |
+std::string *SystemLoggingImpl::accumulator_; |
SystemLoggingImpl::SystemLoggingImpl() { |
} |
@@ -22,23 +24,33 @@ void SystemLoggingImpl::Initialize(const char *ident) { |
openlog(identity_.c_str(), LOG_PID, LOG_USER); |
} |
+void SystemLoggingImpl::LogWithLevel(int level, const char *format, |
+ va_list arg_list) { |
+ std::string message = StringPrintV(format, arg_list); |
+ syslog(level, "%s", message.c_str()); |
+ if (accumulator_ != NULL) { |
+ accumulator_->append(message); |
+ accumulator_->push_back('\n'); |
+ } |
+} |
+ |
void SystemLoggingImpl::LogInfo(const char *format, ...) { |
va_list vl; |
va_start(vl, format); |
- vsyslog(LOG_INFO, format, vl); |
+ LogWithLevel(LOG_INFO, format, vl); |
va_end(vl); |
} |
void SystemLoggingImpl::LogWarning(const char *format, ...) { |
va_list vl; |
va_start(vl, format); |
- vsyslog(LOG_WARNING, format, vl); |
+ LogWithLevel(LOG_WARNING, format, vl); |
va_end(vl); |
} |
void SystemLoggingImpl::LogError(const char *format, ...) { |
va_list vl; |
va_start(vl, format); |
- vsyslog(LOG_ERR, format, vl); |
+ LogWithLevel(LOG_ERR, format, vl); |
va_end(vl); |
} |