]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCLog.cxx
- adapted to AliRoot logging system, messages printed out via AliRoot
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCLog.cxx
1 // $Id$
2 // Original: AliHLTLog.cxx,v 1.1 2004/05/14 09:37:22 loizides 
3
4 #include "AliHLTTPCLog.h"
5
6 AliHLTTPCLog::TLogLevel AliHLTTPCLog::fgLevel=AliHLTTPCLog::kNone;
7
8 const char* AliHLTTPCLog::kEnd = "";
9 const char* AliHLTTPCLog::kPrec = "";
10 const char* AliHLTTPCLog::kHex = "";
11 const char* AliHLTTPCLog::kDec = "";
12
13 const char* AliHLTTPCLog::fgKeyOrigin ="__origin";
14 const char* AliHLTTPCLog::fgKeyKeyword="__key";
15 const char* AliHLTTPCLog::fgKeyMessage="__message";
16
17 stringstream AliHLTTPCLog::fgStream;
18
19 AliHLTLogging AliHLTTPCLog::fgHLTLogging;
20
21 const char* AliHLTTPCLog::Flush()
22 {
23   int severity=0;
24   string origin("");
25   string keyword("");
26   string iter;
27   string message("");
28   int scanStatus=0;
29   fgStream >> severity;
30   while (!fgStream.eof()) {
31     fgStream >> iter;
32     if (scanStatus==0 && iter.compare(fgKeyOrigin)==0) {
33       // idicate scan of origin message
34       scanStatus=1;
35       continue;
36     } else if (scanStatus==1 && iter.compare(fgKeyKeyword)==0) {
37       // idicate scan of keyword message
38       scanStatus=2;
39       continue;
40     } else if (scanStatus==2 && iter.compare(fgKeyMessage)==0) {
41       scanStatus=3;
42       continue;
43     }
44     switch (scanStatus) {
45     case 1:
46       if (!origin.empty()) origin+=" ";
47       origin+=iter;
48       break;
49     case 2:
50       if (!keyword.empty()) keyword+=" ";
51       keyword+=iter;
52       break;
53     default:
54       // if we have come here already for the first word, we don't
55       // expect origin and keyword any more
56       scanStatus=3;
57       if (!message.empty()) message+=" ";
58       message+=iter;
59     }
60   }
61   
62   // flush the string stream and send out through the logging system
63   switch (severity) {
64   case kDebug:
65     fgHLTLogging.Logging(kHLTLogDebug, origin.c_str(), keyword.c_str(), message.c_str());
66     break;
67   case kInformational:
68     fgHLTLogging.Logging(kHLTLogInfo, origin.c_str(), keyword.c_str(), message.c_str());
69     break;
70   case kWarning:
71     fgHLTLogging.Logging(kHLTLogWarning, origin.c_str(), keyword.c_str(), message.c_str());
72     break;
73   case kError:
74     fgHLTLogging.Logging(kHLTLogError, origin.c_str(), keyword.c_str(), message.c_str());
75     break;
76   case kFatal:
77   case kPrimary:
78     fgHLTLogging.Logging(kHLTLogFatal, origin.c_str(), keyword.c_str(), message.c_str());
79     break;
80   }
81   fgStream.clear();
82   string empty("");
83   fgStream.str(empty);
84   return "";
85 }
86