]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
AliLog handler moved to libHLTrec, minor cleanup in HLT logging
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 16 Oct 2007 10:46:47 +0000 (10:46 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 16 Oct 2007 10:46:47 +0000 (10:46 +0000)
HLT/BASE/AliHLTLogging.cxx
HLT/BASE/AliHLTLogging.h
HLT/BASE/AliHLTSystem.cxx
HLT/BASE/util/AliHLTDynamicAliLog.cxx [deleted file]
HLT/libAliHLTUtil.pkg
HLT/libHLTrec.pkg
HLT/rec/Makefile.am

index 91de4fb45fd69ec8abeba702f457a92de243f41e..7f3a0dc8ce8c9e0326d4ac738bd47e7812bd4d79 100644 (file)
@@ -102,13 +102,22 @@ int AliHLTLogging::Init(AliHLTfctLogging pFun)
 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 {
@@ -123,6 +132,35 @@ int AliHLTLogging::InitAliLogTrap(AliHLTComponentHandler* pHandler)
   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) 
index 5fe82446b4bb55610eb00e9391fd89c724d22d12..c6d94e8fe648ee48b96ec0a18809aee3eedc3979 100644 (file)
@@ -20,6 +20,7 @@
 class AliHLTComponentHandler;
 //#define LOG_PREFIX ""       // logging prefix, for later extensions
 
+#define ALILOG_WRAPPER_LIBRARY "libHLTrec.so"
 
 /* the logging macros can be used inside methods of classes which inherit from 
  * AliHLTLogging
@@ -103,6 +104,14 @@ public:
    */
   static int InitAliLogTrap(AliHLTComponentHandler* pHandler);
 
+  /**
+   * Init the AliRoot logging function.
+   * All log messages are redirected to AliLog when running in AliRoot.
+   * Note: when running in PubSub, AliLog messages are redirected to PubSub,
+   * see AliHLTLogging::InitAliLogTrap
+   */
+  static int InitAliLogFunc(AliHLTComponentHandler* pHandler);
+
   /**
    * Genaral logging function
    */
index 823e502a02f65a07c7b8a372207a44ba70e3928a..cba349299065eaf0d41eb71973b096db8206da4e 100644 (file)
@@ -82,15 +82,8 @@ AliHLTSystem::AliHLTSystem()
     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");
diff --git a/HLT/BASE/util/AliHLTDynamicAliLog.cxx b/HLT/BASE/util/AliHLTDynamicAliLog.cxx
deleted file mode 100644 (file)
index 50e770c..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-// @(#) $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;
-}
index 25dc8f401d262ad16832fb849b36b24dbfd34531..723397a0d24aa2d532264919889c01ad61e06f68 100644 (file)
@@ -13,8 +13,7 @@ CLASS_HDRS:=          AliHLTFilePublisher.h \
                AliHLTDataGenerator.h \
                AliHLTAgentUtil.h
 
-MODULE_SRCS=   AliHLTDynamicAliLog.cxx \
-               $(CLASS_HDRS:.h=.cxx)
+MODULE_SRCS=   $(CLASS_HDRS:.h=.cxx)
 
 MODULE_HDRS:=  $(CLASS_HDRS)
 
index c22840e1dbec0effebcffbe5a43c85645a119eb5..f760310833ddcd71e1f2e7fdb0ab9e4754b4cfbe 100644 (file)
@@ -5,9 +5,10 @@ include $(MODDIR)/hlt.conf
 
 LIBHLTREC_VERSION := 0
 
-MODULE_SRCS:=  AliHLTReconstructor.cxx
+CLASS_HDRS:=   AliHLTReconstructor.h
 
-CLASS_HDRS:=   $(MODULE_SRCS:.cxx=.h)
+MODULE_SRCS:=  AliHLTDynamicAliLog.cxx \
+               $(CLASS_HDRS:.h=.cxx)
 
 MODULE_HDRS:=  $(CLASS_HDRS)
 
index a028e87c0472021fbe7f1c5af8e3000da80ef755..d0e17172ace00e9eddb375a1329889760f6ee8ad 100644 (file)
@@ -34,6 +34,8 @@ pkginclude_HEADERS            = $(MODULE_HDRS)
 # linker flags
 libHLTrec_la_LDFLAGS           = -L@ROOTLIBDIR@ \
                                  @ROOTLIBS@ \
+                                 @ALIROOT_LDFLAGS@ \
+                                 @ALIROOT_LIBS@ \
                                  -version-info $(LIBRARY_VERSION)
 
 # automatic generation of data and time of library build