]>
Commit | Line | Data |
---|---|---|
6ab674bd | 1 | #ifndef ALILOG_H |
2 | #define ALILOG_H | |
3 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * See cxx source for full Copyright notice */ | |
5 | ||
6 | /* $Id$ */ | |
7 | ||
5a9a01d4 | 8 | #include <TClass.h> |
6ab674bd | 9 | #include <TObjArray.h> |
5a9a01d4 | 10 | #include <TObject.h> |
6ab674bd | 11 | #include <TString.h> |
12 | ||
840f6973 | 13 | using std::ostream; |
14 | ||
6d7793cf | 15 | // deprecation macro |
16 | #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) | |
13242232 | 17 | # define ALIROOT_DEPRECATED(func) func __attribute__ ((deprecated)) |
6d7793cf | 18 | #elif defined(_MSC_VER) && _MSC_VER >= 1300 |
13242232 | 19 | # define ALIROOT_DEPRECATED(func) __declspec(deprecated) func |
20 | #else | |
21 | # define ALIROOT_DEPRECATED(func) func | |
6d7793cf | 22 | #endif |
6ab674bd | 23 | |
6d7793cf | 24 | /** |
25 | * class for logging debug, info and error messages | |
26 | */ | |
27 | class AliLog: public TObject | |
28 | { | |
6ab674bd | 29 | public: |
6ab674bd | 30 | |
6d7793cf | 31 | // Log4j log levels: TRACE, DEBUG, INFO, WARN, ERROR, FATAL |
44ce6bbe | 32 | enum EType_t {kFatal = 0, kError, kWarning, kInfo, kDebug, kMaxType}; |
1948744e | 33 | typedef void (*AliLogNotification)(EType_t type, const char* message ); |
34 | ||
6d7793cf | 35 | // NB: singleton constructor & destructor should not be public! |
36 | // ALIROOT_DEPRECATED(AliLog()); | |
37 | // ALIROOT_DEPRECATED(virtual ~AliLog()); | |
38 | ||
39 | // NB: singleton deprecated static instance method | |
40 | // ALIROOT_DEPRECATED(static AliLog* Instance() {return fgInstance;};) | |
41 | ||
42 | // get root logger singleton instance | |
43 | static AliLog *GetRootLogger(); | |
6ab674bd | 44 | |
6d7793cf | 45 | // delete root logger singleton instance |
55247085 | 46 | static void DeleteRootLogger(); |
6d7793cf | 47 | |
48 | // NB: the following functions should not be static | |
49 | // NB: deprecated: logging configuration should be made through to a configuration file | |
55247085 | 50 | static void EnableCoreDump(Bool_t enabled); |
51 | static void MakeCoreDump(const char *fout); | |
6ab674bd | 52 | static void EnableDebug(Bool_t enabled); |
44ce6bbe | 53 | static void SetGlobalLogLevel(EType_t type); |
6ab674bd | 54 | static Int_t GetGlobalLogLevel(); |
55 | static void SetGlobalDebugLevel(Int_t level); | |
56 | static Int_t GetGlobalDebugLevel(); | |
57 | static void SetModuleDebugLevel(const char* module, Int_t level); | |
58 | static void ClearModuleDebugLevel(const char* module); | |
59 | static void SetClassDebugLevel(const char* className, Int_t level); | |
60 | static void ClearClassDebugLevel(const char* className); | |
61 | ||
62 | static void SetStandardOutput(); | |
44ce6bbe | 63 | static void SetStandardOutput(EType_t type); |
6ab674bd | 64 | static void SetErrorOutput(); |
44ce6bbe | 65 | static void SetErrorOutput(EType_t type); |
6ab674bd | 66 | static void SetFileOutput(const char* fileName); |
44ce6bbe | 67 | static void SetFileOutput(EType_t type, const char* fileName); |
1948744e | 68 | static void SetStreamOutput(ostream* stream); |
69 | static void SetStreamOutput(EType_t type, ostream* stream); | |
70 | static void SetLogNotification(AliLogNotification pCallBack); | |
71 | static void SetLogNotification(EType_t type, AliLogNotification pCallBack); | |
6ab674bd | 72 | static void Flush(); |
73 | ||
74 | static void SetHandleRootMessages(Bool_t on); | |
75 | ||
76 | static void SetPrintType(Bool_t on); | |
44ce6bbe | 77 | static void SetPrintType(EType_t type, Bool_t on); |
6ab674bd | 78 | static void SetPrintModule(Bool_t on); |
44ce6bbe | 79 | static void SetPrintModule(EType_t type, Bool_t on); |
6ab674bd | 80 | static void SetPrintScope(Bool_t on); |
44ce6bbe | 81 | static void SetPrintScope(EType_t type, Bool_t on); |
6ab674bd | 82 | static void SetPrintLocation(Bool_t on); |
44ce6bbe | 83 | static void SetPrintLocation(EType_t type, Bool_t on); |
6ab674bd | 84 | |
45fa0297 | 85 | static void SetPrintRepetitions(Bool_t on); |
86 | ||
c4cb6153 | 87 | static void WriteToFile(const char* name, Int_t option = 0); |
6ab674bd | 88 | |
89 | // the following public methods are used by the preprocessor macros | |
90 | // and should not be called directly | |
20848f77 | 91 | static Bool_t IsDebugEnabled() {return fgDebugEnabled;} |
6ab674bd | 92 | static Int_t GetDebugLevel(const char* module, const char* className); |
93 | static void Message(UInt_t level, const char* message, | |
94 | const char* module, const char* className, | |
95 | const char* function, const char* file, Int_t line); | |
96 | static void Debug(UInt_t level, const char* message, | |
97 | const char* module, const char* className, | |
98 | const char* function, const char* file, Int_t line); | |
99 | ||
44ce6bbe | 100 | static Int_t RedirectStdoutTo(EType_t type, UInt_t level, const char* module, |
eeb769e2 | 101 | const char* className, const char* function, |
102 | const char* file, Int_t line, Bool_t print); | |
44ce6bbe | 103 | static Int_t RedirectStderrTo(EType_t type, UInt_t level, const char* module, |
eeb769e2 | 104 | const char* className, const char* function, |
105 | const char* file, Int_t line, Bool_t print); | |
106 | static void RestoreStdout(Int_t original); | |
107 | static void RestoreStderr(Int_t original); | |
108 | ||
44ce6bbe | 109 | static ostream& Stream(EType_t type, UInt_t level, |
eeb769e2 | 110 | const char* module, const char* className, |
111 | const char* function, const char* file, Int_t line); | |
112 | ||
6ab674bd | 113 | private: |
6d7793cf | 114 | |
115 | // constructor is made private for implementing a singleton | |
116 | AliLog(); | |
117 | virtual ~AliLog(); | |
118 | ||
119 | // NOT IMPLEMENTED? | |
6ab674bd | 120 | AliLog(const AliLog& log); |
121 | AliLog& operator = (const AliLog& log); | |
122 | ||
eeb769e2 | 123 | void ReadEnvSettings(); |
124 | ||
6ab674bd | 125 | static void RootErrorHandler(Int_t level, Bool_t abort, |
126 | const char* location, const char* message); | |
127 | ||
128 | void CloseFile(Int_t type); | |
129 | FILE* GetOutputStream(Int_t type); | |
130 | ||
131 | UInt_t GetLogLevel(const char* module, const char* className) const; | |
eeb769e2 | 132 | void PrintMessage(UInt_t type, const char* message, |
133 | const char* module, const char* className, | |
134 | const char* function, | |
135 | const char* file, Int_t line); | |
1948744e | 136 | |
137 | void PrintString(Int_t type, FILE* stream, const char* format, ...); | |
45fa0297 | 138 | void PrintRepetitions(); |
eeb769e2 | 139 | |
44ce6bbe | 140 | Int_t RedirectTo(FILE* stream, EType_t type, UInt_t level, |
eeb769e2 | 141 | const char* module, const char* className, |
142 | const char* function, | |
143 | const char* file, Int_t line, Bool_t print); | |
144 | ||
44ce6bbe | 145 | ostream& GetStream(EType_t type, UInt_t level, |
eeb769e2 | 146 | const char* module, const char* className, |
147 | const char* function, const char* file, Int_t line); | |
6ab674bd | 148 | |
149 | enum {kDebugOffset = kDebug-1}; | |
150 | ||
151 | static AliLog* fgInstance; //! pointer to current instance | |
6ab674bd | 152 | static Bool_t fgDebugEnabled; // flag for debug en-/disabling |
55247085 | 153 | static Bool_t fgCoreEnabled; // flag for core dump en-/disabling |
6ab674bd | 154 | |
155 | UInt_t fGlobalLogLevel; // global logging level | |
156 | TObjArray fModuleDebugLevels; // debug levels for modules | |
157 | TObjArray fClassDebugLevels; // debug levels for classes | |
158 | ||
159 | Int_t fOutputTypes[kMaxType]; // types of output streams | |
160 | TString fFileNames[kMaxType]; // file names | |
161 | FILE* fOutputFiles[kMaxType]; //! log output files | |
1948744e | 162 | ostream* fOutputStreams[kMaxType]; //! log output streams |
6ab674bd | 163 | |
164 | Bool_t fPrintType[kMaxType]; // print type on/off | |
165 | Bool_t fPrintModule[kMaxType]; // print module on/off | |
166 | Bool_t fPrintScope[kMaxType]; // print scope/class name on/off | |
167 | Bool_t fPrintLocation[kMaxType]; // print file and line on/off | |
168 | ||
45fa0297 | 169 | Bool_t fPrintRepetitions; // print number of repetitions instead of repeated message on/off |
170 | ||
171 | Int_t fRepetitions; //! counter of repetitions | |
172 | UInt_t fLastType; //! type of last message | |
173 | TString fLastMessage; //! last message | |
174 | TString fLastModule; //! module name of last message | |
175 | TString fLastClassName; //! class name of last message | |
176 | TString fLastFunction; //! function name of last message | |
177 | TString fLastFile; //! file name of last message | |
178 | Int_t fLastLine; //! line number of last message | |
1948744e | 179 | AliLogNotification fCallBacks[kMaxType]; //! external notification callback |
45fa0297 | 180 | |
6ab674bd | 181 | ClassDef(AliLog, 1) // class for logging debug, info and error messages |
182 | }; | |
183 | ||
eeb769e2 | 184 | |
6d7793cf | 185 | // module name macro |
eb5bc777 | 186 | #ifdef _MODULE_ |
13242232 | 187 | # define MODULENAME() _MODULE_ |
eeb769e2 | 188 | #else |
13242232 | 189 | # define MODULENAME() "NoModule" |
cd676389 | 190 | #endif |
eeb769e2 | 191 | |
6d7793cf | 192 | // function name macro |
eeb769e2 | 193 | #if defined(__GNUC__) || defined(__ICC) || defined(__ECC) || defined(__APPLE__) |
13242232 | 194 | # define FUNCTIONNAME() __FUNCTION__ |
92154bc0 | 195 | // #elif defined(__HP_aCC) || defined(__alpha) || defined(__DECCXX) |
196 | // #define FUNCTIONNAME() __FUNC__ | |
eeb769e2 | 197 | #else |
13242232 | 198 | # define FUNCTIONNAME() "???" |
cd676389 | 199 | #endif |
6ab674bd | 200 | |
eeb769e2 | 201 | // redirection |
13242232 | 202 | /** |
203 | * Redirect output to std::cout to specified log stream | |
204 | * | |
205 | * @param type Type of stream to re-direct to | |
206 | * @param level Level of output | |
207 | * @param scope Scope | |
208 | * @param whatever Any code that will output to std::cout | |
209 | */ | |
210 | #define REDIRECTSTDOUT(type, level, scope, whatever) \ | |
211 | do {Int_t originalStdout = AliLog::RedirectStdoutTo(type, level, MODULENAME(), scope, FUNCTIONNAME(), __FILE__, __LINE__, kFALSE); \ | |
212 | whatever; AliLog::RestoreStdout(originalStdout);} while(false) | |
213 | /** | |
214 | * Redirect output to std::cerr to specified log stream | |
215 | * | |
216 | * @param type Type of stream to re-direct to | |
217 | * @param level Level of output | |
218 | * @param scope Scope | |
219 | * @param whatever Any code that will output to std::cout | |
220 | */ | |
221 | #define REDIRECTSTDERR(type, level, scope, whatever) \ | |
222 | do {Int_t originalStderr = AliLog::RedirectStderrTo(type, level, MODULENAME(), scope, FUNCTIONNAME(), __FILE__, __LINE__, kFALSE); \ | |
223 | whatever; AliLog::RestoreStderr(originalStderr);} while(false) | |
224 | /** | |
225 | * Redirect output to std::cout and std::cerr to specified log stream | |
226 | * | |
227 | * @param type Type of stream to re-direct to | |
228 | * @param level Level of output | |
229 | * @param scope Scope | |
230 | * @param whatever Any code that will output to std::cout or std::cerr | |
231 | */ | |
232 | #define REDIRECTSTDOUTANDSTDERR(type, level, scope, whatever) \ | |
233 | do {Int_t originalStdout = AliLog::RedirectStdoutTo(type, level, MODULENAME(), scope, FUNCTIONNAME(), __FILE__, __LINE__, kFALSE); \ | |
234 | Int_t originalStderr = AliLog::RedirectStderrTo(type, level, MODULENAME(), scope, FUNCTIONNAME(), __FILE__, __LINE__, kFALSE); \ | |
235 | whatever; AliLog::RestoreStderr(originalStderr); AliLog::RestoreStdout(originalStdout);} while(false) | |
eeb769e2 | 236 | |
237 | ||
238 | // debug level | |
6ab674bd | 239 | #ifdef LOG_NO_DEBUG |
13242232 | 240 | # define AliDebugLevel() -1 |
241 | # define AliDebugLevelClass() -1 | |
242 | # define AliDebugLevelGeneral(scope) -1 | |
6ab674bd | 243 | #else |
13242232 | 244 | /** |
245 | * Get the object scope debug level | |
246 | */ | |
247 | # define AliDebugLevel() ((AliLog::IsDebugEnabled()) ? AliLog::GetDebugLevel(MODULENAME(), ClassName()) : -1) | |
248 | /** | |
249 | * Get the class (ROOT-enabled) debug level | |
250 | */ | |
251 | # define AliDebugLevelClass() ((AliLog::IsDebugEnabled()) ? AliLog::GetDebugLevel(MODULENAME(), Class()->GetName()) : -1) | |
252 | /** | |
253 | * Get the debug level associated with scope | |
254 | * @param scope Scope | |
255 | */ | |
256 | # define AliDebugLevelGeneral(scope) ((AliLog::IsDebugEnabled()) ? AliLog::GetDebugLevel(MODULENAME(), scope) : -1) | |
6ab674bd | 257 | #endif |
258 | ||
eeb769e2 | 259 | // debug messages |
6ab674bd | 260 | #ifdef LOG_NO_DEBUG |
13242232 | 261 | # define AliDebug(level, message) do { } while (false) |
262 | # define AliDebugClass(level, message) do { } while (false) | |
263 | # define AliDebugGeneral(scope, level, message) do { } while (false) | |
264 | # define AliDebugF(level, message,...) do { } while (false) | |
265 | # define AliDebugClassF(level, message,...) do { } while (false) | |
266 | # define AliDebugGeneralF(scope, level, message,...) do { } while (false) | |
6ab674bd | 267 | #else |
c2deee9d | 268 | |
269 | // inspired by log4cxx code (see log4cxx/Logger.h) | |
270 | // implements GCC branch prediction for increasing logging performance | |
13242232 | 271 | # if !defined(ALIROOT_UNLIKELY) |
272 | # if defined(__GNUC__) && (__GNUC__ >= 3) | |
c2deee9d | 273 | /** |
13242232 | 274 | * Provides optimization hint to the compiler |
275 | * to optimize for the expression being false. | |
276 | * @param expr boolean expression. | |
277 | * @returns value of expression. | |
278 | */ | |
279 | # define ALIROOT_UNLIKELY(expr) __builtin_expect(expr, 0) | |
280 | # else | |
c2deee9d | 281 | /** |
13242232 | 282 | * Provides optimization hint to the compiler |
283 | * to optimize for the expression being false. | |
284 | * @param expr boolean expression. | |
285 | * @returns value of expression. | |
286 | */ | |
287 | # define ALIROOT_UNLIKELY(expr) expr | |
288 | # endif | |
289 | # endif | |
c2deee9d | 290 | |
291 | /** | |
13242232 | 292 | * |
293 | * Logs a message to a specified logger with the DEBUG level. | |
294 | * | |
295 | * @param logLevel the debug level. | |
296 | * @param message message to print in the following format: Form(message). | |
297 | * Note, that message should contain balanced parenthesis, like | |
298 | * <code>AliDebug(1, Form("Failed to decode line %d of %s", line, filename));</code> | |
299 | */ | |
300 | # define AliDebug(logLevel, message) \ | |
c2deee9d | 301 | do { if (ALIROOT_UNLIKELY(AliLog::IsDebugEnabled() && AliLog::GetDebugLevel(MODULENAME(), ClassName()) >= logLevel)) {\ |
302 | AliLog::Debug(logLevel, message, MODULENAME(), ClassName(), FUNCTIONNAME(), __FILE__, __LINE__); }} while (0) | |
c2deee9d | 303 | /** |
13242232 | 304 | * |
305 | * Logs a message to a specified logger with the DEBUG level. For use | |
306 | * in static member functions of a class | |
307 | * | |
308 | * @param logLevel the debug level. | |
309 | * @param message message to print in the following format: Form(message). | |
310 | * Note, that message should contain balanced parenthesis, like | |
311 | * <code>AliDebug(1, Form("Failed to decode line %d of %s", line, filename));</code> | |
312 | */ | |
313 | # define AliDebugClass(logLevel, message) \ | |
c2deee9d | 314 | do { if (ALIROOT_UNLIKELY(AliLog::IsDebugEnabled() && AliLog::GetDebugLevel(MODULENAME(), Class()->GetName()) >= logLevel)) {\ |
315 | AliLog::Debug(logLevel, message, MODULENAME(), Class()->GetName(), FUNCTIONNAME(), __FILE__, __LINE__); }} while (0) | |
316 | ||
317 | /** | |
13242232 | 318 | * Logs a message to a specified logger with the DEBUG level. For use |
319 | * in non-ROOT-enabled-class scope. | |
320 | * | |
321 | * @param scope the logging scope. | |
322 | * @param logLevel the debug level. | |
323 | * @param message message to print in the following format: Form(message). | |
324 | * Note, that message should contain balanced parenthesis, like | |
325 | * <code>AliDebug(1, Form("Failed to decode line %d of %s", line, filename));</code> | |
c2deee9d | 326 | */ |
13242232 | 327 | # define AliDebugGeneral(scope, logLevel, message) \ |
c2deee9d | 328 | do { if (ALIROOT_UNLIKELY(AliLog::IsDebugEnabled() && AliLog::GetDebugLevel(MODULENAME(), scope) >= logLevel)) {\ |
329 | AliLog::Debug(logLevel, message, MODULENAME(), scope, FUNCTIONNAME(), __FILE__, __LINE__); }} while (0) | |
13242232 | 330 | /** |
331 | * Macro to output debugging information. This excepts a printf-like | |
332 | * format statement. Note, at least 3 arguments (in total) must be | |
333 | * passed. | |
334 | * | |
335 | * @param logLevel Debug level | |
336 | * @param format Printf-like format. | |
337 | */ | |
338 | # define AliDebugF(logLevel,format,...) \ | |
339 | do { if (ALIROOT_UNLIKELY(AliLog::IsDebugEnabled() && AliLog::GetDebugLevel(MODULENAME(), ClassName()) >= logLevel)) { \ | |
340 | TString m;m.Form(format,__VA_ARGS__); \ | |
341 | AliLog::Debug(logLevel, m, MODULENAME(), ClassName(), FUNCTIONNAME(), __FILE__, __LINE__); }} while (0) | |
342 | /** | |
343 | * Outut debug information, filtered on debug level. For use in | |
344 | * static member function of a ROOT-enabled class. This excepts a | |
345 | * printf-like format statement. Note, at least 3 arguments (in | |
346 | * total) must be passed. | |
347 | * | |
348 | * @param logLevel Debug level | |
349 | * @param format Printf-like format | |
350 | * | |
351 | * @return | |
352 | */ | |
353 | # define AliDebugClassF(logLevel,format,...) \ | |
354 | do { if (ALIROOT_UNLIKELY(AliLog::IsDebugEnabled() && AliLog::GetDebugLevel(MODULENAME(), Class()->GetName()) >= logLevel)) { \ | |
355 | TString m;m.Form(format,__VA_ARGS__); \ | |
356 | AliLog::Debug(logLevel, m, MODULENAME(), Class()->GetName(), FUNCTIONNAME(), __FILE__, __LINE__); }} while (0) | |
357 | /** | |
358 | * Outut debug information, filtered on debug level. For use in | |
359 | * static member function of a non-ROOT-enabled class-scope. This | |
360 | * excepts a printf-like format statement. Note, at least 3 arguments | |
361 | * (in total) must be passed. | |
362 | * | |
363 | * @param scope Scope | |
364 | * @param logLevel Debug level | |
365 | * @param format Printf-like format | |
366 | * | |
367 | * @return | |
368 | */ | |
369 | # define AliDebugGeneralF(scope,logLevel,format,...) \ | |
370 | do { if (ALIROOT_UNLIKELY(AliLog::IsDebugEnabled() && AliLog::GetDebugLevel(MODULENAME(), scope) >= logLevel)) { \ | |
371 | TString m;m.Form(format,__VA_ARGS__); \ | |
372 | AliLog::Debug(logLevel, m, MODULENAME(), scope, FUNCTIONNAME(), __FILE__, __LINE__); }} while (0) | |
373 | ||
6ab674bd | 374 | #endif |
375 | ||
eeb769e2 | 376 | // redirection to debug |
377 | #define StdoutToAliDebug(level, whatever) REDIRECTSTDOUT(AliLog::kDebug, level, ClassName(), whatever) | |
378 | #define StderrToAliDebug(level, whatever) REDIRECTSTDERR(AliLog::kDebug, level, ClassName(), whatever) | |
379 | #define ToAliDebug(level, whatever) REDIRECTSTDOUTANDSTDERR(AliLog::kDebug, level, ClassName(), whatever) | |
380 | #define StdoutToAliDebugClass(level, whatever) REDIRECTSTDOUT(AliLog::kDebug, level, Class()->GetName(), whatever) | |
381 | #define StderrToAliDebugClass(level, whatever) REDIRECTSTDERR(AliLog::kDebug, level, Class()->GetName(), whatever) | |
382 | #define ToAliDebugClass(level, whatever) REDIRECTSTDOUTANDSTDERR(AliLog::kDebug, level, Class()->GetName(), whatever) | |
383 | #define StdoutToAliDebugGeneral(scope, level, whatever) REDIRECTSTDOUT(AliLog::kDebug, level, scope, whatever) | |
384 | #define StderrToAliDebugGeneral(scope, level, whatever) REDIRECTSTDERR(AliLog::kDebug, level, scope, whatever) | |
385 | #define ToAliDebugGeneral(scope, level, whatever) REDIRECTSTDOUTANDSTDERR(AliLog::kDebug, level, scope, whatever) | |
386 | ||
387 | // debug stream objects | |
388 | #define AliDebugStream(level) AliLog::Stream(AliLog::kDebug, level, MODULENAME(), ClassName(), FUNCTIONNAME(), __FILE__, __LINE__) | |
389 | #define AliDebugClassStream(level) AliLog::Stream(AliLog::kDebug, level, MODULENAME(), Class()->GetName(), FUNCTIONNAME(), __FILE__, __LINE__) | |
390 | #define AliDebugGeneralStream(scope, level) AliLog::Stream(AliLog::kDebug, level, MODULENAME(), scope, FUNCTIONNAME(), __FILE__, __LINE__) | |
391 | ||
392 | ||
13242232 | 393 | /** |
394 | * Macro that will output stuff using the logging facilities. | |
395 | * | |
396 | * @param lvl Message level | |
397 | * @param message Message to show | |
398 | */ | |
399 | #define AliMessage(lvl,message) do { \ | |
400 | AliLog::Message(lvl, message, MODULENAME(), ClassName(), FUNCTIONNAME(), __FILE__, __LINE__);} while(false) | |
401 | /** | |
402 | * Macro that will output stuff using the logging facilities. | |
403 | * For use in static member function of ROOT-enabled class-scope. | |
404 | * | |
405 | * @param lvl Message level | |
406 | * @param message Message to show | |
407 | */ | |
408 | #define AliMessageClass(lvl,message) do { \ | |
409 | AliLog::Message(lvl, message, MODULENAME(), Class()->GetName(), FUNCTIONNAME(), __FILE__, __LINE__);} while(false) | |
410 | /** | |
411 | * Macro that will output stuff using the logging facilities. | |
412 | * For use in non-ROOT-enabled class-scope. | |
413 | * | |
414 | * @param scope Scope | |
415 | * @param lvl Message level | |
416 | * @param message Message to show | |
417 | */ | |
418 | #define AliMessageGeneral(scope,lvl,message) do { \ | |
419 | AliLog::Message(lvl, message, MODULENAME(), scope, FUNCTIONNAME(), __FILE__, __LINE__);} while(false) | |
420 | /** | |
421 | * Print a message using the AliLog logging facility. This macro | |
422 | * accepts printf-like format arguments. Note, at least 3 arguments | |
423 | * must be passed. | |
424 | * @code | |
425 | * AliMessageF(1, "foo"); // <-- Failes | |
426 | * AliMessageF(1, "foo %d", 42); // <-- OK | |
427 | * @endcode | |
428 | * | |
429 | * @param lvl Message level | |
430 | * @param format printf-like format | |
431 | */ | |
432 | #define AliMessageF(lvl,format,...) do { \ | |
433 | TString m; m.Form(format,__VA_ARGS__); \ | |
434 | AliLog::Message(lvl, m, MODULENAME(), ClassName(), FUNCTIONNAME(), __FILE__, __LINE__);} while(false) | |
435 | /** | |
436 | * Print a message using the AliLog logging facility. This macro | |
437 | * accepts printf-like format arguments. Note, at least 3 arguments | |
438 | * must be passed. | |
439 | * @code | |
440 | * AliMessageF(1, "foo"); // <-- Failes | |
441 | * AliMessageF(1, "foo %d", 42); // <-- OK | |
442 | * @endcode | |
443 | * | |
444 | * This is for static member function in for ROOT-enabled class-scope | |
445 | * | |
446 | * @param lvl Message level | |
447 | * @param format printf-like format | |
448 | */ | |
449 | #define AliMessageClassF(lvl,format,...) do { \ | |
450 | TString m; m.Form(format,__VA_ARGS__); \ | |
451 | AliLog::Message(lvl, m, MODULENAME(), Class()->GetName(), FUNCTIONNAME(), __FILE__, __LINE__);} while(false) | |
452 | /** | |
453 | * Print a message using the AliLog logging facility. This macro | |
454 | * accepts printf-like format arguments. Note, at least 3 arguments | |
455 | * must be passed. | |
456 | * @code | |
457 | * AliMessageF(1, "foo"); // <-- Failes | |
458 | * AliMessageF(1, "foo %d", 42); // <-- OK | |
459 | * @endcode | |
460 | * | |
461 | * This is for non-ROOT-enabled class-scope | |
462 | * | |
463 | * @param scope Scope | |
464 | * @param lvl Message level | |
465 | * @param format printf-like format | |
466 | */ | |
467 | #define AliMessageGeneralF(scope,lvl,format,...) do { \ | |
468 | TString m; m.Form(format,__VA_ARGS__); \ | |
469 | AliLog::Message(lvl, m, MODULENAME(), scope, FUNCTIONNAME(), __FILE__, __LINE__);} while(false) | |
470 | ||
eeb769e2 | 471 | // info messages |
6ab674bd | 472 | #ifdef LOG_NO_INFO |
13242232 | 473 | # define AliInfo(message) do { } while (false) |
474 | # define AliInfoClass(message) do { } while (false) | |
475 | # define AliInfoGeneral(scope, message) do { } while (false) | |
476 | # define AliInfoF(message,...) do { } while (false) | |
477 | # define AliInfoClassF(message,...) do { } while (false) | |
478 | # define AliInfoGeneralF(scope, message,...) do { } while (false) | |
6ab674bd | 479 | #else |
13242232 | 480 | /** |
481 | * Forwards to AliMessage with log level of AliLog::kInfo | |
482 | * @see AliMessage | |
483 | */ | |
484 | # define AliInfo(message) AliMessage(AliLog::kInfo, message) | |
485 | /** | |
486 | * Forwards to AliMessageClass with log level of AliLog::kInfo | |
487 | * @see AliMessageClass | |
488 | */ | |
489 | # define AliInfoClass(message) AliMessageClass(AliLog::kInfo, message) | |
490 | /** | |
491 | * Forwards to AliMessageGeneral with log level of AliLog::kInfo | |
492 | * @see AliMessageGeneral | |
493 | */ | |
494 | # define AliInfoGeneral(scope, message) AliMessageGeneral(scope, AliLog::kInfo, message) | |
495 | /** | |
496 | * Forwards to AliMessageF with log level of AliLog::kInfo | |
497 | * @see AliMessageF | |
498 | */ | |
499 | # define AliInfoF(message,...) AliMessageF(AliLog::kInfo, message, __VA_ARGS__) | |
500 | /** | |
501 | * Forwards to AliMessageClassF with log level of AliLog::kInfo | |
502 | * @see AliMessageClassF | |
503 | */ | |
504 | # define AliInfoClassF(message,...) AliMessageClassF(AliLog::kInfo, message, __VA_ARGS__) | |
505 | /** | |
506 | * Forwards to AliMessageGeneralF with log level of AliLog::kInfo | |
507 | * @see AliMessageGeneralF | |
508 | */ | |
509 | # define AliInfoGeneralF(scope,message,...) AliMessageGeneralF(scope, AliLog::kInfo, message, __VA_ARGS__) | |
6ab674bd | 510 | #endif |
511 | ||
eeb769e2 | 512 | // redirection to info |
513 | #define StdoutToAliInfo(whatever) REDIRECTSTDOUT(AliLog::kInfo, 0, ClassName(), whatever) | |
514 | #define StderrToAliInfo(whatever) REDIRECTSTDERR(AliLog::kInfo, 0, ClassName(), whatever) | |
515 | #define ToAliInfo(whatever) REDIRECTSTDOUTANDSTDERR(AliLog::kInfo, 0, ClassName(), whatever) | |
516 | #define StdoutToAliInfoClass(whatever) REDIRECTSTDOUT(AliLog::kInfo, 0, Class()->GetName(), whatever) | |
517 | #define StderrToAliInfoClass(whatever) REDIRECTSTDERR(AliLog::kInfo, 0, Class()->GetName(), whatever) | |
518 | #define ToAliInfoClass(whatever) REDIRECTSTDOUTANDSTDERR(AliLog::kInfo, 0, Class()->GetName(), whatever) | |
519 | #define StdoutToAliInfoGeneral(scope, whatever) REDIRECTSTDOUT(AliLog::kInfo, 0, scope, whatever) | |
520 | #define StderrToAliInfoGeneral(scope, whatever) REDIRECTSTDERR(AliLog::kInfo, 0, scope, whatever) | |
521 | #define ToAliInfoGeneral(scope, whatever) REDIRECTSTDOUTANDSTDERR(AliLog::kInfo, 0, scope, whatever) | |
522 | ||
523 | // info stream objects | |
524 | #define AliInfoStream() AliLog::Stream(AliLog::kInfo, 0, MODULENAME(), ClassName(), FUNCTIONNAME(), __FILE__, __LINE__) | |
525 | #define AliInfoClassStream() AliLog::Stream(AliLog::kInfo, 0, MODULENAME(), Class()->GetName(), FUNCTIONNAME(), __FILE__, __LINE__) | |
526 | #define AliInfoGeneralStream(scope) AliLog::Stream(AliLog::kInfo, 0, MODULENAME(), scope, FUNCTIONNAME(), __FILE__, __LINE__) | |
527 | ||
eeb769e2 | 528 | // warning messages |
6ab674bd | 529 | #ifdef LOG_NO_WARNING |
13242232 | 530 | # define AliWarning(message) do { } while (false) |
531 | # define AliWarningClass(message) do { } while (false) | |
532 | # define AliWarningGeneral(scope, message) do { } while (false) | |
533 | # define AliWarningF(message,...) do { } while (false) | |
534 | # define AliWarningClassF(message,...) do { } while (false) | |
535 | # define AliWarningGeneralF(scope, message,...) do { } while (false) | |
6ab674bd | 536 | #else |
13242232 | 537 | /** |
538 | * Forwards to AliMessage with log level of AliLog::kWarning | |
539 | * @see AliMessage | |
540 | */ | |
541 | # define AliWarning(message) AliMessage(AliLog::kWarning, message) | |
542 | /** | |
543 | * Forwards to AliMessageClass with log level of AliLog::kWarning | |
544 | * @see AliMessageClass | |
545 | */ | |
546 | # define AliWarningClass(message) AliMessageClass(AliLog::kWarning, message) | |
547 | /** | |
548 | * Forwards to AliMessageGeneral with log level of AliLog::kWarning | |
549 | * @see AliMessageGeneral | |
550 | */ | |
551 | # define AliWarningGeneral(scope, message) AliMessageGeneral(scope, AliLog::kWarning, message) | |
552 | /** | |
553 | * Forwards to AliMessageF with log level of AliLog::kWarning | |
554 | * @see AliMessageF | |
555 | */ | |
556 | # define AliWarningF(message,...) AliMessageF(AliLog::kWarning, message, __VA_ARGS__) | |
557 | /** | |
558 | * Forwards to AliMessageClassF with log level of AliLog::kWarning | |
559 | * @see AliMessageClassF | |
560 | */ | |
561 | # define AliWarningClassF(message,...) AliMessageClassF(AliLog::kWarning, message, __VA_ARGS__) | |
562 | /** | |
563 | * Forwards to AliMessageGeneralF with log level of AliLog::kWarning | |
564 | * @see AliMessageGeneralF | |
565 | */ | |
566 | # define AliWarningGeneralF(scope,message,...) AliMessageGeneralF(scope, AliLog::kWarning, message, __VA_ARGS__) | |
6ab674bd | 567 | #endif |
568 | ||
eeb769e2 | 569 | // redirection to warning |
570 | #define StdoutToAliWarning(whatever) REDIRECTSTDOUT(AliLog::kWarning, 0, ClassName(), whatever) | |
571 | #define StderrToAliWarning(whatever) REDIRECTSTDERR(AliLog::kWarning, 0, ClassName(), whatever) | |
572 | #define ToAliWarning(whatever) REDIRECTSTDOUTANDSTDERR(AliLog::kWarning, 0, ClassName(), whatever) | |
573 | #define StdoutToAliWarningClass(whatever) REDIRECTSTDOUT(AliLog::kWarning, 0, Class()->GetName(), whatever) | |
574 | #define StderrToAliWarningClass(whatever) REDIRECTSTDERR(AliLog::kWarning, 0, Class()->GetName(), whatever) | |
575 | #define ToAliWarningClass(whatever) REDIRECTSTDOUTANDSTDERR(AliLog::kWarning, 0, Class()->GetName(), whatever) | |
576 | #define StdoutToAliWarningGeneral(scope, whatever) REDIRECTSTDOUT(AliLog::kWarning, 0, scope, whatever) | |
577 | #define StderrToAliWarningGeneral(scope, whatever) REDIRECTSTDERR(AliLog::kWarning, 0, scope, whatever) | |
578 | #define ToAliWarningGeneral(scope, whatever) REDIRECTSTDOUTANDSTDERR(AliLog::kWarning, 0, scope, whatever) | |
579 | ||
580 | // warning stream objects | |
581 | #define AliWarningStream() AliLog::Stream(AliLog::kWarning, 0, MODULENAME(), ClassName(), FUNCTIONNAME(), __FILE__, __LINE__) | |
582 | #define AliWarningClassStream() AliLog::Stream(AliLog::kWarning, 0, MODULENAME(), Class()->GetName(), FUNCTIONNAME(), __FILE__, __LINE__) | |
583 | #define AliWarningGeneralStream(scope) AliLog::Stream(AliLog::kWarning, 0, MODULENAME(), scope, FUNCTIONNAME(), __FILE__, __LINE__) | |
584 | ||
585 | ||
586 | // error messages | |
13242232 | 587 | /** |
588 | * Forwards to AliMessage with log level of AliLog::kError | |
589 | * @see AliMessage | |
590 | */ | |
591 | #define AliError(message) AliMessage(AliLog::kError, message) | |
592 | /** | |
593 | * Forwards to AliMessageClass with log level of AliLog::kError | |
594 | * @see AliMessageClass | |
595 | */ | |
596 | #define AliErrorClass(message) AliMessageClass(AliLog::kError, message) | |
597 | /** | |
598 | * Forwards to AliMessageGeneral with log level of AliLog::kError | |
599 | * @see AliMessageGeneral | |
600 | */ | |
601 | #define AliErrorGeneral(scope, message) AliMessageGeneral(scope, AliLog::kError, message) | |
602 | /** | |
603 | * Forwards to AliMessageF with log level of AliLog::kError | |
604 | * @see AliMessageF | |
605 | */ | |
606 | #define AliErrorF(message,...) AliMessageF(AliLog::kError, message, __VA_ARGS__) | |
607 | /** | |
608 | * Forwards to AliMessageClassF with log level of AliLog::kError | |
609 | * @see AliMessageClassF | |
610 | */ | |
611 | #define AliErrorClassF(message,...) AliMessageClassF(AliLog::kError, message, __VA_ARGS__) | |
612 | /** | |
613 | * Forwards to AliMessageGeneralF with log level of AliLog::kError | |
614 | * @see AliMessageGeneralF | |
615 | */ | |
616 | #define AliErrorGeneralF(scope,message,...) AliMessageGeneralF(scope, AliLog::kError, message, __VA_ARGS__) | |
eeb769e2 | 617 | |
618 | // redirection to error | |
619 | #define StdoutToAliError(whatever) REDIRECTSTDOUT(AliLog::kError, 0, ClassName(), whatever) | |
620 | #define StderrToAliError(whatever) REDIRECTSTDERR(AliLog::kError, 0, ClassName(), whatever) | |
621 | #define ToAliError(whatever) REDIRECTSTDOUTANDSTDERR(AliLog::kError, 0, ClassName(), whatever) | |
622 | #define StdoutToAliErrorClass(whatever) REDIRECTSTDOUT(AliLog::kError, 0, Class()->GetName(), whatever) | |
623 | #define StderrToAliErrorClass(whatever) REDIRECTSTDERR(AliLog::kError, 0, Class()->GetName(), whatever) | |
624 | #define ToAliErrorClass(whatever) REDIRECTSTDOUTANDSTDERR(AliLog::kError, 0, Class()->GetName(), whatever) | |
625 | #define StdoutToAliErrorGeneral(scope, whatever) REDIRECTSTDOUT(AliLog::kError, 0, scope, whatever) | |
626 | #define StderrToAliErrorGeneral(scope, whatever) REDIRECTSTDERR(AliLog::kError, 0, scope, whatever) | |
627 | #define ToAliErrorGeneral(scope, whatever) REDIRECTSTDOUTANDSTDERR(AliLog::kError, 0, scope, whatever) | |
628 | ||
629 | // error stream objects | |
630 | #define AliErrorStream() AliLog::Stream(AliLog::kError, 0, MODULENAME(), ClassName(), FUNCTIONNAME(), __FILE__, __LINE__) | |
631 | #define AliErrorClassStream() AliLog::Stream(AliLog::kError, 0, MODULENAME(), Class()->GetName(), FUNCTIONNAME(), __FILE__, __LINE__) | |
632 | #define AliErrorGeneralStream(scope) AliLog::Stream(AliLog::kError, 0, MODULENAME(), scope, FUNCTIONNAME(), __FILE__, __LINE__) | |
633 | ||
6ab674bd | 634 | |
eeb769e2 | 635 | // fatal messages |
13242232 | 636 | /** |
637 | * Forwards to AliMessage with log level of AliLog::kFatal | |
638 | * @see AliMessage | |
639 | */ | |
640 | #define AliFatal(message) AliMessage(AliLog::kFatal, message) | |
641 | /** | |
642 | * Forwards to AliMessageClass with log level of AliLog::kFatal | |
643 | * @see AliMessageClass | |
644 | */ | |
645 | #define AliFatalClass(message) AliMessageClass(AliLog::kFatal, message) | |
646 | /** | |
647 | * Forwards to AliMessageGeneral with log level of AliLog::kFatal | |
648 | * @see AliMessageGeneral | |
649 | */ | |
650 | #define AliFatalGeneral(scope, message) AliMessageGeneral(scope, AliLog::kFatal, message) | |
651 | /** | |
652 | * Forwards to AliMessageF with log level of AliLog::kFatal | |
653 | * @see AliMessageF | |
654 | */ | |
655 | #define AliFatalF(message,...) AliMessageF(AliLog::kFatal, message, __VA_ARGS__) | |
656 | /** | |
657 | * Forwards to AliMessageClassF with log level of AliLog::kFatal | |
658 | * @see AliMessageClassF | |
659 | */ | |
660 | #define AliFatalClassF(message,...) AliMessageClassF(AliLog::kFatal, message, __VA_ARGS__) | |
661 | /** | |
662 | * Forwards to AliMessageGeneralF with log level of AliLog::kFatal | |
663 | * @see AliMessageGeneralF | |
664 | */ | |
665 | #define AliFatalGeneralF(scope,message,...) AliMessageGeneralF(scope, AliLog::kFatal, message, __VA_ARGS__) | |
6ab674bd | 666 | |
667 | #endif |