| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/logging.h" | 5 #include "chrome/browser/chromeos/drive/logging.h" |
| 6 | 6 |
| 7 #include <stdarg.h> // va_list |
| 8 |
| 7 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 8 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 9 #include "chrome/browser/drive/event_logger.h" | 11 #include "chrome/browser/drive/event_logger.h" |
| 10 | 12 |
| 11 namespace drive { | 13 namespace drive { |
| 12 namespace util { | 14 namespace util { |
| 13 namespace { | 15 namespace { |
| 14 | 16 |
| 15 static base::LazyInstance<EventLogger> g_logger = | 17 static base::LazyInstance<EventLogger> g_logger = |
| 16 LAZY_INSTANCE_INITIALIZER; | 18 LAZY_INSTANCE_INITIALIZER; |
| 17 | 19 |
| 18 } // namespace | 20 } // namespace |
| 19 | 21 |
| 20 void Log(const char* format, ...) { | 22 void Log(logging::LogSeverity severity, const char* format, ...) { |
| 21 std::string what; | 23 std::string what; |
| 22 | 24 |
| 23 va_list args; | 25 va_list args; |
| 24 va_start(args, format); | 26 va_start(args, format); |
| 25 base::StringAppendV(&what, format, args); | 27 base::StringAppendV(&what, format, args); |
| 26 va_end(args); | 28 va_end(args); |
| 27 | 29 |
| 30 DVLOG(1) << what; |
| 31 |
| 28 // On thread-safety: LazyInstance guarantees thread-safety for the object | 32 // On thread-safety: LazyInstance guarantees thread-safety for the object |
| 29 // creation. EventLogger::Log() internally maintains the lock. | 33 // creation. EventLogger::Log() internally maintains the lock. |
| 30 EventLogger* ptr = g_logger.Pointer(); | 34 EventLogger* ptr = g_logger.Pointer(); |
| 31 ptr->Log("%s", what.c_str()); | 35 ptr->Log(severity, what); |
| 32 } | 36 } |
| 33 | 37 |
| 34 std::vector<EventLogger::Event> GetLogHistory() { | 38 std::vector<EventLogger::Event> GetLogHistory() { |
| 35 EventLogger* ptr = g_logger.Pointer(); | 39 EventLogger* ptr = g_logger.Pointer(); |
| 36 return ptr->GetHistory(); | 40 return ptr->GetHistory(); |
| 37 } | 41 } |
| 38 | 42 |
| 39 } // namespace util | 43 } // namespace util |
| 40 } // namespace drive | 44 } // namespace drive |
| OLD | NEW |