Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(663)

Side by Side Diff: system_logging.cc

Issue 6297004: crash-reporter: Add diagnostics to help diagnose failures in the wild (Closed) Base URL: http://git.chromium.org/git/crash-reporter.git@master
Patch Set: clarify Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdarg.h> 5 #include "crash-reporter/system_logging.h"
6
6 #include <syslog.h> 7 #include <syslog.h>
7 8
8 #include "crash-reporter/system_logging.h" 9 #include "base/stringprintf.h"
9 10
10 std::string SystemLoggingImpl::identity_; 11 std::string SystemLoggingImpl::identity_;
12 std::string *SystemLoggingImpl::accumulator_;
11 13
12 SystemLoggingImpl::SystemLoggingImpl() { 14 SystemLoggingImpl::SystemLoggingImpl() {
13 } 15 }
14 16
15 SystemLoggingImpl::~SystemLoggingImpl() { 17 SystemLoggingImpl::~SystemLoggingImpl() {
16 } 18 }
17 19
18 void SystemLoggingImpl::Initialize(const char *ident) { 20 void SystemLoggingImpl::Initialize(const char *ident) {
petkov 2011/01/18 19:18:20 Maybe reset accumulator_ to NULL so that Initializ
19 // Man page does not specify if openlog copies its string or assumes 21 // Man page does not specify if openlog copies its string or assumes
20 // the pointer is always valid, so make its scope global. 22 // the pointer is always valid, so make its scope global.
21 identity_ = ident; 23 identity_ = ident;
22 openlog(identity_.c_str(), LOG_PID, LOG_USER); 24 openlog(identity_.c_str(), LOG_PID, LOG_USER);
23 } 25 }
24 26
27 void SystemLoggingImpl::LogWithLevel(int level, const char *format,
28 va_list arg_list) {
29 std::string message = StringPrintV(format, arg_list);
30 syslog(level, "%s", message.c_str());
31 if (accumulator_ != NULL) {
32 accumulator_->append(message);
33 accumulator_->push_back('\n');
34 }
35 }
36
25 void SystemLoggingImpl::LogInfo(const char *format, ...) { 37 void SystemLoggingImpl::LogInfo(const char *format, ...) {
26 va_list vl; 38 va_list vl;
27 va_start(vl, format); 39 va_start(vl, format);
28 vsyslog(LOG_INFO, format, vl); 40 LogWithLevel(LOG_INFO, format, vl);
29 va_end(vl); 41 va_end(vl);
30 } 42 }
31 43
32 void SystemLoggingImpl::LogWarning(const char *format, ...) { 44 void SystemLoggingImpl::LogWarning(const char *format, ...) {
33 va_list vl; 45 va_list vl;
34 va_start(vl, format); 46 va_start(vl, format);
35 vsyslog(LOG_WARNING, format, vl); 47 LogWithLevel(LOG_WARNING, format, vl);
36 va_end(vl); 48 va_end(vl);
37 } 49 }
38 50
39 void SystemLoggingImpl::LogError(const char *format, ...) { 51 void SystemLoggingImpl::LogError(const char *format, ...) {
40 va_list vl; 52 va_list vl;
41 va_start(vl, format); 53 va_start(vl, format);
42 vsyslog(LOG_ERR, format, vl); 54 LogWithLevel(LOG_ERR, format, vl);
43 va_end(vl); 55 va_end(vl);
44 } 56 }
OLDNEW
« no previous file with comments | « system_logging.h ('k') | system_logging_mock.h » ('j') | user_collector.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698