]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCLog.cxx
ecc8c6b66595471f7a6503aa5e4ff6156c7f9b4a
[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   // see header file for class documentation
24   int severity=0;
25   string origin("");
26   string keyword("");
27   string iter;
28   string message("");
29   int scanStatus=0;
30   fgStream >> severity;
31   while (!fgStream.eof()) {
32     fgStream >> iter;
33     if (scanStatus==0 && iter.compare(fgKeyOrigin)==0) {
34       // idicate scan of origin message
35       scanStatus=1;
36       continue;
37     } else if (scanStatus==1 && iter.compare(fgKeyKeyword)==0) {
38       // idicate scan of keyword message
39       scanStatus=2;
40       continue;
41     } else if (scanStatus==2 && iter.compare(fgKeyMessage)==0) {
42       scanStatus=3;
43       continue;
44     }
45     switch (scanStatus) {
46     case 1:
47       if (!origin.empty()) origin+=" ";
48       origin+=iter;
49       break;
50     case 2:
51       if (!keyword.empty()) keyword+=" ";
52       keyword+=iter;
53       break;
54     default:
55       // if we have come here already for the first word, we don't
56       // expect origin and keyword any more
57       scanStatus=3;
58       if (!message.empty()) message+=" ";
59       message+=iter;
60     }
61   }
62   
63   // flush the string stream and send out through the logging system
64   switch (severity) {
65   case kDebug:
66     fgHLTLogging.Logging(kHLTLogDebug, origin.c_str(), keyword.c_str(), message.c_str());
67     break;
68   case kInformational:
69     fgHLTLogging.Logging(kHLTLogInfo, origin.c_str(), keyword.c_str(), message.c_str());
70     break;
71   case kWarning:
72     fgHLTLogging.Logging(kHLTLogWarning, origin.c_str(), keyword.c_str(), message.c_str());
73     break;
74   case kError:
75     fgHLTLogging.Logging(kHLTLogError, origin.c_str(), keyword.c_str(), message.c_str());
76     break;
77   case kFatal:
78   case kPrimary:
79     fgHLTLogging.Logging(kHLTLogFatal, origin.c_str(), keyword.c_str(), message.c_str());
80     break;
81   }
82   fgStream.clear();
83   string empty("");
84   fgStream.str(empty);
85   return "";
86 }
87