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

Side by Side Diff: chromeos/device_event_log.cc

Issue 773703002: Generalize network_event_log -> device_event_log (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + feedback Created 6 years 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
« no previous file with comments | « chromeos/device_event_log.h ('k') | chromeos/device_event_log_impl.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 2014 The Chromium 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 "chromeos/device_event_log.h"
6
7 #include <string>
8
9 #include "base/logging.h"
10 #include "chromeos/device_event_log_impl.h"
11
12 namespace chromeos {
13
14 namespace device_event_log {
15
16 namespace {
17
18 const size_t kDefaultMaxEntries = 4000;
19
20 DeviceEventLogImpl* g_device_event_log = NULL;
21
22 } // namespace
23
24 const LogLevel kDefaultLogLevel = LOG_LEVEL_EVENT;
25
26 void Initialize(size_t max_entries) {
27 CHECK(!g_device_event_log);
28 if (max_entries == 0)
29 max_entries = kDefaultMaxEntries;
30 g_device_event_log = new DeviceEventLogImpl(max_entries);
31 }
32
33 void Shutdown() {
34 delete g_device_event_log;
35 g_device_event_log = NULL;
36 }
37
38 void AddEntry(const char* file,
39 int line,
40 LogType type,
41 LogLevel level,
42 const std::string& event) {
43 if (g_device_event_log) {
44 g_device_event_log->AddEntry(file, line, type, level, event);
45 } else {
46 DeviceEventLogImpl::SendToVLogOrErrorLog(file, line, type, level, event);
47 }
48 }
49
50 void AddEntryWithDescription(const char* file,
51 int line,
52 LogType type,
53 LogLevel level,
54 const std::string& event,
55 const std::string& desc) {
56 std::string event_with_desc = event;
57 if (!desc.empty())
58 event_with_desc += ": " + desc;
59 AddEntry(file, line, type, level, event_with_desc);
60 }
61
62 std::string GetAsString(StringOrder order,
63 const std::string& format,
64 LogType log_type,
65 LogLevel max_level,
66 size_t max_events) {
67 if (!g_device_event_log)
68 return "DeviceEventLog not initialized.";
69 return g_device_event_log->GetAsString(order, format, log_type, max_level,
70 max_events);
71 }
72
73 namespace internal {
74
75 DeviceEventLogInstance::DeviceEventLogInstance(const char* file,
76 int line,
77 device_event_log::LogType type,
78 device_event_log::LogLevel level)
79 : file_(file), line_(line), type_(type), level_(level) {
80 }
81
82 DeviceEventLogInstance::~DeviceEventLogInstance() {
83 device_event_log::AddEntry(file_, line_, type_, level_, stream_.str());
84 }
85
86 } // namespace internal
87
88 } // namespace device_event_log
89
90 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/device_event_log.h ('k') | chromeos/device_event_log_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698