File size: 1,153 Bytes
6229e10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// control verbosity levels in the code to make things cleaner

#pragma once

#include <sstream>

namespace data_structures {

enum VERBOSITY_LEVEL {
  VERBOSITY_LEVEL_QUIET,
  VERBOSITY_LEVEL_VERBOSE,
  VERBOSITY_LEVEL_DEBUG,
  VERBOSITY_LEVEL_TRACE
};

VERBOSITY_LEVEL GLOBAL_VERBOSITY_LEVEL = VERBOSITY_LEVEL_QUIET;

inline void setGlobalVerbosityLevel(VERBOSITY_LEVEL vl) {
  GLOBAL_VERBOSITY_LEVEL = vl;
}

template<typename T>
std::string to_str(const T& value){
  std::ostringstream tmp_str;
  tmp_str << value;
  return tmp_str.str();
}

template<typename T, typename ... Args >
std::string to_str(const T& value, const Args& ... args){
  return to_str(value) + to_str(args...);
}

template<typename T>
inline void LOGGER(T x) {
    if (GLOBAL_VERBOSITY_LEVEL >= VERBOSITY_LEVEL_VERBOSE) {
        std::cout << x << std::endl;
    }
}

template<typename T>
inline void LOGGER(VERBOSITY_LEVEL vl, T x) {
    if (vl <= GLOBAL_VERBOSITY_LEVEL) {
        std::cout << x << std::endl;
    }
}

template<typename T>
inline void LOGGER(T x, bool newline) {
    if (GLOBAL_VERBOSITY_LEVEL >= VERBOSITY_LEVEL_VERBOSE) {
        std::cout << x;
    }
}

}