From fa2746268d2309285d68a446a231a3f70d14380e Mon Sep 17 00:00:00 2001 From: richterm Date: Wed, 14 Mar 2007 09:47:32 +0000 Subject: [PATCH] - check whether AliLog supports external streams and notification callback added to configure - notification callback activated if supported (AliHLTLogging) --- HLT/BASE/AliHLTComponentHandler.cxx | 16 ++++++++++++++-- HLT/BASE/AliHLTLogging.cxx | 16 +++++++++------- HLT/configure.ac | 15 +++++++++++++-- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/HLT/BASE/AliHLTComponentHandler.cxx b/HLT/BASE/AliHLTComponentHandler.cxx index 2e98397ca46..45b26b2628f 100644 --- a/HLT/BASE/AliHLTComponentHandler.cxx +++ b/HLT/BASE/AliHLTComponentHandler.cxx @@ -74,7 +74,13 @@ AliHLTComponentHandler::AliHLTComponentHandler(AliHLTComponentEnvironment* pEnv) // see header file for class documentation if (pEnv) { memcpy(&fEnvironment, pEnv, sizeof(AliHLTComponentEnvironment)); - AliHLTLogging::Init(pEnv->fLoggingFunc); + if (pEnv->fLoggingFunc) { + // the AliHLTLogging::Init method also sets the stream output + // and notification handler to AliLog. This should only be done + // if the logging environment contains a logging function + // for redirection + AliHLTLogging::Init(pEnv->fLoggingFunc); + } } else memset(&fEnvironment, 0, sizeof(AliHLTComponentEnvironment)); AddStandardComponents(); @@ -236,7 +242,13 @@ void AliHLTComponentHandler::SetEnvironment(AliHLTComponentEnvironment* pEnv) // see header file for class documentation if (pEnv) { memcpy(&fEnvironment, pEnv, sizeof(AliHLTComponentEnvironment)); - AliHLTLogging::Init(fEnvironment.fLoggingFunc); + if (fEnvironment.fLoggingFunc) { + // the AliHLTLogging::Init method also sets the stream output + // and notification handler to AliLog. This should only be done + // if the logging environment contains a logging function + // for redirection + AliHLTLogging::Init(fEnvironment.fLoggingFunc); + } } } diff --git a/HLT/BASE/AliHLTLogging.cxx b/HLT/BASE/AliHLTLogging.cxx index 60d7b980062..d2121e2a9d9 100644 --- a/HLT/BASE/AliHLTLogging.cxx +++ b/HLT/BASE/AliHLTLogging.cxx @@ -47,7 +47,6 @@ ostringstream gLogstr; */ void LogNotification(AliLog::EType_t level, const char* message) { - cout << "Notification handler: " << gLogstr.str() << endl; AliHLTLogging hltlog; hltlog.SwitchAliLog(0); hltlog.Logging(kHLTLogInfo, "NotificationHandler", "AliLog", gLogstr.str().c_str()); @@ -111,18 +110,21 @@ AliHLTLogging::~AliHLTLogging() } int AliHLTLogging::Init(AliHLTfctLogging pFun) -{ +{ // see header file for class documentation if (fLoggingFunc!=NULL && fLoggingFunc!=pFun) { (*fLoggingFunc)(NULL/*fParam*/, kHLTLogWarning, "AliHLTLogging::Init", "no key", "overriding previously initialized logging function"); } fLoggingFunc=pFun; + // older versions of AliLog does not support the notification callback and + // stringstreams, but they support the logging macros in general #ifndef NOALIROOT_LOGGING - // to be activated when changes to AliLog have been committed -// AliLog* log=new AliLog; -// log->SetLogNotification(LogNotification); -// log->SetStreamOutput(&gLogstr); -#endif +#ifndef NO_ALILOG_NOTIFICATION + AliLog* log=new AliLog; + log->SetLogNotification(LogNotification); + log->SetStreamOutput(&gLogstr); +#endif // NO_ALILOG_NOTIFICATION +#endif // NOALIROOT_LOGGING return 0; } diff --git a/HLT/configure.ac b/HLT/configure.ac index dcdad67f40c..80fdb1ac806 100644 --- a/HLT/configure.ac +++ b/HLT/configure.ac @@ -191,8 +191,19 @@ if test ! "x$have_aliroot" = "xno" ; then have_alirawdata=$CHECKLIB], [have_alirawdata=no]) ]) dnl AC_CHECK_LIB RAWDatabase - AC_MSG_CHECKING(for AliRawReader classes in RAWData libraries) - AC_MSG_RESULT($have_alirawdata) + AC_MSG_CHECKING([for AliRawReader classes in RAWData libraries]) + AC_MSG_RESULT([$have_alirawdata]) + + dnl + dnl check whether AliLog supports notification callback + dnl + have_alilog_notification=no + AC_MSG_CHECKING([whether AliLog supports notification callback]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], + [AliLog::AliLogNotification fct])], + [have_alilog_notification=yes], + [AC_DEFINE(NO_ALILOG_NOTIFICATION)]) + AC_MSG_RESULT([$have_alilog_notification]) dnl dnl Check for the interface of AliExternalTrackParam which has been changed -- 2.39.3