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

Side by Side Diff: chrome/browser/chromeos/drive/event_logger.h

Issue 14247011: drive: Change EventLogger to take printf format (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium 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 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_EVENT_LOGGER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_EVENT_LOGGER_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_EVENT_LOGGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_EVENT_LOGGER_H_
7 7
8 #include <stdarg.h> // va_list
8 #include <string> 9 #include <string>
9 #include <deque> 10 #include <deque>
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
12 #include "base/time.h" 14 #include "base/time.h"
13 15
14 namespace drive { 16 namespace drive {
15 17
16 // EventLogger is used to expose text messages to chrome:drive-internals, 18 // EventLogger is used to expose text messages to chrome:drive-internals,
17 // for diagnosing the behavior of the Drive client. 19 // for diagnosing the behavior of the Drive client.
18 class EventLogger { 20 class EventLogger {
19 public: 21 public:
20 // Represents a single event log. 22 // Represents a single event log.
21 struct Event { 23 struct Event {
22 Event(int id, const std::string& what); 24 Event(int id, const std::string& what);
23 int id; // Monotonically increasing ID starting from 0. 25 int id; // Monotonically increasing ID starting from 0.
24 base::Time when; // When the event occurred. 26 base::Time when; // When the event occurred.
25 std::string what; // What happened. 27 std::string what; // What happened.
26 }; 28 };
27 29
28 // Creates an event logger that keeps the latest |history_size| events. 30 // Creates an event logger that keeps the latest |history_size| events.
29 explicit EventLogger(size_t history_size); 31 explicit EventLogger(size_t history_size);
30 ~EventLogger(); 32 ~EventLogger();
31 33
32 // Logs a message. 34 // Logs a message using printf format.
33 void Log(const std::string& what); 35 // Note that PRINTF_FORMAT should be (2, 3) instead of (1, 2) as this is a
36 // C++ member function.
37 void Log(const char* format, ...) PRINTF_FORMAT(2, 3);
34 38
35 // Gets the list of latest events (the oldest event comes first). 39 // Gets the list of latest events (the oldest event comes first).
36 const std::deque<Event>& history() const { return history_; } 40 const std::deque<Event>& history() const { return history_; }
37 41
38 private: 42 private:
39 std::deque<Event> history_; 43 std::deque<Event> history_;
40 const size_t history_size_; 44 const size_t history_size_;
41 int next_event_id_; 45 int next_event_id_;
42 46
43 DISALLOW_COPY_AND_ASSIGN(EventLogger); 47 DISALLOW_COPY_AND_ASSIGN(EventLogger);
44 }; 48 };
45 49
46 } // namespace drive 50 } // namespace drive
47 51
48 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_EVENT_LOGGER_H_ 52 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_EVENT_LOGGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_prefetcher.cc ('k') | chrome/browser/chromeos/drive/event_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698