summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/benchmark/src/log.cc
blob: b660309d324fa207ebce00d2e211f9049b7154a4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "log.h"

#include <iostream>

namespace benchmark {
namespace internal {

int& LoggingLevelImp() {
    static int level = 0;
    return level;
}

void SetLogLevel(int value) {
    LoggingLevelImp() = value;
}

int GetLogLevel() {
    return LoggingLevelImp();
}

class NullLogBuffer : public std::streambuf
{
public:
  int overflow(int c) {
    return c;
  }
};

std::ostream& GetNullLogInstance() {
  static NullLogBuffer log_buff;
  static std::ostream null_log(&log_buff);
  return null_log;
}

std::ostream& GetErrorLogInstance() {
  return std::clog;
}

} // end namespace internal
} // end namespace benchmark