]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTLogging.h
HLTcalo module
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTLogging.h
index eb9e09dc59fb77f4e0ce05ab91b69d95ada3b07d..b09858aed616414dd6b12b8a33c3d1354f819537 100644 (file)
@@ -3,15 +3,15 @@
 
 #ifndef ALIHLTLOGGING_H
 #define ALIHLTLOGGING_H
-/* This file is property of and copyright by the ALICE HLT Project        * 
- * ALICE Experiment at CERN, All rights reserved.                         *
- * See cxx source for full Copyright notice                               */
+///* This file is property of and copyright by the                          * 
+///* ALICE Experiment at CERN, All rights reserved.                         *
+///* See cxx source for full Copyright notice                               */
 
-/** @file   AliHLTLogging.h
-    @author Matthias Richter, Timm Steinbeck
-    @date   
-    @brief  HLT module logging primitives.
-*/
+/// @file   AliHLTLogging.h
+/// @author Matthias Richter, Timm Steinbeck
+/// @date   
+/// @brief  HLT module logging primitives.
+///
 
 #include "AliHLTDataTypes.h"
 #include "AliHLTStdIncludes.h"
@@ -27,9 +27,6 @@ class AliHLTComponentHandler;
 /* the logging macros can be used inside methods of classes which inherit from 
  * AliHLTLogging
  */
-// HLTMessage is not filtered
-#define HLTMessage( ... )   LoggingVarargs(kHLTLogNone,      NULL , NULL , __FILE__ , __LINE__ , __VA_ARGS__ )
-
 // function name
 #if defined(__GNUC__) || defined(__ICC) || defined(__ECC) || defined(__APPLE__)
 #define FUNCTIONNAME() __FUNCTION__
@@ -37,8 +34,12 @@ class AliHLTComponentHandler;
 #define FUNCTIONNAME() "???"
 #endif
 
-// the following macros are filtered by the Global and Local Log Filter
 #ifndef ALIHLTLOGGINGVARIADICFREE_H
+// HLTMessage is not filtered
+#define HLTMessage( ... )   LoggingVarargs(kHLTLogNone,      NULL , NULL , __FILE__ , __LINE__ , __VA_ARGS__ )
+
+// the following macros are filtered by the Global and Local Log Filter
+#define HLTLog( level, ... ) if (CheckFilter(level))         LoggingVarargs(level, Class_Name() , FUNCTIONNAME() , __FILE__ , __LINE__ , __VA_ARGS__ )
 #define HLTBenchmark( ... ) LoggingVarargs(kHLTLogBenchmark, Class_Name() , FUNCTIONNAME() , __FILE__ , __LINE__ , __VA_ARGS__ )
 #ifdef __DEBUG
 #define HLTDebug( ... )     if (CheckFilter(kHLTLogDebug) && CheckGroup(Class_Name())) LoggingVarargs(kHLTLogDebug,     Class_Name() , FUNCTIONNAME() , __FILE__ , __LINE__ , __VA_ARGS__ )
@@ -54,6 +55,8 @@ class AliHLTComponentHandler;
 // the same macros are defined variadic free, in that case the message must be complete
 // include AliHLTLoggingVariadicFree.h
 #else //ALIHLTLOGGINGVARIADICFREE_H
+#define HLTMessage( message )   LoggingVarargs(kHLTLogNone,      NULL , NULL , __FILE__ , __LINE__ , message )
+#define HLTLog( level, message) if (CheckFilter(level))          LoggingVarargs(level, Class_Name() , FUNCTIONNAME() , __FILE__ , __LINE__ , message )
 #define HLTBenchmark( message ) LoggingVarargs(kHLTLogBenchmark, Class_Name() , FUNCTIONNAME() , __FILE__ , __LINE__ , message )
 #ifdef __DEBUG
 #define HLTDebug( message )     if (CheckFilter(kHLTLogDebug) && CheckGroup(Class_Name())) LoggingVarargs(kHLTLogDebug,     Class_Name() , FUNCTIONNAME() , __FILE__ , __LINE__ , message )
@@ -128,6 +131,8 @@ public:
 
   /**
    * Set a temporary keyword
+   * Keywords need to be static const strings, the class handles only
+   * pointers and assumes the strings to be persistent.
    * returns the old key value
    */
   const char* SetKeyword(const char* keyword) 
@@ -244,6 +249,11 @@ public:
    */
   static void SetLocalLoggingDefault(AliHLTComponentLogSeverity level);
 
+  /**
+   * Get default setting for local logging filter for individual objects.
+   */
+  static AliHLTComponentLogSeverity GetLocalLoggingDefault() { return fgLocalLogDefault; }
+
   /**
    * Get local logging level
    * logging filter for individual object
@@ -262,14 +272,14 @@ public:
    * @param bAppend    append to current content
    * @return const char string with the formatted message 
    */
-  static const char* BuildLogString(const char *format, va_list ap, bool bAppend=false);
+  static const char* BuildLogString(const char *format, va_list &ap, bool bAppend=false);
 
   /**
    * Set the log string from format specifier and from variable arguments.
    * @param format     format string of printf style
    * @return const char string with the formatted message 
    */
-  static const char* SetLogString(const char *format, ... );
+  static const char* SetLogString(const void* p, const char* pfmt, const char *format, ... );
 
   /**
    * Get parameter given by the external caller.
@@ -341,13 +351,14 @@ private:
   /** groups of classes not to print debug messages */
   static TString fgWhiteList;                                      //! transient
   
-  ClassDef(AliHLTLogging, 3)
+  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
+ * to the original value. Please note that all keywords need to be static strings, only pointyers
+ * are handled and the strings required to ber persistent.
  */
 class AliHLTKeyword {
  public:
@@ -358,30 +369,18 @@ class AliHLTKeyword {
     {
     }
 
-  AliHLTKeyword(AliHLTLogging* parent, const char* keyword)
+  AliHLTKeyword(const AliHLTLogging* parent, const char* keyword)
     :
-    fpParent(parent),
+    fpParent(const_cast<AliHLTLogging*>(parent)),
     fpOriginal(NULL)
     {
-      if (parent) {
+      // the const cast is on purpose in order to be allowed to use
+      // HLTLogKeyword from const member functions
+      if (fpParent) {
        fpOriginal=fpParent->SetKeyword(keyword);
       }
     }
 
-  AliHLTKeyword(const AliHLTKeyword& kw)
-    :
-    fpParent(kw.fpParent),
-    fpOriginal(kw.fpOriginal)
-    {
-    }
-
-  AliHLTKeyword& operator=(const AliHLTKeyword& kw)
-    { 
-      fpParent=kw.fpParent;
-      fpOriginal=kw.fpOriginal;
-      return *this;
-    }
-
   ~AliHLTKeyword()
     {
       if (fpParent) {
@@ -390,6 +389,11 @@ class AliHLTKeyword {
     }
 
  private:
+  /// copy constructor prohibited
+  AliHLTKeyword(const AliHLTKeyword& kw);
+  /// assignment operator prohibited
+  AliHLTKeyword& operator=(const AliHLTKeyword& kw);
+
   AliHLTLogging* fpParent;                                         //! transient
   const char* fpOriginal;                                          //! transient
 };