CLASS  5.1
Fuel Cycle Simulator
CLASSLogger.hxx
Go to the documentation of this file.
1 #ifndef _LOG_
2 #define _LOG_
3 
4 
14 #include <string>
15 #include <fstream>
16 
17 #include <iostream>
18 #include <cstring>
19 #include <sstream>
20 #include "stdlib.h"
21 using namespace std;
22 
23 
24 #ifndef __ROOTCLING__
25 
26 #define ERROR if(fLog)if(fLog->GetMaxOutPutLVL() >= 0) fLog->E() << "!!!ERROR!!! " << "[" << __FILE__ << ":" << __FUNCTION__ << "] "
27 #define WARNING if(fLog)if(fLog->GetMaxOutPutLVL() >= 1) fLog->W() << "!!WARNING!! " << "[" << __FILE__ << ":" << __FUNCTION__ << "] "
28 #define INFO if(fLog)if(fLog->GetMaxOutPutLVL() >= 2) fLog->I() << "!!!!INFO!!! " << "[" << __FILE__ << "] "
29 
30 #define DBGL if(fLog)if(fLog->GetMaxOutPutLVL() >= 3) fLog->D() << __FILE__ << " : " << __LINE__ << " [" << __FUNCTION__ << "]" << endl;
31 #define DBGV(x) {if(fLog)if(fLog->GetMaxOutPutLVL() >= 3) fLog->D() << __FILE__ << " : " << __LINE__ << " [" << __FUNCTION__ << "]" << x << endl;}
32 
33 #else
34 
35 #define ERROR cout
36 #define INFO cout
37 #define WARNING cout
38 #define DBGL
39 #define DBGV(x)
40 
41 
42 #endif
43 
44 
45 
46 #ifndef _LOGTYPE_
47 #define _LOGTYPE_
48 
49 //-----------------------------------------------------------------------------//
51 
60 //________________________________________________________________________
61 
62 
63 class LogType
64 {
65 public:
66  //********* Constructor/Destructor Method *********//
67 
72 
73  //{
75 
79  LogType(ostream &Log) { fLog = &Log; fLog2 = 0; }
80  //}
81 
82  ~LogType() {}
83 
85 
86  //********* In/Out Method *********//
87 
92  string GetCLASSLoggerName() const { return fCLASSLoggerName; }
93 
94  LogType &operator << (std::ostream& (*manip)(std::ostream &))
95  {
96  manip( *(this->fLog) );
97  if(fLog2)
98  manip( *(this->fLog2) );
99  return *this;
100  }
101 
102 
103  template<typename T>
104  inline LogType& operator << (T something)
105  {
106  *(this->fLog) << something;
107  if(fLog2)
108  *(this->fLog2) << something;
109  return *this;
110  }
111  //}
112 
113  void SetSecondOutput(ostream &log) {fLog2 = &log;} // used to direct the stream into two output ostream
114 
115  private :
116 
117  ostream *fLog;
118  ostream *fLog2;
119 
120  string fCLASSLoggerName;
121 };
122 
123 
124 #endif
125 
126 
127 #ifndef _CLASSLogger_
128 #define _CLASSLogger_
129 
130 //-----------------------------------------------------------------------------//
132 
141 //________________________________________________________________________
142 
143 
145 {
146 public:
147 
148  //********* Constructor/Destructor Method *********//
149 
154  //{
156 
169  CLASSLogger(string CLASSLoggerName = "CLASS_OUTPUT.log", int VerboseLvl = 0, int OutputLvl = 1 );
170  //}
171 
172  ~CLASSLogger();
173 
175 
176  //********* In/Out Method *********//
177 
182  string GetCLASSLoggerName() const { return fCLASSLoggerName; }
183  int GetMaxOutPutLVL() const { return fMaxOutPutLVL; }
184  int GetVerboseLVL() const { return fVerboseLVL; }
185 
186  LogType E() {return *fError;}
187  LogType W() {return *fWarning;}
188  LogType I() {return *fInfo;}
189  LogType D() {return *fDebug;}
190 
192 
193 
194 
195 
196  private :
197  int fMaxOutPutLVL;
198  int fVerboseLVL;
199 
200  LogType* fError;
201  LogType* fInfo;
202  LogType* fWarning;
203  LogType* fDebug;
204 
205  ofstream fOutPutFile;
206  string fCLASSLoggerName;
207 };
208 
209 #endif
210 
211 
212 
213 #endif
214 
215 
216 
Definition: CLASSBackEndDict.cxx:37
string GetCLASSLoggerName() const
return the CLASSLogger name
Definition: CLASSLogger.hxx:182
~LogType()
Normal Destructor.
Definition: CLASSLogger.hxx:82
LogType D()
Return the DEBUG Streamer.
Definition: CLASSLogger.hxx:189
string GetCLASSLoggerName() const
return the CLASSLogger name
Definition: CLASSLogger.hxx:92
void SetSecondOutput(ostream &log)
Definition: CLASSLogger.hxx:113
LogType(ostream &Log)
Normal Constructor.
Definition: CLASSLogger.hxx:79
int GetMaxOutPutLVL() const
Return File Output lvl.
Definition: CLASSLogger.hxx:183
Object to handle output messages.
Definition: CLASSLogger.hxx:144
handles output stream in CLASS
Definition: CLASSLogger.hxx:63
int GetVerboseLVL() const
Definition: CLASSLogger.hxx:184
LogType I()
Return the INFO Streamer.
Definition: CLASSLogger.hxx:188
LogType E()
Return the ERROR Streamer.
Definition: CLASSLogger.hxx:186
LogType W()
Return the WARNING Streamer.
Definition: CLASSLogger.hxx:187