]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCLog.cxx
documentation, formatting, coding conventions
[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 // lagacy logging methods for HLT TPC code
5 // or                                                                        //
6 // refer to README to build package                                          //
7 // or                                                                        //
8 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt                          //
9
10 #include "AliHLTTPCLog.h"
11
12 AliHLTTPCLog::TLogLevel AliHLTTPCLog::fgLevel=AliHLTTPCLog::kNone;
13
14 const char* AliHLTTPCLog::kEnd = "";
15 const char* AliHLTTPCLog::kPrec = "";
16 const char* AliHLTTPCLog::kHex = "";
17 const char* AliHLTTPCLog::kDec = "";
18
19 const char* AliHLTTPCLog::fgKeyOrigin ="__origin";
20 const char* AliHLTTPCLog::fgKeyKeyword="__key";
21 const char* AliHLTTPCLog::fgKeyMessage="__message";
22
23 stringstream AliHLTTPCLog::fgStream;
24
25 AliHLTLogging AliHLTTPCLog::fgHLTLogging;
26
27 const char* AliHLTTPCLog::Flush()
28 {
29   // see header file for class documentation
30   int severity=0;
31   string origin("");
32   string keyword("");
33   string iter;
34   string message("");
35   int scanStatus=0;
36   fgStream >> severity;
37   while (!fgStream.eof()) {
38     fgStream >> iter;
39     if (scanStatus==0 && iter.compare(fgKeyOrigin)==0) {
40       // idicate scan of origin message
41       scanStatus=1;
42       continue;
43     } else if (scanStatus==1 && iter.compare(fgKeyKeyword)==0) {
44       // idicate scan of keyword message
45       scanStatus=2;
46       continue;
47     } else if (scanStatus==2 && iter.compare(fgKeyMessage)==0) {
48       scanStatus=3;
49       continue;
50     }
51     switch (scanStatus) {
52     case 1:
53       if (!origin.empty()) origin+=" ";
54       origin+=iter;
55       break;
56     case 2:
57       if (!keyword.empty()) keyword+=" ";
58       keyword+=iter;
59       break;
60     default:
61       // if we have come here already for the first word, we don't
62       // expect origin and keyword any more
63       scanStatus=3;
64       if (!message.empty()) message+=" ";
65       message+=iter;
66     }
67   }
68   
69   // flush the string stream and send out through the logging system
70   switch (severity) {
71   case kDebug:
72     fgHLTLogging.Logging(kHLTLogDebug, origin.c_str(), keyword.c_str(), message.c_str());
73     break;
74   case kInformational:
75     fgHLTLogging.Logging(kHLTLogInfo, origin.c_str(), keyword.c_str(), message.c_str());
76     break;
77   case kWarning:
78     fgHLTLogging.Logging(kHLTLogWarning, origin.c_str(), keyword.c_str(), message.c_str());
79     break;
80   case kError:
81     fgHLTLogging.Logging(kHLTLogError, origin.c_str(), keyword.c_str(), message.c_str());
82     break;
83   case kFatal:
84   case kPrimary:
85     fgHLTLogging.Logging(kHLTLogFatal, origin.c_str(), keyword.c_str(), message.c_str());
86     break;
87   }
88   fgStream.clear();
89   string empty("");
90   fgStream.str(empty);
91   return "";
92 }
93