3 #ifndef ALIHLTLOGGING_H
4 #define ALIHLTLOGGING_H
5 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * See cxx source for full Copyright notice */
9 the HLT logging methods
13 #include "AliHLTDataTypes.h"
17 #define LOG_BUFFER_SIZE 100 // global logging buffer
18 //#define LOG_PREFIX "" // logging prefix, for later extensions
21 /* the logging macros can be used inside methods of classes which inherit from
24 // HLTMessage is not filtered
25 #define HLTMessage( ... ) LoggingVarargs(kHLTLogNone, NULL , NULL , __VA_ARGS__ )
27 // the following macros are filtered by the Global and Local Log Filter
28 #define HLTBenchmark( ... ) LoggingVarargs(kHLTLogBenchmark, this->Class_Name() , __func__ , __VA_ARGS__ )
29 #define HLTDebug( ... ) LoggingVarargs(kHLTLogDebug, this->Class_Name() , __func__ , __VA_ARGS__ )
30 #define HLTInfo( ... ) LoggingVarargs(kHLTLogInfo, this->Class_Name() , __func__ , __VA_ARGS__ )
31 #define HLTWarning( ... ) LoggingVarargs(kHLTLogWarning, this->Class_Name() , __func__ , __VA_ARGS__ )
32 #define HLTError( ... ) LoggingVarargs(kHLTLogError, this->Class_Name() , __func__ , __VA_ARGS__ )
33 #define HLTFatal( ... ) LoggingVarargs(kHLTLogFatal, this->Class_Name() , __func__ , __VA_ARGS__ )
35 // helper macro to set the keyword
36 #define HLTLogKeyword(a) AliHLTKeyword __hltlog_tmpkey__LINE__(this, a)
38 #define HLT_DEFAULT_LOG_KEYWORD "no key"
43 virtual ~AliHLTLogging();
45 // logging filter for all objects
47 static AliHLTComponent_LogSeverity SetGlobalLogLevel(AliHLTComponent_LogSeverity iLogFilter) {fGlobalLogFilter=iLogFilter; return fGlobalLogFilter;}
49 // logging filter for individual object
51 AliHLTComponent_LogSeverity SetLocalLogLevel(AliHLTComponent_LogSeverity iLogFilter) {fLocalLogFilter=iLogFilter; return fLocalLogFilter;}
53 // set the default key word
54 // the keyword is intended to simplify the use of logging macros
56 void SetDefaultKeyword(const char* keyword) { fpDefaultKeyword=keyword; }
58 // set a temporary keyword
59 // returns the old key value
60 const char* SetKeyword(const char* keyword)
62 const char* currentKeyword=fpCurrentKeyword;
63 fpCurrentKeyword=keyword;
64 return currentKeyword;
67 // get the current keyword
69 const char* GetKeyword()
71 if (fpCurrentKeyword) return fpCurrentKeyword;
72 else if (fpDefaultKeyword) return fpDefaultKeyword;
73 return HLT_DEFAULT_LOG_KEYWORD;
76 static int Init(AliHLTfctLogging pFun) { fLoggingFunc=pFun; return 0;}
78 // genaral logging function
80 int Logging( AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* message, ... );
82 // logging function with two origin parameters, used by the log macros
84 int LoggingVarargs( AliHLTComponent_LogSeverity severity, const char* origin_class, const char* origin_func, ... );
86 // apply filter, return 1 if message should pass
88 int CheckFilter(AliHLTComponent_LogSeverity severity);
90 static int Message(void * param, AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* message);
92 static const char* BuildLogString(const char *format, va_list ap);
94 virtual void* GetParameter() {return NULL;}
98 static AliHLTComponent_LogSeverity fGlobalLogFilter;
99 AliHLTComponent_LogSeverity fLocalLogFilter;
100 static char fLogBuffer[LOG_BUFFER_SIZE];
101 static char fOriginBuffer[LOG_BUFFER_SIZE];
102 static AliHLTfctLogging fLoggingFunc;
103 const char* fpDefaultKeyword;
104 const char* fpCurrentKeyword;
106 ClassDef(AliHLTLogging, 0)
109 /* the class AliHLTKeyword is a simple helper class used by the HLTLogKeyword macro
110 * HLTLogKeyword("a keyword") creates an object of AliHLTKeyword which sets the keyword for the logging class
111 * the object is destroyed automatically when the current scope is left and so the keyword is set
112 * to the original value
114 class AliHLTKeyword {
122 AliHLTKeyword(AliHLTLogging* parent, const char* keyword)
127 fpOriginal=fpParent->SetKeyword(keyword);
134 fpParent->SetKeyword(fpOriginal);
139 AliHLTLogging* fpParent;
140 const char* fpOriginal;