Home | History | Annotate | Download | only in chrome
      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 #ifndef CHROME_TEST_CHROMEDRIVER_CHROME_LOG_H_
      6 #define CHROME_TEST_CHROMEDRIVER_CHROME_LOG_H_
      7 
      8 #include <string>
      9 
     10 #include "base/compiler_specific.h"
     11 #include "base/time/time.h"
     12 
     13 // Abstract class for logging entries with a level, timestamp, string message.
     14 class Log {
     15  public:
     16   // Log entry severity level.
     17   enum Level {
     18     kDebug,
     19     kLog,
     20     kWarning,
     21     kError
     22   };
     23 
     24   virtual ~Log() {}
     25 
     26   // Adds an entry to the log.
     27   virtual void AddEntryTimestamped(const base::Time& timestamp,
     28                                    Level level,
     29                                    const std::string& message) = 0;
     30 
     31   // Adds an entry to the log, timestamped with the current time.
     32   void AddEntry(Level level, const std::string& message);
     33 };
     34 
     35 // Writes log entries using printf.
     36 class Logger : public Log {
     37  public:
     38   // Creates a logger with a minimum level of |kDebug|.
     39   Logger();
     40   explicit Logger(Level min_log_level);
     41   virtual ~Logger();
     42 
     43   virtual void AddEntryTimestamped(const base::Time& timestamp,
     44                                    Level level,
     45                                    const std::string& message) OVERRIDE;
     46 
     47  private:
     48   Level min_log_level_;
     49   base::Time start_;
     50 };
     51 
     52 #endif  // CHROME_TEST_CHROMEDRIVER_CHROME_LOG_H_
     53