if (FindComponent(pSample->GetComponentID())==NULL) {
iResult=InsertComponent(pSample);
if (iResult>=0) {
- Logging(kHLTLogInfo, "BASE", "Component Handler", "component %s registered", pSample->GetComponentID());
+ HLTInfo("component %s registered", pSample->GetComponentID());
}
} else {
// component already registered
- Logging(kHLTLogInfo, "BASE", "Component Handler", "component %s already registered, skipped", pSample->GetComponentID());
+ HLTInfo("component %s already registered, skipped", pSample->GetComponentID());
iResult=-EEXIST;
}
} else {
if (pSample!=NULL) {
component=pSample->Spawn();
if (component) {
- Logging(kHLTLogDebug, "BASE", "Component Handler", "component \"%s\" created (%p)", componentID, component);
+ HLTDebug("component \"%s\" created (%p)", componentID, component);
component->Init(&fEnvironment, environ_param, argc, argv);
} else {
- Logging(kHLTLogError, "BASE", "Component Handler", "can not spawn component \"%s\"", componentID);
+ HLTError("can not spawn component \"%s\"", componentID);
iResult=-ENOENT;
}
} else {
- Logging(kHLTLogWarning, "BASE", "Component Handler", "can not find component \"%s\"", componentID);
+ HLTWarning("can not find component \"%s\"", componentID);
iResult=-ENOENT;
}
} else {
vector<AliHLTComponent*>::iterator element=fComponentList.begin();
int index=0;
while (element!=fComponentList.end()) {
- Logging(kHLTLogInfo, "BASE", "Component Handler", "%d. %s", index++, (*element++)->GetComponentID());
+ HLTInfo("%d. %s", index++, (*element++)->GetComponentID());
}
}
AliHLTLibHandle hLib=dlopen(libraryPath, RTLD_NOW);
if (hLib) {
AliHLTComponent::UnsetGlobalComponentHandler();
- Logging(kHLTLogDebug, "BASE", "Component Handler", "library %s loaded", libraryPath);
+ HLTDebug("library %s loaded", libraryPath);
fLibraryList.push_back(hLib);
vector<AliHLTComponent*>::iterator element=fScheduleList.begin();
int iSize=fScheduleList.size();
fScheduleList.erase(element);
}
} else {
- Logging(kHLTLogError, "BASE", "Component Handler", "can not load library %s", libraryPath);
- Logging(kHLTLogError, "BASE", "Component Handler", "dlopen error: %s", dlerror());
+ HLTError("can not load library %s", libraryPath);
+ HLTError("dlopen error: %s", dlerror());
iResult=-ELIBACC;
}
} else {
ClassImp(AliHLTConfiguration)
+/* the global configuration handler which is used to automatically register the configuration
+ */
+AliHLTConfigurationHandler* AliHLTConfiguration::fConfigurationHandler=NULL;
+
AliHLTConfiguration::AliHLTConfiguration()
{
fID=NULL;
fNofSources=-1;
fArguments=arguments;
fListSrcElement=fListSources.begin();
- AliHLTConfigurationHandler::RegisterConfiguration(this);
+ if (fConfigurationHandler) {
+ fConfigurationHandler->RegisterConfiguration(this);
+ } else {
+ HLTError("no configuration handler set, abort registration");
+ }
}
}
AliHLTConfiguration::~AliHLTConfiguration()
{
- if (AliHLTConfigurationHandler::FindConfiguration(fID)!=NULL) {
- AliHLTConfigurationHandler::RemoveConfiguration(this);
+ if (fConfigurationHandler) {
+ if (fConfigurationHandler->FindConfiguration(fID)!=NULL) {
+ fConfigurationHandler->RemoveConfiguration(this);
+ }
}
if (fArgv != NULL) {
if (fArgc>0) {
}
}
+int AliHLTConfiguration::GlobalInit(AliHLTConfigurationHandler* pHandler)
+{
+ int iResult=0;
+ if (fConfigurationHandler!=NULL) {
+ fConfigurationHandler->Logging(kHLTLogWarning, "AliHLTConfiguration::GlobalInit", HLT_DEFAULT_LOG_KEYWORD, "configuration handler already initialized, overriding object %p", fConfigurationHandler);
+ }
+ fConfigurationHandler=pHandler;
+ return iResult;
+}
+
+int AliHLTConfiguration::GlobalDeinit()
+{
+ int iResult=0;
+ fConfigurationHandler=NULL;
+ return iResult;
+}
+
const char* AliHLTConfiguration::GetName() const {
if (fID)
return fID;
{
int iResult=0;
if (fNofSources>=0 || bAuto && (iResult=ExtractSources())>=0) {
- //Logging(kHLTLogDebug, "BASE", "Configuration", "fNofSources=%d", fNofSources);
- //Logging(kHLTLogDebug, "BASE", "Configuration", "list size = %d", fListSources.size());
+ //HLTDebug("fNofSources=%d", fNofSources);
+ //HLTDebug("list size = %d", fListSources.size());
iResult=fNofSources==(int)fListSources.size();
}
return iResult;
void AliHLTConfiguration::PrintStatus()
{
- Logging(kHLTLogInfo, "BASE", "AliHLTConfiguration", "status of configuration \"%s\" (%p)", GetName(), this);
- if (fComponent) Logging(kHLTLogInfo, "BASE", "AliHLTConfiguration", " - component: \"%s\"", fComponent);
- else Logging(kHLTLogInfo, "BASE", "AliHLTConfiguration", " - component string invalid");
- if (fStringSources) Logging(kHLTLogInfo, "BASE", "AliHLTConfiguration", " - sources: \"%s\"", fStringSources);
- else Logging(kHLTLogInfo, "BASE", "AliHLTConfiguration", " - no sources");
+ HLTLogKeyword("configuration status");
+ HLTMessage("status of configuration \"%s\" (%p)", GetName(), this);
+ if (fComponent) HLTMessage(" - component: \"%s\"", fComponent);
+ else HLTMessage(" - component string invalid");
+ if (fStringSources) HLTMessage(" - sources: \"%s\"", fStringSources);
+ else HLTMessage(" - no sources");
if (SourcesResolved(1)<=0)
- Logging(kHLTLogInfo, "BASE", "AliHLTConfiguration", " there are unresolved sources");
+ HLTMessage(" there are unresolved sources");
AliHLTConfiguration* pSrc=GetFirstSource();
while (pSrc) {
- Logging(kHLTLogInfo, "BASE", "AliHLTConfiguration", " source \"%s\" (%p) resolved", pSrc->GetName(), pSrc);
+ HLTMessage(" source \"%s\" (%p) resolved", pSrc->GetName(), pSrc);
pSrc=GetNextSource();
}
}
if ((iResult=InterpreteString(fStringSources, tgtList))>=0) {
fNofSources=tgtList.size();
vector<char*>::iterator element=tgtList.begin();
- while ((element=tgtList.begin())!=tgtList.end() && iResult>=0) {
- AliHLTConfiguration* pConf=AliHLTConfigurationHandler::FindConfiguration(*element);
- if (pConf) {
- Logging(kHLTLogDebug, "BASE", "Configuration", "source \"%s\" inserted", pConf->GetName());
- fListSources.push_back(pConf);
- } else {
- Logging(kHLTLogError, "BASE", "Configuration", "can not find source \"%s\"", (*element));
- iResult=-ENOENT;
+ while ((element=tgtList.begin())!=tgtList.end()) {
+ if (fConfigurationHandler) {
+ AliHLTConfiguration* pConf=fConfigurationHandler->FindConfiguration(*element);
+ if (pConf) {
+ HLTDebug("source \"%s\" inserted", pConf->GetName());
+ fListSources.push_back(pConf);
+ } else {
+ HLTError("can not find source \"%s\"", (*element));
+ iResult=-ENOENT;
+ }
+ } else if (iResult>=0) {
+ iResult=-EFAULT;
+ HLTFatal("global configuration handler not initialized, can not resolve sources");
}
delete[] (*element);
tgtList.erase(element);
vector<char*> tgtList;
if ((iResult=InterpreteString(fArguments, tgtList))>=0) {
fArgc=tgtList.size();
- //Logging(kHLTLogDebug, "BASE", "Configuration", "found %d arguments", fArgc);
+ //HLTDebug("found %d arguments", fArgc);
if (fArgc>0) {
fArgv = new char*[fArgc];
if (fArgv) {
vector<char*>::iterator element=tgtList.begin();
int i=0;
while (element!=tgtList.end()) {
- //Logging(kHLTLogDebug, "BASE", "Configuration Handler", "assign arguments %d (%s)", i, *element);
+ //HLTDebug("assign arguments %d (%s)", i, *element);
fArgv[i++]=(*element);
element++;
}
{
int iResult=0;
if (arg) {
- //Logging(kHLTLogDebug, "BASE", "Configuration Handler", "interprete \"%s\"", arg);
+ //HLTDebug("interprete \"%s\"", arg);
int i=0;
int prec=-1;
do {
if (pEntry) {
strncpy(pEntry, &arg[prec], i-prec);
pEntry[i-prec]=0; // terminate string
- //Logging(kHLTLogDebug, "BASE", "Configuration Handler", "create string \"%s\", insert at %d", pEntry, argList.size());
+ //HLTDebug("create string \"%s\", insert at %d", pEntry, argList.size());
argList.push_back(pEntry);
} else
iResult=-ENOMEM;
iResult=pCH->CreateComponent(fConf->GetComponentID(), NULL, argc, argv, fpComponent);
if (fpComponent) {
} else {
- Logging(kHLTLogError, "BASE", "AliHLTTask", "can not find component \"%s\"", fConf->GetComponentID());
+ HLTError("can not find component \"%s\"", fConf->GetComponentID());
}
}
}
void AliHLTTask::PrintDependencyTree(const char* id, int bFromConfiguration)
{
+ HLTLogKeyword("task dependencies");
int iResult=0;
TList tgtList;
if (bFromConfiguration) {
} else
iResult=FollowDependency(id, &tgtList);
if (iResult>0) {
- Logging(kHLTLogInfo, "BASE", "AliHLTTask", " task \"%s\": dependency level %d ", GetName(), iResult);
+ HLTMessage(" task \"%s\": dependency level %d ", GetName(), iResult);
TObjLink* lnk=tgtList.FirstLink();
int i=iResult;
char* pSpace = new char[iResult+1];
pSpace[i]=0;
while (lnk) {
TObject* obj=lnk->GetObject();
- Logging(kHLTLogInfo, "BASE", "AliHLTTask", " %s^-- %s ", &pSpace[i--], obj->GetName());
+ HLTMessage(" %s^-- %s ", &pSpace[i--], obj->GetName());
lnk=lnk->Next();
}
delete [] pSpace;
AliHLTConfiguration* pSrc=fpConfiguration->GetFirstSource();
while (pSrc) {
if (FindDependency(pSrc->GetName())==NULL) {
- //Logging(kHLTLogDebug, "BASE", "AliHLTTask", "dependency \"%s\" unresolved", pSrc->GetName());
+ //HLTDebug("dependency \"%s\" unresolved", pSrc->GetName());
iResult++;
}
pSrc=fpConfiguration->GetNextSource();
if (fpConfiguration) {
iResult=fpConfiguration->GetSource(pTask->GetName())!=NULL;
if (iResult>0) {
- //Logging(kHLTLogDebug, "BASE", "AliHLTTask", "task \"%s\" depends on \"%s\"", GetName(), pTask->GetName());
+ //HLTDebug("task \"%s\" depends on \"%s\"", GetName(), pTask->GetName());
} else {
- //Logging(kHLTLogDebug, "BASE", "AliHLTTask", "task \"%s\" independend of \"%s\"", GetName(), pTask->GetName());
+ //HLTDebug("task \"%s\" independend of \"%s\"", GetName(), pTask->GetName());
}
} else {
iResult=-EFAULT;
void AliHLTTask::PrintStatus()
{
+ HLTLogKeyword("task properties");
if (fpComponent) {
- Logging(kHLTLogInfo, "BASE", "AliHLTTask", " component: %s (%p)", fpComponent->GetComponentID(), fpComponent);
+ HLTMessage(" component: %s (%p)", fpComponent->GetComponentID(), fpComponent);
} else {
- Logging(kHLTLogInfo, "BASE", "AliHLTTask", " no component set!");
+ HLTMessage(" no component set!");
}
if (fpConfiguration) {
AliHLTConfiguration* pSrc=fpConfiguration->GetFirstSource();
const char* pQualifier="unresolved";
if (FindDependency(pSrc->GetName()))
pQualifier="resolved";
- Logging(kHLTLogInfo, "BASE", "AliHLTTask", " source: %s (%s)", pSrc->GetName(), pQualifier);
+ HLTMessage(" source: %s (%s)", pSrc->GetName(), pQualifier);
pSrc=fpConfiguration->GetNextSource();
}
TObjLink* lnk = fListTargets.FirstLink();
while (lnk) {
TObject *obj = lnk->GetObject();
- Logging(kHLTLogInfo, "BASE", "AliHLTTask", " target: %s", obj->GetName());
+ HLTMessage(" target: %s", obj->GetName());
lnk = lnk->Next();
}
} else {
- Logging(kHLTLogInfo, "BASE", "AliHLTTask", " task \"%s\" not initialized", GetName());
+ HLTMessage(" task \"%s\" not initialized", GetName());
}
}
while (lnk) {
TObject* obj=lnk->GetObject();
if (fListConfigurations.FindObject(obj->GetName())==NULL) {
- Logging(kHLTLogDebug, "BASE", "Configuration Handler", "delete dynamic configuration \"%s\"", obj->GetName());
+ HLTDebug("delete dynamic configuration \"%s\"", obj->GetName());
delete obj;
}
lnk=lnk->Next();
if (pConf) {
if (FindConfiguration(pConf->GetName()) == NULL) {
fListConfigurations.Add(pConf);
- //Logging(kHLTLogDebug, "BASE", "Configuration Handler", "configuration \"%s\" registered", pConf->GetName());
+ //HLTDebug("configuration \"%s\" registered", pConf->GetName());
// mark all configurations with unresolved dependencies for re-evaluation
TObjLink* lnk=fListConfigurations.FirstLink();
}
} else {
iResult=-EEXIST;
- Logging(kHLTLogWarning, "BASE", "Configuration Handler", "configuration \"%s\" already registered", pConf->GetName());
+ HLTWarning("configuration \"%s\" already registered", pConf->GetName());
}
} else {
iResult=-EINVAL;
fListDynamicConfigurations.Add(pConf);
}
} else {
- Logging(kHLTLogError, "BASE", "Configuration Handler", "system error: object allocation failed");
+ HLTError("system error: object allocation failed");
iResult=-ENOMEM;
}
return iResult;
void AliHLTConfigurationHandler::PrintConfigurations()
{
- Logging(kHLTLogInfo, "BASE", "Configuration Handler", "registered configurations:");
+ HLTLogKeyword("configuration listing");
+ HLTMessage("registered configurations:");
TObjLink *lnk = fListConfigurations.FirstLink();
while (lnk) {
TObject *obj = lnk->GetObject();
- Logging(kHLTLogInfo, "BASE", "Configuration Handler", " %s", obj->GetName());
+ HLTMessage(" %s", obj->GetName());
lnk = lnk->Next();
}
}
if ((pConf=FindConfiguration(id))!=NULL) {
iResult=RemoveConfiguration(pConf);
} else {
- Logging(kHLTLogWarning, "BASE", "Configuration Handler", "can not find configuration \"%s\"", id);
+ HLTWarning("can not find configuration \"%s\"", id);
iResult=-ENOENT;
}
} else {
#include "AliHLTDataTypes.h"
#include "AliHLTLogging.h"
-
+class AliHLTConfigurationHandler;
/*****************************************************************************************************
*
* AliHLTConfiguration
AliHLTConfiguration(const char* id, const char* component, const char* sources, const char* arguments);
virtual ~AliHLTConfiguration();
+ /****************************************************************************************************
+ * global initialization
+ */
+ static int GlobalInit(AliHLTConfigurationHandler* pHandler);
+
+ static int GlobalDeinit();
+
/****************************************************************************************************
* properties
*/
protected:
- //int Logging( AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* message, ... );
private:
/* extract the source configurations from the sources string
int fArgc; // number of arguments
char** fArgv; // argument array
+ static AliHLTConfigurationHandler* fConfigurationHandler;
+
ClassDef(AliHLTConfiguration, 0);
};
*/
// register a configuration to the global list of configurations
- static int RegisterConfiguration(AliHLTConfiguration* pConf);
+ int RegisterConfiguration(AliHLTConfiguration* pConf);
// create a configuration and register it
- static int CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments);
+ int CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments);
// remove a configuration from the global list
- static int RemoveConfiguration(AliHLTConfiguration* pConf);
- static int RemoveConfiguration(const char* id);
+ int RemoveConfiguration(AliHLTConfiguration* pConf);
+ int RemoveConfiguration(const char* id);
// find a configuration from the global list
- static AliHLTConfiguration* FindConfiguration(const char* id);
+ AliHLTConfiguration* FindConfiguration(const char* id);
// print the registered configurations to the logging function
- static void PrintConfigurations();
+ void PrintConfigurations();
private:
typedef AliHLTUInt64_t AliHLTEventID_t;
- enum AliHLTComponent_LogSeverity { kHLTLogNone=0, kHLTLogBenchmark=1, kHLTLogDebug=2, kHLTLogInfo=4, kHLTLogWarning=8, kHLTLogError=16, kHLTLogFatal=32 };
+ enum AliHLTComponent_LogSeverity { kHLTLogNone=0, kHLTLogBenchmark=1, kHLTLogDebug=2, kHLTLogInfo=4, kHLTLogWarning=8, kHLTLogError=16, kHLTLogFatal=32, kHLTLogAll=0x3f, kHLTLogDefault=0x39 };
struct AliHLTComponent_EventData
{
char AliHLTLogging::fLogBuffer[LOG_BUFFER_SIZE]="";
char AliHLTLogging::fOriginBuffer[LOG_BUFFER_SIZE]="";
-AliHLTComponent_LogSeverity AliHLTLogging::fGlobalLogFilter=(AliHLTComponent_LogSeverity)0;
+AliHLTComponent_LogSeverity AliHLTLogging::fGlobalLogFilter=kHLTLogAll;
AliHLTfctLogging AliHLTLogging::fLoggingFunc=NULL;
AliHLTLogging::AliHLTLogging()
{
+ fpDefaultKeyword=NULL;
+ fpCurrentKeyword=NULL;
+ //fLocalLogFilter=kHLTLogDefault;
+ fLocalLogFilter=kHLTLogAll;
}
default:
break;
}
- cout << "HLT Log " << strSeverity << ": " << origin << " (" << keyword << ") " << message << endl;
+ cout << "HLT Log " << strSeverity << ": " << origin << " " << message;
+ if (strcmp(keyword, HLT_DEFAULT_LOG_KEYWORD)!=0)
+ cout << " (" << keyword << ")";
+ cout << endl;
return iResult;
}
char* tgtBuffer=fLogBuffer;
tgtBuffer[tgtLen]=0;
+#if (defined LOG_PREFIX)
tgtLen = snprintf(tgtBuffer, iBufferSize, LOG_PREFIX); // add logging prefix
+#endif
if (tgtLen>=0) {
tgtBuffer+=tgtLen; iBufferSize-=tgtLen;
tgtLen = vsnprintf(tgtBuffer, iBufferSize, format, ap);
}
int AliHLTLogging::Logging(AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* format, ... ) {
- va_list args;
- va_start(args, format);
- if (fLoggingFunc) {
- return (*fLoggingFunc)(NULL/*fParam*/, severity, origin, keyword, AliHLTLogging::BuildLogString(format, args ));
- } else {
- return Message(NULL/*fParam*/, severity, origin, keyword, AliHLTLogging::BuildLogString(format, args ));
+ int iResult=CheckFilter(severity);
+ if (iResult>0) {
+ va_list args;
+ va_start(args, format);
+ if (fLoggingFunc) {
+ iResult = (*fLoggingFunc)(NULL/*fParam*/, severity, origin, keyword, AliHLTLogging::BuildLogString(format, args ));
+ } else {
+ iResult = Message(NULL/*fParam*/, severity, origin, keyword, AliHLTLogging::BuildLogString(format, args ));
+ }
}
- return -ENOSYS;
+ return iResult;
}
int AliHLTLogging::LoggingVarargs( AliHLTComponent_LogSeverity severity, const char* origin_class, const char* origin_func, ... )
{
- int iResult=0;
- int iMaxSize=LOG_BUFFER_SIZE-1;
- int iPos=0;
- const char* separator="";
- fOriginBuffer[iPos]=0;
- if (origin_class) {
- if ((int)strlen(origin_class)<iMaxSize-iPos) {
- strcpy(&fOriginBuffer[iPos], origin_class);
- iPos+=strlen(origin_class);
- separator="::";
+ int iResult=CheckFilter(severity);
+ if (iResult>0) {
+ int iMaxSize=LOG_BUFFER_SIZE-1;
+ int iPos=0;
+ const char* separator="";
+ fOriginBuffer[iPos]=0;
+ if (origin_class) {
+ if ((int)strlen(origin_class)<iMaxSize-iPos) {
+ strcpy(&fOriginBuffer[iPos], origin_class);
+ iPos+=strlen(origin_class);
+ separator="::";
+ }
}
- }
- if (origin_func) {
- if ((int)strlen(origin_func)+(int)strlen(separator)<iMaxSize-iPos) {
- strcpy(&fOriginBuffer[iPos], separator);
- iPos+=strlen(separator);
- strcpy(&fOriginBuffer[iPos], origin_func);
- iPos+=strlen(origin_func);
+ if (origin_func) {
+ if ((int)strlen(origin_func)+(int)strlen(separator)<iMaxSize-iPos) {
+ strcpy(&fOriginBuffer[iPos], separator);
+ iPos+=strlen(separator);
+ strcpy(&fOriginBuffer[iPos], origin_func);
+ iPos+=strlen(origin_func);
+ }
}
+ va_list args;
+ va_start(args, origin_func);
+ const char* format = va_arg(args, const char*);
+
+ const char* message=format;
+ char* qualifier=NULL;
+ if ((qualifier=strchr(format, '%'))!=NULL) {
+ message=AliHLTLogging::BuildLogString(format, args);
+ }
+ if (fLoggingFunc) {
+ iResult=(*fLoggingFunc)(NULL/*fParam*/, severity, fOriginBuffer, GetKeyword(), message);
+ } else {
+ iResult=Message(NULL/*fParam*/, severity, fOriginBuffer, GetKeyword(), message);
+ }
+ va_end(args);
}
- va_list args;
- va_start(args, origin_func);
- const char* format = va_arg(args, const char*);
-
- const char* message=format;
- char* qualifier=NULL;
- const char* keyword="no key";
- if ((qualifier=strchr(format, '%'))!=NULL) {
- message=AliHLTLogging::BuildLogString(format, args);
- }
- if (fLoggingFunc) {
- iResult=(*fLoggingFunc)(NULL/*fParam*/, severity, fOriginBuffer, keyword, message);
- } else {
- iResult=Message(NULL/*fParam*/, severity, fOriginBuffer, keyword, message);
- }
- va_end(args);
return iResult;
}
int AliHLTLogging::CheckFilter(AliHLTComponent_LogSeverity severity)
{
- int iResult=1;
+ int iResult=severity==kHLTLogNone || (severity&fGlobalLogFilter)>0 && (severity&fLocalLogFilter)>0;
return iResult;
}
#include <stdio.h>
#define LOG_BUFFER_SIZE 100 // global logging buffer
-#define LOG_PREFIX "" // logging prefix, for later extensions
+//#define LOG_PREFIX "" // logging prefix, for later extensions
-#define DebugMsg( ... ) LoggingVarargs(kHLTLogDebug, this->Class_Name() , __func__ , __VA_ARGS__ )
+
+/* the logging macros can be used inside methods of classes which inherit from
+ * AliHLTLogging
+ */
+// HLTMessage is not filtered
+#define HLTMessage( ... ) LoggingVarargs(kHLTLogNone, NULL , NULL , __VA_ARGS__ )
+
+// the following macros are filtered by the Global and Local Log Filter
+#define HLTBenchmark( ... ) LoggingVarargs(kHLTLogBenchmark, this->Class_Name() , __func__ , __VA_ARGS__ )
+#define HLTDebug( ... ) LoggingVarargs(kHLTLogDebug, this->Class_Name() , __func__ , __VA_ARGS__ )
+#define HLTInfo( ... ) LoggingVarargs(kHLTLogInfo, this->Class_Name() , __func__ , __VA_ARGS__ )
+#define HLTWarning( ... ) LoggingVarargs(kHLTLogWarning, this->Class_Name() , __func__ , __VA_ARGS__ )
+#define HLTError( ... ) LoggingVarargs(kHLTLogError, this->Class_Name() , __func__ , __VA_ARGS__ )
+#define HLTFatal( ... ) LoggingVarargs(kHLTLogFatal, this->Class_Name() , __func__ , __VA_ARGS__ )
+
+// helper macro to set the keyword
+#define HLTLogKeyword(a) AliHLTKeyword __hltlog_tmpkey__LINE__(this, a)
+
+#define HLT_DEFAULT_LOG_KEYWORD "no key"
class AliHLTLogging {
public:
AliHLTLogging();
virtual ~AliHLTLogging();
- /* logging filter for all objects
- */
+ // logging filter for all objects
+ //
static AliHLTComponent_LogSeverity SetGlobalLogLevel(AliHLTComponent_LogSeverity iLogFilter) {fGlobalLogFilter=iLogFilter; return fGlobalLogFilter;}
- /* logging filter for individual object
- */
+ // logging filter for individual object
+ //
AliHLTComponent_LogSeverity SetLocalLogLevel(AliHLTComponent_LogSeverity iLogFilter) {fLocalLogFilter=iLogFilter; return fLocalLogFilter;}
+
+ // set the default key word
+ // the keyword is intended to simplify the use of logging macros
+ //
+ void SetDefaultKeyword(const char* keyword) { fpDefaultKeyword=keyword; }
+
+ // set a temporary keyword
+ // returns the old key value
+ const char* SetKeyword(const char* keyword)
+ {
+ const char* currentKeyword=fpCurrentKeyword;
+ fpCurrentKeyword=keyword;
+ return currentKeyword;
+ }
+
+ // get the current keyword
+ //
+ const char* GetKeyword()
+ {
+ if (fpCurrentKeyword) return fpCurrentKeyword;
+ else if (fpDefaultKeyword) return fpDefaultKeyword;
+ return HLT_DEFAULT_LOG_KEYWORD;
+ }
static int Init(AliHLTfctLogging pFun) { fLoggingFunc=pFun; return 0;}
// genaral logging function
//
- static int Logging( AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* message, ... );
+ int Logging( AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* message, ... );
// logging function with two origin parameters, used by the log macros
//
static char fLogBuffer[LOG_BUFFER_SIZE];
static char fOriginBuffer[LOG_BUFFER_SIZE];
static AliHLTfctLogging fLoggingFunc;
+ const char* fpDefaultKeyword;
+ const char* fpCurrentKeyword;
ClassDef(AliHLTLogging, 0)
};
+
+/* the class AliHLTKeyword is a simple helper class used by the HLTLogKeyword macro
+ * HLTLogKeyword("a keyword") creates an object of AliHLTKeyword which sets the keyword for the logging class
+ * the object is destroyed automatically when the current scope is left and so the keyword is set
+ * to the original value
+ */
+class AliHLTKeyword {
+ public:
+ AliHLTKeyword()
+ {
+ fpParent=NULL;
+ fpOriginal=NULL;
+ }
+
+ AliHLTKeyword(AliHLTLogging* parent, const char* keyword)
+ {
+ fpOriginal=NULL;
+ if (parent) {
+ fpParent=parent;
+ fpOriginal=fpParent->SetKeyword(keyword);
+ }
+ }
+
+ ~AliHLTKeyword()
+ {
+ if (fpParent) {
+ fpParent->SetKeyword(fpOriginal);
+ }
+ }
+
+ private:
+ AliHLTLogging* fpParent;
+ const char* fpOriginal;
+};
#endif
// init logging function in AliHLTLogging
Init(AliHLTLogging::Message);
+ } else {
+ HLTFatal("can not create Component Handler");
+ }
+ fpConfigurationHandler=new AliHLTConfigurationHandler();
+ if (fpConfigurationHandler) {
+ AliHLTConfiguration::GlobalInit(fpConfigurationHandler);
+ } else {
+ HLTFatal("can not create Configuration Handler");
}
- DebugMsg("create hlt object %s %p", "AliHLTSystem", this);
- DebugMsg("done");
}
AliHLTSystem::~AliHLTSystem()
{
+ AliHLTConfiguration::GlobalDeinit();
+ if (fpConfigurationHandler) {
+ delete fpConfigurationHandler;
+ }
+ fpConfigurationHandler=NULL;
+
+ if (fpComponentHandler) {
+ delete fpComponentHandler;
+ }
+ fpComponentHandler=NULL;
}
int AliHLTSystem::AddConfiguration(AliHLTConfiguration* pConf)
AliHLTTask* pTask=NULL;
if ((pTask=FindTask(pConf->GetName()))!=NULL) {
if (pTask->GetConf()!=pConf) {
- Logging(kHLTLogError, "BASE", "AliHLTSystem", "configuration missmatch, there is already a task with configuration name \"%s\", but it is different. Most likely configuration %p is not registered properly", pConf->GetName(), pConf);
+ HLTError("configuration missmatch, there is already a task with configuration name \"%s\", but it is different. Most likely configuration %p is not registered properly", pConf->GetName(), pConf);
iResult=-EEXIST;
pTask=NULL;
}
} else if (pConf->SourcesResolved(1)!=1) {
- Logging(kHLTLogError, "BASE", "AliHLTSystem", "configuration \"%s\" has unresolved sources, aborting ...", pConf->GetName());
+ HLTError("configuration \"%s\" has unresolved sources, aborting ...", pConf->GetName());
iResult=-ENOLINK;
} else {
pTask=new AliHLTTask(pConf, NULL);
if (pTask) {
// check for ring dependencies
if ((iResult=pConf->FollowDependency(pConf->GetName()))>0) {
- Logging(kHLTLogError, "BASE", "AliHLTSystem", "detected ring dependency for configuration \"%s\"", pTask->GetName());
+ HLTError("detected ring dependency for configuration \"%s\"", pTask->GetName());
pTask->PrintDependencyTree(pTask->GetName(), 1/*use the configuration list*/);
- Logging(kHLTLogError, "BASE", "AliHLTSystem", "aborted ...");
+ HLTError("aborted ...");
iResult=-ELOOP;
}
if (iResult>=0) {
lnk=fTaskList.FirstLink();
while (lnk && iResult>0) {
AliHLTTask* pCurr = (AliHLTTask*)lnk->GetObject();
- //Logging(kHLTLogDebug, "BASE", "AliHLTSystem", "checking \"%s\"", pCurr->GetName());
+ //HLTDebug("checking \"%s\"", pCurr->GetName());
iResult=pTask->Depends(pCurr);
if (iResult>0) {
iResult=pTask->SetDependency(pCurr);
pCurr->SetTarget(pTask);
- Logging(kHLTLogDebug, "BASE", "AliHLTSystem", "set dependency \"%s\" for configuration \"%s\"", pCurr->GetName(), pTask->GetName());
+ HLTDebug("set dependency \"%s\" for configuration \"%s\"", pCurr->GetName(), pTask->GetName());
}
if (pCurr->Depends(pTask)) {
// ring dependency
- Logging(kHLTLogError, "BASE", "AliHLTSystem", "ring dependency: can not resolve dependencies for configuration \"%s\"", pTask->GetName());
+ HLTError("ring dependency: can not resolve dependencies for configuration \"%s\"", pTask->GetName());
iResult=-ELOOP;
} else if ((iResult=pTask->CheckDependencies())>0) {
lnk = lnk->Next();
} else {
fTaskList.AddFirst(pTask);
}
- Logging(kHLTLogDebug, "BASE", "AliHLTSystem", "task \"%s\" inserted", pTask->GetName());
+ HLTDebug("task \"%s\" inserted", pTask->GetName());
} else if (iResult>0) {
- Logging(kHLTLogError, "BASE", "AliHLTSystem", "can not resolve dependencies for configuration \"%s\" (%d unresolved)", pTask->GetName(), iResult);
+ HLTError("can not resolve dependencies for configuration \"%s\" (%d unresolved)", pTask->GetName(), iResult);
iResult=-ENOLINK;
}
return iResult;
void AliHLTSystem::PrintTaskList()
{
+ HLTLogKeyword("task list");
TObjLink *lnk = NULL;
- Logging(kHLTLogInfo, "BASE", "AliHLTSystem", "Task List");
+ HLTMessage("Task List");
lnk=fTaskList.FirstLink();
while (lnk) {
TObject* obj=lnk->GetObject();
if (obj) {
- Logging(kHLTLogInfo, "BASE", "AliHLTSystem", " %s - status:", obj->GetName());
+ HLTMessage(" %s - status:", obj->GetName());
AliHLTTask* pTask=(AliHLTTask*)obj;
pTask->PrintStatus();
} else {
class AliHLTComponentHandler;
class AliHLTConfiguration;
+class AliHLTConfigurationHandler;
class AliHLTTask;
class AliHLTSystem : public AliHLTLogging {
virtual ~AliHLTSystem();
AliHLTComponentHandler* fpComponentHandler;
+ AliHLTConfigurationHandler* fpConfigurationHandler;
/* add a configuration to the end of the list
*/