Sha256: bc6fe5fb954f884bd2ab7e4a03aef5c81420e4a4dca320bc434adb06b380d2ed
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
#ifndef BENCHMARK_LOG_H_ #define BENCHMARK_LOG_H_ #include <iostream> #include <ostream> #include "benchmark/benchmark.h" namespace benchmark { namespace internal { typedef std::basic_ostream<char>&(EndLType)(std::basic_ostream<char>&); class LogType { friend LogType& GetNullLogInstance(); friend LogType& GetErrorLogInstance(); // FIXME: Add locking to output. template <class Tp> friend LogType& operator<<(LogType&, Tp const&); friend LogType& operator<<(LogType&, EndLType*); private: LogType(std::ostream* out) : out_(out) {} std::ostream* out_; BENCHMARK_DISALLOW_COPY_AND_ASSIGN(LogType); }; template <class Tp> LogType& operator<<(LogType& log, Tp const& value) { if (log.out_) { *log.out_ << value; } return log; } inline LogType& operator<<(LogType& log, EndLType* m) { if (log.out_) { *log.out_ << m; } return log; } inline int& LogLevel() { static int log_level = 0; return log_level; } inline LogType& GetNullLogInstance() { static LogType log(nullptr); return log; } inline LogType& GetErrorLogInstance() { static LogType log(&std::clog); return log; } inline LogType& GetLogInstanceForLevel(int level) { if (level <= LogLevel()) { return GetErrorLogInstance(); } return GetNullLogInstance(); } } // end namespace internal } // end namespace benchmark #define VLOG(x) \ (::benchmark::internal::GetLogInstanceForLevel(x) << "-- LOG(" << x << "):" \ " ") #endif
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simdjson-0.3.0 | vendor/simdjson/dependencies/json/benchmarks/thirdparty/benchmark/src/log.h |