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

Side by Side Diff: system_logging.cc

Issue 6517001: crash-reporter: Use standard logging and new libchromeos Process code (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crash-reporter.git@master
Patch Set: More comments Created 9 years, 9 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
« no previous file with comments | « system_logging.h ('k') | system_logging_mock.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "crash-reporter/system_logging.h"
6
7 #include <syslog.h>
8
9 #include "base/stringprintf.h"
10
11 std::string SystemLoggingImpl::identity_;
12
13 SystemLoggingImpl::SystemLoggingImpl() : is_accumulating_(false) {
14 }
15
16 SystemLoggingImpl::~SystemLoggingImpl() {
17 }
18
19 void SystemLoggingImpl::Initialize(const char *ident) {
20 // Man page does not specify if openlog copies its string or assumes
21 // the pointer is always valid, so make its scope global.
22 identity_ = ident;
23 openlog(identity_.c_str(), LOG_PID, LOG_USER);
24 }
25
26 void SystemLoggingImpl::LogWithLevel(int level, const char *format,
27 va_list arg_list) {
28 std::string message = StringPrintV(format, arg_list);
29 syslog(level, "%s", message.c_str());
30 if (is_accumulating_) {
31 accumulator_.append(message);
32 accumulator_.push_back('\n');
33 }
34 }
35
36 void SystemLoggingImpl::LogInfo(const char *format, ...) {
37 va_list vl;
38 va_start(vl, format);
39 LogWithLevel(LOG_INFO, format, vl);
40 va_end(vl);
41 }
42
43 void SystemLoggingImpl::LogWarning(const char *format, ...) {
44 va_list vl;
45 va_start(vl, format);
46 LogWithLevel(LOG_WARNING, format, vl);
47 va_end(vl);
48 }
49
50 void SystemLoggingImpl::LogError(const char *format, ...) {
51 va_list vl;
52 va_start(vl, format);
53 LogWithLevel(LOG_ERR, format, vl);
54 va_end(vl);
55 }
OLDNEW
« no previous file with comments | « system_logging.h ('k') | system_logging_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698