File: logger.cpp

package info (click to toggle)
literki 0.0.0+20100113.git1da40724-1.2
  • links: PTS, VCS
  • area: main
  • in suites: sid, stretch
  • size: 3,444 kB
  • ctags: 1,153
  • sloc: cpp: 5,263; makefile: 72
file content (58 lines) | stat: -rw-r--r-- 849 bytes parent folder | download | duplicates (2)
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
56
57
58

#include <iostream>

#include <cstdlib>
#include "logger.h"

using namespace std;
    
Logger::Logger(const Logger& l){
    type_ = l.type_;
}

Logger& Logger::operator << (const char * c){
  if (type_!=DEV_NULL)
	  cerr << c;
}
Logger& Logger::operator << (const string& s){
  if (type_!=DEV_NULL)
	  cerr << s.c_str();
}
Logger& Logger::operator << (int i){
  if (type_!=DEV_NULL)
	  cerr << i;
}
Logger& Logger::operator << (double d){
  if (type_!=DEV_NULL)
	  cerr << d;
}


Logger LOG(LogType t){
  Logger l(t);
  switch (t){
	  case FATAL: 
      l << "FATAL: ";
		  break;
	  case INFO:
      l << "INFO: ";
		  break;
	  case DEV_NULL:
      break;
    }
  return l;
}

Logger::Logger(LogType t):type_(t){
}

Logger::~Logger(){
  switch (type_){
	  case INFO:
      cerr << endl;
		  break;
	case FATAL:
    cerr << endl;
		exit(1);
  }
}