int AliHLTLogging::InitAliLogTrap(AliHLTComponentHandler* pHandler)
{
// see header file for class documentation
+ // init the AliRoot logging trap
+ // AliLog messages are redirected to PubSub,
int iResult=0;
if (pHandler) {
+ // set temporary loglevel of component handler
AliHLTComponentLogSeverity loglevel=pHandler->GetLocalLoggingLevel();
pHandler->SetLocalLoggingLevel(kHLTLogError);
- pHandler->LoadLibrary("libAliHLTUtil.so");
+
+ // load library containing AliRoot dependencies and initialization handler
+ pHandler->LoadLibrary(ALILOG_WRAPPER_LIBRARY, 0/* do not activate agents */);
+
+ // restore loglevel
pHandler->SetLocalLoggingLevel(loglevel);
- InitAliDynamicMessageCallback pFunc=(InitAliDynamicMessageCallback)pHandler->FindSymbol("libAliHLTUtil.so", "InitAliDynamicMessageCallback");
+
+ // find the symbol
+ InitAliDynamicMessageCallback pFunc=(InitAliDynamicMessageCallback)pHandler->FindSymbol(ALILOG_WRAPPER_LIBRARY, "InitAliDynamicMessageCallback");
if (pFunc) {
iResult=(*pFunc)();
} else {
return iResult;
}
+int AliHLTLogging::InitAliLogFunc(AliHLTComponentHandler* pHandler)
+{
+ // see header file for class documentation
+ int iResult=0;
+ if (pHandler) {
+ // set temporary loglevel of component handler
+ AliHLTComponentLogSeverity loglevel=pHandler->GetLocalLoggingLevel();
+ pHandler->SetLocalLoggingLevel(kHLTLogError);
+
+ // load library containing AliRoot dependencies and initialization handler
+ pHandler->LoadLibrary(ALILOG_WRAPPER_LIBRARY, 0/* do not activate agents */);
+
+ // restore loglevel
+ pHandler->SetLocalLoggingLevel(loglevel);
+
+ // find the symbol
+ fgAliLoggingFunc=(AliHLTLogging::AliHLTDynamicMessage)pHandler->FindSymbol(ALILOG_WRAPPER_LIBRARY, "AliDynamicMessage");
+ if (fgAliLoggingFunc==NULL) {
+ Message(NULL, kHLTLogError, "AliHLTLogging::InitAliLogFunc", "init logging",
+ "symbol lookp failure: can not find AliDynamicMessage, switching to HLT logging system");
+ iResult=-ENOSYS;
+ }
+ } else {
+ iResult=-EINVAL;
+ }
+
+ return iResult;
+}
+
int AliHLTLogging::Message(void *param, AliHLTComponentLogSeverity severity,
const char* origin, const char* keyword,
const char* message)
memset(&env, 0, sizeof(AliHLTComponentEnvironment));
env.fAllocMemoryFunc=AliHLTSystem::AllocMemory;
env.fLoggingFunc=NULL;
- AliHLTComponentLogSeverity loglevel=fpComponentHandler->GetLocalLoggingLevel();
- fpComponentHandler->SetLocalLoggingLevel(kHLTLogError);
fpComponentHandler->SetEnvironment(&env);
- fpComponentHandler->LoadLibrary("libAliHLTUtil.so", 0/* do not activate agents */);
- fgAliLoggingFunc=(AliHLTLogging::AliHLTDynamicMessage)fpComponentHandler->FindSymbol("libAliHLTUtil.so", "AliDynamicMessage");
- fpComponentHandler->SetLocalLoggingLevel(loglevel);
- if (fgAliLoggingFunc==NULL) {
- HLTError("symbol lookp failure: can not find AliDynamicMessage, switching to HLT logging system");
- }
+ InitAliLogFunc(fpComponentHandler);
fpComponentHandler->AnnounceVersion();
} else {
HLTFatal("can not create Component Handler");
+++ /dev/null
-// @(#) $Id$
-
-/**************************************************************************
- * This file is property of and copyright by the ALICE HLT Project *
- * ALICE Experiment at CERN, All rights reserved. *
- * *
- * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
- * for The ALICE HLT Project. *
- * *
- * Permission to use, copy, modify and distribute this software and its *
- * documentation strictly for non-commercial purposes is hereby granted *
- * without fee, provided that the above copyright notice appears in all *
- * copies and that both the copyright notice and this permission notice *
- * appear in the supporting documentation. The authors make no claims *
- * about the suitability of this software for any purpose. It is *
- * provided "as is" without express or implied warranty. *
- **************************************************************************/
-
-/** @file AliHLTDynamicAliLog.cxx
- @author Matthias Richter
- @date
- @brief Implementation of dynamically loaded AliLog functionality
-*/
-
-#include <sstream>
-#include <iostream>
-#include "AliLog.h"
-#include "AliHLTLogging.h"
-#include "AliHLTDataTypes.h"
-
-/**
- * Notification callback for AliRoot logging methods
- */
-void LogNotification(AliLog::EType_t /*level*/, const char* /*message*/)
-{
- // Notification callback for AliRoot logging methods
-
- AliHLTLogging hltlog;
- // in case of the initialized callback we never want to redirect
- // HLT logging messages to AliLog (that would be a circular function call)
- hltlog.SwitchAliLog(0);
- hltlog.Logging(kHLTLogInfo, "NotificationHandler", "AliLog", AliHLTLogging::fgLogstr.str().c_str());
- AliHLTLogging::fgLogstr.clear();
- string empty("");
- AliHLTLogging::fgLogstr.str(empty);
-}
-
-/**
- * This is the entry point for AliLog messages.
- * The function pointer is fetched by the AliLogging class after libAliHLTUtil
- * was loaded dynamically. By that we can keep libHLTbase free of AliRoot
- * libraries.
- */
-extern "C" int AliDynamicMessage(AliHLTComponentLogSeverity severity,
- const char* originClass, const char* originFunc,
- const char* file, int line, const char* message)
-{
- // see header file for class documentation
-
- switch (severity) {
- case kHLTLogBenchmark:
- AliLog::Message(AliLog::kInfo, message, "HLT", originClass, originFunc, file, line);
- break;
- case kHLTLogDebug:
- AliLog::Message(AliLog::kDebug, message, "HLT", originClass, originFunc, file, line);
- break;
- case kHLTLogInfo:
- AliLog::Message(AliLog::kInfo, message, "HLT", originClass, originFunc, file, line);
- break;
- case kHLTLogWarning:
- AliLog::Message(AliLog::kWarning, message, "HLT", originClass, originFunc, file, line);
- break;
- case kHLTLogError:
- AliLog::Message(AliLog::kError, message, "HLT", originClass, originFunc, file, line);
- break;
- case kHLTLogFatal:
- AliLog::Message(AliLog::kWarning, message, "HLT", originClass, originFunc, file, line);
- break;
- default:
- break;
- }
- return 0;
-}
-
-/**
- * Init the AliLog callback.
- * If libHLTbase is used within AliRoot, no message callback is initialized since
- * all logging happens through AliRoot. If externally used by other frameworks (e.g.
- * PubSub), all messages from components to AliLog must be trapped and redirected
- * to the external callback.
- */
-extern "C" int InitAliDynamicMessageCallback()
-{
- // older versions of AliLog does not support the notification callback and
- // stringstreams, but they support the logging macros in general
-#ifndef NO_ALILOG_NOTIFICATION
- AliLog* log=new AliLog;
- log->SetLogNotification(LogNotification);
- log->SetStreamOutput(&AliHLTLogging::fgLogstr);
- return 0;
-#endif // NO_ALILOG_NOTIFICATION
- return -ENOSYS;
-}