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 namespace base {
     14 class Value;
     15 }
     16 
     17 // Abstract class for logging entries with a level, timestamp, string message.
     18 class Log {
     19  public:
     20   // Log entry severity level.
     21   enum Level {
     22     kAll,
     23     kDebug,
     24     kInfo,
     25     kWarning,
     26     kError,
     27     kOff
     28   };
     29 
     30   virtual ~Log() {}
     31 
     32   // Adds an entry to the log.
     33   virtual void AddEntryTimestamped(const base::Time& timestamp,
     34                                    Level level,
     35                                    const std::string& source,
     36                                    const std::string& message) = 0;
     37 
     38   // Adds an entry to the log, timestamped with the current time.
     39   void AddEntry(Level level,
     40                 const std::string& source,
     41                 const std::string& message);
     42 
     43   // Adds an entry to the log, timestamped with the current time and no source.
     44   void AddEntry(Level level, const std::string& message);
     45 };
     46 
     47 typedef bool (*IsVLogOnFunc)(int vlog_level);
     48 void InitLogging(IsVLogOnFunc is_vlog_on_func);
     49 
     50 // Returns whether the given VLOG level is on.
     51 bool IsVLogOn(int vlog_level);
     52 
     53 std::string PrettyPrintValue(const base::Value& value);
     54 
     55 // Returns a pretty printed value, after truncating long strings.
     56 std::string FormatValueForDisplay(const base::Value& value);
     57 
     58 // Returns a pretty printed json string, after truncating long strings.
     59 std::string FormatJsonForDisplay(const std::string& json);
     60 
     61 #endif  // CHROME_TEST_CHROMEDRIVER_CHROME_LOG_H_
     62