OLD | NEW |
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 #include "chrome/browser/chromeos/drive/event_logger.h" | 5 #include "chrome/browser/chromeos/drive/event_logger.h" |
6 | 6 |
| 7 #include "base/stringprintf.h" |
| 8 |
7 namespace drive { | 9 namespace drive { |
8 | 10 |
9 EventLogger::Event::Event(int id, const std::string& what) | 11 EventLogger::Event::Event(int id, const std::string& what) |
10 : id(id), | 12 : id(id), |
11 when(base::Time::Now()), | 13 when(base::Time::Now()), |
12 what(what) { | 14 what(what) { |
13 } | 15 } |
14 | 16 |
15 EventLogger::EventLogger(size_t history_size) | 17 EventLogger::EventLogger(size_t history_size) |
16 : history_size_(history_size), | 18 : history_size_(history_size), |
17 next_event_id_(0) { | 19 next_event_id_(0) { |
18 } | 20 } |
19 | 21 |
20 EventLogger::~EventLogger() { | 22 EventLogger::~EventLogger() { |
21 } | 23 } |
22 | 24 |
23 void EventLogger::Log(const std::string& what) { | 25 void EventLogger::Log(const char* format, ...) { |
| 26 std::string what; |
| 27 |
| 28 va_list args; |
| 29 va_start(args, format); |
| 30 base::StringAppendV(&what, format, args); |
| 31 va_end(args); |
| 32 |
24 history_.push_back(Event(next_event_id_, what)); | 33 history_.push_back(Event(next_event_id_, what)); |
25 ++next_event_id_; | 34 ++next_event_id_; |
26 if (history_.size() > history_size_) | 35 if (history_.size() > history_size_) |
27 history_.pop_front(); | 36 history_.pop_front(); |
28 } | 37 } |
29 | 38 |
30 } // namespace drive | 39 } // namespace drive |
OLD | NEW |