]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTSystem.cxx
started the new framework module supporting PubSub and AliRoot
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTSystem.cxx
1 // $Id$
2
3 /**************************************************************************
4  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  *                                                                        *
6  * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
7  *          Timm Steinbeck <timm@kip.uni-heidelberg.de>                   *
8  *          Artur Szostak <artursz@iafrica.com>                           *
9  *          for The ALICE Off-line Project.                               *
10  *                                                                        *
11  * Permission to use, copy, modify and distribute this software and its   *
12  * documentation strictly for non-commercial purposes is hereby granted   *
13  * without fee, provided that the above copyright notice appears in all   *
14  * copies and that both the copyright notice and this permission notice   *
15  * appear in the supporting documentation. The authors make no claims     *
16  * about the suitability of this software for any purpose. It is          *
17  * provided "as is" without express or implied warranty.                  *
18  **************************************************************************/
19
20 ///////////////////////////////////////////////////////////////////////////////
21 //                                                                           //
22 // global HLT module management                                              //
23 //                                                                           //
24 ///////////////////////////////////////////////////////////////////////////////
25
26 #if __GNUC__== 3
27 using namespace std;
28 #endif
29
30 #include <errno.h>
31 #include <string.h>
32 #include "AliL3StandardIncludes.h"
33 #include "AliHLTSystem.h"
34 #include "AliHLTComponentHandler.h"
35 #include "AliHLTComponent.h"
36
37 ClassImp(AliHLTSystem)
38
39 char AliHLTSystem::fLogBuffer[LOG_BUFFER_SIZE]="";
40
41 AliHLTSystem::AliHLTSystem()
42 {
43   fpComponentHandler=new AliHLTComponentHandler();
44   if (fpComponentHandler) {
45     AliHLTComponentEnvironment env;
46     memset(&env, 0, sizeof(AliHLTComponentEnvironment));
47     env.fLoggingFunc=AliHLTSystem::Logging;
48     fpComponentHandler->SetEnvironment(&env);
49   }
50 }
51
52
53 AliHLTSystem::~AliHLTSystem()
54 {
55 }
56
57 int AliHLTSystem::Logging(void *param, AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* message) {
58   int iResult=0;
59   const char* strSeverity="";
60   switch (severity) {
61   case kHLTLogBenchmark: 
62     strSeverity="benchmark";
63     break;
64   case kHLTLogDebug:
65     strSeverity="debug";
66     break;
67   case kHLTLogInfo:
68     strSeverity="info";
69     break;
70   case kHLTLogWarning:
71     strSeverity="warning";
72     break;
73   case kHLTLogError:
74     strSeverity="error";
75     break;
76   case kHLTLogFatal:
77     strSeverity="fatal";
78     break;
79   default:
80     break;
81   }
82   cout << "HLT Log " << strSeverity << ": " << origin << " (" << keyword << ") " << message << endl;
83   return iResult;
84 }
85
86 const char* AliHLTSystem::BuildLogString(const char *format, va_list ap) {
87   int tgtLen=0;
88   int iBufferSize=LOG_BUFFER_SIZE;
89   char* tgtBuffer=fLogBuffer;
90   tgtBuffer[tgtLen]=0;
91
92   tgtLen = snprintf(tgtBuffer, iBufferSize, LOG_PREFIX); // add logging prefix
93   if (tgtLen>=0) {
94     tgtBuffer+=tgtLen; iBufferSize-=tgtLen;
95     tgtLen = vsnprintf(tgtBuffer, iBufferSize, format, ap);
96     if (tgtLen>0) {
97       tgtBuffer+=tgtLen;
98 //       if (tgtLen<LOG_BUFFER_SIZE-1) {
99 //      *tgtBuffer++='\n'; // add newline if space in buffer
100 //      }
101       *tgtBuffer=0; // terminate the buffer
102     }
103   }
104   return fLogBuffer;
105 }
106
107