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