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