00001
00014 #ifndef ClassStMessMgr
00015 #define ClassStMessMgr
00016
00017 #ifdef __ROOT__
00018 #include "Rtypes.h"
00019 #endif
00020
00021 #ifndef __CINT__
00022 #ifdef LOGGERMESSAGE
00023 #error An attempt to redefine the LOGGERMESSAGE macro
00024 #else
00025 # define LOGGERMESSAGE(MESSAGELEVEL) \
00026 if (StMessMgr::CurrentMessager()->_NAME3_(is,MESSAGELEVEL,Enabled)()) \
00027 StMessMgr::CurrentMessager()->MESSAGELEVEL("","O",__FUNCTION__, __LINE__)
00028
00029 # define LOG_INFO LOGGERMESSAGE(Info)
00030 # define LOG_WARN LOGGERMESSAGE(Warning)
00031 # define LOG_ERROR LOGGERMESSAGE(Error)
00032 # define LOG_FATAL LOGGERMESSAGE(Fatal)
00033 # define LOG_DEBUG LOGGERMESSAGE(Debug)
00034 # define LOG_QA LOGGERMESSAGE(QAInfo)
00035 # define LOG_UCM LOGGERMESSAGE(UCMInfo)
00036
00037 #define STAR_INFO(name) \
00038 GetLogger(_QUITE_(name))->MESSAGELEVEL(__FUNCTION__, __LINE__)
00039
00040 #define MSG_INFO(name) \
00041 GetLogger(_QUITE_(name))->MESSAGELEVEL(__FUNCTION__, __LINE__)
00042 #endif
00043 #endif
00044
00045 #ifndef __CINT__
00046 #include "StarCallf77.h"
00047 #define Message_ F77_NAME(message,MESSAGE)
00048 #define Msg_Enable_ F77_NAME(msg_enable,MSG_ENABLE)
00049 #define Msg_Enabled_ F77_NAME(msg_enabled,MSG_ENABLED)
00050 #define Msg_Disable_ F77_NAME(msg_disable,MSG_DISABLE)
00051 #define StMessage_ F77_NAME(stmessage,STMESSAGE)
00052 #define StInfo_ F77_NAME(stinfo,STINFO)
00053 #define StWarning_ F77_NAME(stwarning,STWARNING)
00054 #define StError_ F77_NAME(sterror,STERROR)
00055 #define StDebug_ F77_NAME(stdebug,STDEBUG)
00056 #define QAInfo_ F77_NAME(qainfo,QAINFO)
00057 #define UCMInfo_ F77_NAME(ucminfo,UCMINFO)
00058 #define StInfoOpt_ F77_NAME(stinfoopt,STINFOOPT)
00059 #define StWarningOpt_ F77_NAME(stwarningopt,STWARNINGOPT)
00060 #define StErrorOpt_ F77_NAME(sterroropt,STERROROPT)
00061 #define StDebugOpt_ F77_NAME(stdebugopt,STDEBUGOPT)
00062 #define QAInfoOpt_ F77_NAME(qainfoopt,QAINFOOPT)
00063 #define UCMInfoOpt_ F77_NAME(ucminfoopt,UCMINFOOPT)
00064 #define StMessAddType_ F77_NAME(stmessaddtype,STMESSADDTYPE)
00065 extern "C" {
00066 void type_of_call Message_(const char* mess, int *lines, int *id, size_t len);
00067 void type_of_call Msg_Enable_(const char* mess, size_t len);
00068 int type_of_call Msg_Enabled_(const char* mess, int *id, size_t len);
00069 void type_of_call Msg_Disable_(const char* mess, size_t len);
00070 void type_of_call MessageOut(const char* msg);
00071 void type_of_call StMessage_(const char* mess, const char* type,
00072 const char* opt, size_t len1,
00073 size_t len2, size_t len3);
00074 void type_of_call StInfo_(const char* mess, size_t len);
00075 void type_of_call StWarning_(const char* mess, size_t len);
00076 void type_of_call StError_(const char* mess, size_t len);
00077 void type_of_call StDebug_(const char* mess, size_t len);
00078 void type_of_call QAInfo_(const char* mess, size_t len);
00079 void type_of_call UCMInfo_(const char* mess, size_t len);
00080 void type_of_call StInfoOpt_(const char* mess, const char* opt,
00081 size_t len1, size_t len2);
00082 void type_of_call StWarningOpt_(const char* mess, const char* opt,
00083 size_t len1, size_t len2);
00084 void type_of_call StErrorOpt_(const char* mess, const char* opt,
00085 size_t len1, size_t len2);
00086 void type_of_call StDebugOpt_(const char* mess, const char* opt,
00087 size_t len1, size_t len2);
00088 void type_of_call QAInfoOpt_(const char* mess, const char* opt,
00089 size_t len1, size_t len2);
00090 void type_of_call UCMInfoOpt_(const char* mess, const char* opt,
00091 size_t len1, size_t len2);
00092 void type_of_call StMessAddType_(const char* type, const char* text,
00093 size_t len1, size_t len2);
00094 }
00095 #endif
00096
00097
00098
00099 class StMessage;
00100
00101 #ifndef ClassMessVec
00102 class messVec;
00103 #endif
00104
00105 #include <Stsstream.h>
00106 #include <Stiostream.h>
00107
00108 class StMessMgr : public ostrstream {
00109 friend ostream& operator<<(ostream& ,StMessage*);
00110 friend ostream& operator++(StMessMgr&);
00111 friend ostream& operator-(StMessMgr&);
00112 friend ostream& operator--(StMessMgr&);
00113 friend ostream& operator~(StMessMgr&);
00114 friend class StBFChain;
00115
00116 private:
00117
00118 protected:
00119 virtual void IgnoreRepeats() =0;
00120 virtual void AllowRepeats() =0;
00121
00122 StMessMgr& operator=(const StMessMgr&){ return *this;}
00123 public:
00124 enum ESTARMakerErrorLevels {
00125 kAll=-5, kFatal, kError, kWarning, kInfo, kDefault, kDebug, kDebug2
00126 };
00127 StMessMgr();
00128 StMessMgr(const StMessMgr&){;}
00129 virtual ~StMessMgr(){;}
00130
00131
00132 virtual std::ostream& OperatorShift(std::ostream& os, StMessage* stm) = 0;
00133
00134
00135 virtual ostrstream& Message(const char* mess="", const char* type="",
00136 const char* opt=0,const char *sourceFileName=0, int lineNumber=-1)= 0;
00137 virtual void Print() =0;
00138 virtual int PrintList(messVec* list) =0;
00139 virtual int PrintAll() =0;
00140 virtual StMessage* FindMessage(const char* s1, const char s2[]="",
00141 const char* s3="", const char* s4="", messVec* list=0) =0;
00142 virtual messVec* FindMessageList(const char* s1, const char* s2="",
00143 const char* s3="", const char* s4="", messVec* list=0) =0;
00144 virtual int RemoveMessage(StMessage* mess) =0;
00145 virtual int RemoveMessage(const char* s1, const char* s2="",
00146 const char* s3="", const char* s4="") =0;
00147 virtual void SetLimit(const char* str, int n=0) =0;
00148 virtual int GetLimit(const char* str) =0;
00149 virtual void ListLimits() =0;
00150 virtual void RemoveLimit(const char* str) =0;
00151 virtual void SetLevel(Int_t logLevel) =0;
00152 virtual Int_t GetLevel(Int_t logLevel) const =0;
00153 virtual const char *GetName() const = 0;
00154 virtual void SwitchOff(const char* str) =0;
00155 virtual void SwitchOn(const char* str) =0;
00156 virtual void FixOn(const char* str) =0;
00157 virtual void NoLimits() =0;
00158 virtual void Summary(size_t nTerms=1) =0;
00159 virtual void MemorySummary() =0;
00160 virtual void MemoryOn() =0;
00161 virtual void MemoryOff() =0;
00162 virtual int AddType(const char* type, const char* text) =0;
00163 virtual int ListTypes() =0;
00164 virtual void Close() {}
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187 virtual bool isDebugEnabled() const;
00188 virtual bool isWarnEnabled() const;
00189 virtual bool isWarningEnabled() const;
00190 virtual bool isErrorEnabled() const;
00191 virtual bool isInfoEnabled() const;
00192 virtual bool isFatalEnabled() const;
00193 virtual bool isEnabledFor() const;
00194 virtual bool isQAInfoEnabled() const;
00195 virtual bool isUCMInfoEnabled()const;
00196
00197
00198
00199
00200 public:
00201 static StMessMgr* CurrentMessager();
00202 static StMessMgr* Instance();
00203 static StMessMgr* Instance(const char *);
00204 static StMessMgr* SetCurrentMessager(StMessMgr *mgr=0);
00205 protected:
00206 virtual StMessMgr* Instantiate();
00207 virtual StMessMgr* Instantiate(const char *);
00208
00209 public:
00210
00211 virtual ostrstream& Info(const char* mess="", const char* opt="O",const char *sourceFileName=0, int lineNumber=-1)=0;
00212 virtual int PrintInfos() =0;
00213 virtual const messVec* GetInfos() =0;
00214 virtual StMessage* FindInfo(const char* s1, const char* s2="",
00215 const char* s3="", const char* s4="") =0;
00216 virtual messVec* FindInfoList(const char* s1, const char* s2="",
00217 const char* s3="", const char* s4="") =0;
00218
00219
00220 virtual ostrstream& Warning(const char* mess="", const char* opt="E",const char *sourceFileName=0, int lineNumber=-1)= 0;
00221 virtual int PrintWarnings() =0;
00222 virtual const messVec* GetWarnings() =0;
00223 virtual StMessage* FindWarning(const char* s1, const char* s2="",
00224 const char* s3="", const char* s4="") =0;
00225 virtual messVec* FindWarningList(const char* s1, const char* s2="",
00226 const char* s3="", const char* s4="") =0;
00227
00228
00229 virtual ostrstream& Error(const char* mess="", const char* opt="E",const char *sourceFileName=0, int lineNumber=-1) = 0;
00230 virtual int PrintErrors() =0;
00231 virtual const messVec* GetErrors() =0;
00232 virtual StMessage* FindError(const char* s1, const char* s2="",
00233 const char* s3="", const char* s4="") =0;
00234 virtual messVec* FindErrorList(const char* s1, const char* s2="",
00235 const char* s3="", const char* s4="") =0;
00236
00237
00238 virtual ostrstream& Debug(const char* mess="", const char* opt="OT",const char *sourceFileName=0, int lineNumber=-1)= 0;
00239 virtual int PrintDebug() =0;
00240 virtual const messVec* GetDebugs() =0;
00241 virtual StMessage* FindDebug(const char* s1, const char* s2="",
00242 const char* s3="", const char* s4="") =0;
00243 virtual messVec* FindDebugList(const char* s1, const char* s2="",
00244 const char* s3="", const char* s4="") =0;
00245
00246
00247 virtual ostrstream& QAInfo(const char* mess="", const char* opt="OS",const char *sourceFileName=0, int lineNumber=-1) = 0;
00248 virtual int PrintQAInfo() =0;
00249 virtual const messVec* GetQAInfos() =0;
00250 virtual StMessage* FindQAInfo(const char* s1, const char* s2="",
00251 const char* s3="", const char* s4="") =0;
00252 virtual messVec* FindQAInfoList(const char* s1, const char* s2="",
00253 const char* s3="", const char* s4="") =0;
00254
00255
00256 virtual ostrstream& UCMInfo(const char* mess="", const char* opt="OS",const char *sourceFileName=0, int lineNumber=-1) = 0;
00257 virtual int PrintUCMInfo() =0;
00258 virtual const messVec* GetUCMInfos() =0;
00259 virtual StMessage* FindUCMInfo(const char* s1, const char* s2="",
00260 const char* s3="", const char* s4="") =0;
00261 virtual messVec* FindUCMInfoList(const char* s1, const char* s2="",
00262 const char* s3="", const char* s4="") =0;
00263
00264
00265 virtual ostrstream& out(const char* mess="") = 0;
00266 virtual ostrstream& err(const char* mess="") = 0;
00267
00268 virtual void PrintInfo() =0;
00269
00270 virtual ostrstream& Fatal(const char* mess="", const char* opt="OT",const char *sourceFileName=0, int lineNumber=-1)= 0;
00271
00272 #ifdef __ROOT__
00273 ClassDef(StMessMgr,0)
00274 #endif
00275 };
00276
00277
00278
00279
00280
00281 class StTurnLogger
00282 {
00283 private:
00284 StMessMgr* fMessager;
00285 public:
00286 StTurnLogger(StMessMgr* msg=0);
00287 StTurnLogger(const StTurnLogger& push);
00288 ~StTurnLogger();
00289 };
00290
00291
00292 R__EXTERN StMessMgr* gMessMgr;
00293 R__EXTERN StMessage* gMessage;
00294 R__EXTERN StMessage* endm;
00295
00296
00297
00298 inline StTurnLogger::StTurnLogger(StMessMgr* msg): fMessager(0)
00299 {
00300 if (msg) fMessager = StMessMgr::SetCurrentMessager(msg);
00301 }
00302
00303
00304 inline StTurnLogger::StTurnLogger(const StTurnLogger& push) : fMessager(push.fMessager)
00305 { ((StTurnLogger*)&push)->fMessager=0; }
00306
00307
00308 inline StTurnLogger::~StTurnLogger()
00309 {if (fMessager) StMessMgr::SetCurrentMessager(fMessager);}
00310
00311
00312
00313 inline ostream& operator<<(ostream& os, StMessage* stm) {
00314 return gMessMgr->OperatorShift(os,stm);
00315 }
00316
00317
00318 inline ostream& operator++(StMessMgr&) {
00319 return gMessMgr->Info();
00320 }
00321
00322 inline ostream& operator--(StMessMgr&) {
00323 return gMessMgr->Error();
00324 }
00325
00326 inline ostream& operator~(StMessMgr&) {
00327 return gMessMgr->out();
00328 }
00329
00330 inline ostream& operator-(StMessMgr&) {
00331 return gMessMgr->err();
00332 }
00333
00334
00335
00336
00337 #endif
00338
00339