1 #ifndef BENCHMARK_LOG_H_
2 #define BENCHMARK_LOG_H_
7 #include "benchmark/benchmark.h"
12 typedef std::basic_ostream
<char>&(EndLType
)(std::basic_ostream
<char>&);
15 friend LogType
& GetNullLogInstance();
16 friend LogType
& GetErrorLogInstance();
18 // FIXME: Add locking to output.
20 friend LogType
& operator<<(LogType
&, Tp
const&);
21 friend LogType
& operator<<(LogType
&, EndLType
*);
24 LogType(std::ostream
* out
) : out_(out
) {}
26 BENCHMARK_DISALLOW_COPY_AND_ASSIGN(LogType
);
30 LogType
& operator<<(LogType
& log
, Tp
const& value
) {
37 inline LogType
& operator<<(LogType
& log
, EndLType
* m
) {
44 inline int& LogLevel() {
45 static int log_level
= 0;
49 inline LogType
& GetNullLogInstance() {
50 static LogType
log(nullptr);
54 inline LogType
& GetErrorLogInstance() {
55 static LogType
log(&std::clog
);
59 inline LogType
& GetLogInstanceForLevel(int level
) {
60 if (level
<= LogLevel()) {
61 return GetErrorLogInstance();
63 return GetNullLogInstance();
66 } // end namespace internal
67 } // end namespace benchmark
70 (::benchmark::internal::GetLogInstanceForLevel(x) << "-- LOG(" << x << "):" \