StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StLoggerManager.h
1 
15 #ifndef ClassStLoggerManager
16 #define ClassStLoggerManager
17 #include "StMessMgr.h"
18 
19 #ifndef __CINT__
20 # include <log4cxx/logger.h>
21 # include <vector>
22 # include <cassert>
23 # include "StarOptionFilter.h"
24 #endif
25 
26 
27 //#include "StMessage.h"
28 //#include "StMessTypeList.h"
29 //#include "StMessageCounter.h"
30 
31 class StMessTypeList;
32 class StMessageCounter;
33 class StMessTypeList;
34 //class StarOptionFilter;
35 
36 #ifndef ClassMessVec
37 #define ClassMessVec
38  //typedef StVector(StMessage*) messVec;
39  //typedef StVector(StMessage*)::iterator messVecIter;
40  //typedef StVector(messVec*) messTypeVec;
41 #endif
42 
43 class StLoggerManager : public StMessMgr {
44 
45  private:
46 #ifndef __CINT__
47  log4cxx::LoggerPtr fLogger;
48  static log4cxx::LoggerPtr fgQALogger;
49  static log4cxx::LoggerPtr &fgUCMLogger;
50 #endif
51 
52  static StMessMgr* mInstance;
53  static const char *fgLevels;
54  // StMessTypeList* messTypeList; //!
55  // StMessageCounter* messCounter; //!
56  unsigned char fCurType;
57  char* fCurOpt;
58 #ifndef __CINT__
59  std::vector<std::string> fSourceFileNames;
60  std::string fLastMessage;
61  std::ostringstream fStreams[7];
62 #endif
63  int fLineNumbers[10];
64  int fAllowRepeat; // the total number one and the same message can be printed out
65  int fLastRepeatCounter;
66 #ifndef __CINT__
67  log4cxx::varia::StarOptionFilterPtr fStarOptionFilter;
68  log4cxx::LevelPtr fDefaultLevel;
69 #endif
70  // int building;
71  // int remember;
72 
73 
74  protected:
75  // messVec messList;
76  // messTypeVec messCollection;
77  static inline int LevelIndex(char level);
78  static bool mColorEnabled;
79  protected:
80  StLoggerManager(const char *loggerName="BFC");
82  virtual void BuildMessage(const char* mess="", unsigned char type=0,
83  const char* opt=0,const char *sourceFileName=0, int lineNumber=-1);
84 #ifndef __CINT__
85  void SetStarOptionFilter(const log4cxx::varia::StarOptionFilterPtr& filter);
86  const log4cxx::varia::StarOptionFilterPtr& GetStarOptionFilter() const;
87  log4cxx::varia::StarOptionFilterPtr& GetStarOptionFilter();
88  std::ostringstream &Stream();
89 #endif
90 
91 protected:
92  friend class StChain;
93  virtual void IgnoreRepeats();
94  virtual void AllowRepeats();
95  virtual void AllowRepeats(int nRepeats);
96 
97  virtual int PrintList(messVec* list);
98  virtual const messVec* GetAll();
99  static void DestroyInstance();
100 
101  public:
102  virtual ~StLoggerManager();
103  virtual ostream& OperatorShift(ostream& os, StMessage* stm);
104  static StMessMgr* StarLoggerInit();
105  static StMessMgr* StarLoggerInit(const char *loggerName);
106  virtual StMessMgr* Instantiate();
107  virtual StMessMgr* Instantiate(const char *loggerName);
108 
109  virtual bool isDebugEnabled() const;
110  virtual bool isWarnEnabled() const;
111  virtual bool isErrorEnabled() const;
112  virtual bool isInfoEnabled() const;
113  virtual bool isFatalEnabled() const;
114  virtual bool isEnabledFor() const;
115  virtual bool isQAInfoEnabled() const;
116  virtual bool isUCMInfoEnabled()const;
117  static bool isColorEnabled() {return mColorEnabled;}
118  static void setColorEnabled(bool t = true) {mColorEnabled = t;}
119 
120 // Generic Messages:
121  virtual std::ostringstream& Message(const char* mess="", const char* type="",
122  const char* opt=0,const char *sourceFileName=0, int lineNumber=-1);
123  virtual void Print();
124 // virtual int PrintList(messVec* list);
125  virtual int PrintAll();
126  // virtual const messVec* GetAll();
127  virtual StMessage* FindMessage(const char* s1, const char* s2="",
128  const char* s3="", const char* s4="", messVec* list=0);
129  virtual messVec* FindMessageList(const char* s1, const char* s2="",
130  const char* s3="", const char* s4="", messVec* list=0);
131  virtual int RemoveMessage(StMessage* mess);
132  virtual int RemoveMessage(const char* s1, const char* s2="",
133  const char* s3="", const char* s4="");
134  virtual void SetLimit(const char* str, int n=0);
135  virtual int GetLimit(const char* str);
136  virtual void ListLimits();
137  virtual void RemoveLimit(const char* str);
138  virtual void SetLevel(Int_t );
139  virtual Int_t GetLevel(Int_t ) const;
140  virtual const char *GetName() const { return 0;}
141  virtual void SwitchOff(const char* str);
142  virtual void SwitchOn(const char* str);
143  virtual void FixOn(const char* str);
144  virtual void NoLimits();
145  virtual void Summary(size_t nTerms=1);
146  virtual void MemorySummary();
147  virtual void MemoryOn();
148  virtual void MemoryOff();
149  virtual int AddType(const char* type, const char* text);
150  virtual int ListTypes();
151  virtual void Close(); // Close the messenger streams
152 // virtual const char *GetName();
153 
154 // Info Messages:
155  virtual std::ostringstream& Info(const char* mess="", const char* opt="O"
156  ,const char *sourceFileName=0, int lineNumber=-1);
157  virtual int PrintInfos();
158  virtual const messVec* GetInfos();
159  virtual StMessage* FindInfo(const char* s1, const char* s2="",
160  const char* s3="", const char* s4="");
161  virtual messVec* FindInfoList(const char* s1, const char* s2="",
162  const char* s3="", const char* s4="");
163 
164 // Warning Messages:
165  virtual std::ostringstream& Warning(const char* mess="", const char* opt="E"
166  ,const char *sourceFileName=0, int lineNumber=-1);
167  virtual int PrintWarnings();
168  virtual const messVec* GetWarnings();
169  virtual StMessage* FindWarning(const char* s1, const char* s2="",
170  const char* s3="", const char* s4="");
171  virtual messVec* FindWarningList(const char* s1, const char* s2="",
172  const char* s3="", const char* s4="");
173 
174 // Error Messages:
175  virtual std::ostringstream& Error(const char* mess="", const char* opt="E"
176  ,const char *sourceFileName=0, int lineNumber=-1);
177  virtual int PrintErrors();
178  virtual const messVec* GetErrors();
179  virtual StMessage* FindError(const char* s1, const char* s2="",
180  const char* s3="", const char* s4="");
181  virtual messVec* FindErrorList(const char* s1, const char* s2="",
182  const char* s3="", const char* s4="");
183 
184 // Debug Messages:
185  virtual std::ostringstream& Debug(const char* mess="", const char* opt="OT"
186  ,const char *sourceFileName=0, int lineNumber=-1);
187  virtual int PrintDebug();
188  virtual const messVec* GetDebugs();
189  virtual StMessage* FindDebug(const char* s1, const char* s2="",
190  const char* s3="", const char* s4="");
191  virtual messVec* FindDebugList(const char* s1, const char* s2="",
192  const char* s3="", const char* s4="");
193 
194 // QAInfo Messages:
195  virtual std::ostringstream& QAInfo(const char* mess="", const char* opt="OS"
196  ,const char *sourceFileName=0, int lineNumber=-1);
197  virtual int PrintQAInfo();
198  virtual const messVec* GetQAInfos();
199  virtual StMessage* FindQAInfo(const char* s1, const char* s2="",
200  const char* s3="", const char* s4="");
201  virtual messVec* FindQAInfoList(const char* s1, const char* s2="",
202  const char* s3="", const char* s4="");
203 
204 // UCMInfo Messages:
205  virtual std::ostringstream& UCMInfo(const char* mess="", const char* opt="OS"
206  ,const char *sourceFileName=0, int lineNumber=-1);
207  virtual int PrintUCMInfo();
208  virtual const messVec* GetUCMInfos();
209  virtual StMessage* FindUCMInfo(const char* s1, const char* s2="",
210  const char* s3="", const char* s4="");
211  virtual messVec* FindUCMInfoList(const char* s1, const char* s2="",
212  const char* s3="", const char* s4="");
213 
214 // "As is" Messages:
215  virtual std::ostringstream& out(const char* mess="");
216  virtual std::ostringstream& err(const char* mess="");
217 
218  virtual void PrintInfo();
219 
220  // Fatal Messages:
221  virtual std::ostringstream& Fatal(const char* mess="", const char* opt="F",const char *sourceFileName=0, int lineNumber=-1);
222 
223  // "Extra Logger" methods
224  void PrintLogger(const char* mess, unsigned char type, const char* opt, const char *sourceFileName=0, int lineNumber=-1);
225 
226 #ifdef __ROOT__
227  ClassDef(StLoggerManager,0)
228 #endif
229 };
230 
231 //_____________________________________________________________________________
232 inline int StLoggerManager::LevelIndex(char level)
233 {
234  const char *thisLevel = strchr(StLoggerManager::fgLevels,level);
235  assert(thisLevel);
236  return thisLevel-StLoggerManager::fgLevels;
237 }
238 #ifndef __CINT__
239 //_____________________________________________________________________________
240 inline void StLoggerManager::SetStarOptionFilter(const log4cxx::varia::StarOptionFilterPtr& filter)
241 { fStarOptionFilter = filter; }
242 //_____________________________________________________________________________
243 inline const log4cxx::varia::StarOptionFilterPtr& StLoggerManager::GetStarOptionFilter() const
244 { return fStarOptionFilter;}
245 
246 //_____________________________________________________________________________
247 inline log4cxx::varia::StarOptionFilterPtr& StLoggerManager::GetStarOptionFilter()
248 { return fStarOptionFilter;}
249 
250 #endif
251 #endif
252 
253 // $Id: StLoggerManager.h,v 1.17 2012/10/04 23:32:29 fisyak Exp $
Definition: FJcore.h:367
virtual const char * GetName() const
special overload
Definition: StMaker.cxx:237