GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Log.h
Go to the documentation of this file.
1 // $Id: TGo4Log.h 1879 2016-04-04 17:10:38Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #ifndef TGO4LOG_H
15 #define TGO4LOG_H
16 
17 #include "TString.h"
18 #include "RVersion.h"
19 
20 class TMutex;
21 class TLogTimer;
22 
23 #define __MESSAGETEXTLENGTH__ 1024
24 
25 // define previous trace macro void
26 #define GO4TRACE(X) ;
27 
28 #if ROOT_VERSION_CODE < ROOT_VERSION(5,99,0)
29 // one need to remove TRACE macro when using ROOT v 6
30 #define TRACE(X) ;
31 #endif
32 
33 // optional definitions
34 #define GO4MESSAGE( X ) TGo4Log::Message X;
35 #define GO4INFO(X) TGo4Log::Info X ;
36 #define GO4WARN(X) TGo4Log::Warn X ;
37 #define GO4ERROR(X) TGo4Log::Error X ;
38 
47 #ifdef __CINT__
48 class TGo4Log {
49 #else
50 #ifdef GO4_EXPORT
51 class __declspec(dllimport) TGo4Log {
52 #else
53 class TGo4Log {
54 #endif
55 #endif
56 
57  public:
58  static TGo4Log *Instance();
59 
63  static const char* GO4SYS();
64 
66  static const char* GO4INCPATH();
67 
70  static TString subGO4SYS(const char* subdir);
71 
73  static void SetIgnoreLevel(Int_t level);
74 
76  static Int_t GetIgnoreLevel();
77 
79  static void OutputEnable(Bool_t on=kTRUE);
80 
82  static Bool_t IsOutputEnabled();
83 
85  static void LogfileEnable(Bool_t on=kTRUE);
86 
88  static Bool_t IsLogfileEnabled();
89 
91  static void AutoEnable(Bool_t on=kTRUE);
92 
94  static Bool_t IsAutoEnabled();
95 
100  static void OpenLogfile(const char* name=0,
101  const char* headercomment=0,
102  Bool_t appendmode=kFALSE);
103 
105  static void CloseLogfile();
106 
108  static const char* GetLogname();
109 
116  static const char* Message(Int_t prio, const char* text,...);
117 
119  static void Debug(const char* text,...);
120 
122  static void Info(const char* text,...);
123 
125  static void Warn(const char* text,...);
126 
128  static void Error(const char* text,...);
129 
131  static void Printf(Bool_t _stdout, const char* text);
132 
135  static void WriteLogfile(const char* text, Bool_t withtime=kTRUE);
136 
138  static void set_trace_level(int) {}
139 
141  static void SetTracePriority(int) {}
142 
144  static void StartTracing() { Instance(); SetIgnoreLevel(0); }
145 
147  static void StopTracing() { Instance(); SetIgnoreLevel(1); }
148 
150  static const char* GetDefaultLogname();
151 
154  static const char* GetPrintfArg(Int_t type_id);
155 
157  static const char* fgcLEFT;
158 
160  static const char* fgcRIGHT;
161 
163  static const char* fgcDEBUG;
164 
166  static const char* fgcINFO;
167 
169  static const char* fgcWARN;
170 
172  static const char* fgcERR;
173 
175  static const char* fgcDEFAULTLOG;
176 
179 
180  virtual ~TGo4Log();
181 
182  static void SetSniffer(TNamed* sniff);
183 
184  static void EnableRedirection();
185 
186  private:
187 
188  friend class TLogTimer;
189 
190  TGo4Log();
191 
192  static void ProcessRedirection(int kind = 0);
193 
195 
197  static TMutex* fgxMutex;
198 
200  static Int_t fgiIgnoreLevel;
201 
203  static Bool_t fgbOutputEnabled;
204 
206  static Bool_t fgbLogfileEnabled;
207 
209  static Bool_t fgbAutoMode;
210 
213 
215  static void* fgxLogfile;
216 
218  static TString fgxLogName;
219 
220  static TString fgsGO4SYS;
221 
222  static TNamed* fgSniffer;
223 
224  static int fgStdPipe[2];
225  static int fgStdSave;
226 
227  static TLogTimer* fgTimer;
228 
229  ClassDef(TGo4Log,1)
230 };
231 
232 /* for backward compatibility in user code: */
234 
235 #endif //TGO4LOG_H
static const char * GetLogname()
Definition: TGo4Log.cxx:333
static TGo4Log * Instance()
Definition: TGo4Log.cxx:87
static TGo4Log * fgxInstance
Definition: TGo4Log.h:194
static const char * fgcWARN
Definition: TGo4Log.h:169
static void WriteLogfile(const char *text, Bool_t withtime=kTRUE)
Definition: TGo4Log.cxx:428
static void CloseLogfile()
Definition: TGo4Log.cxx:449
static Bool_t IsOutputEnabled()
Definition: TGo4Log.cxx:364
static void Warn(const char *text,...)
Definition: TGo4Log.cxx:296
static const char * GetPrintfArg(Int_t type_id)
Definition: TGo4Log.cxx:343
static Bool_t fgbLogfileEnabled
Definition: TGo4Log.h:206
static const char * GetDefaultLogname()
Definition: TGo4Log.cxx:338
static Bool_t fgbAutoMode
Definition: TGo4Log.h:209
static void SetIgnoreLevel(Int_t level)
Definition: TGo4Log.cxx:322
static void OutputEnable(Bool_t on=kTRUE)
Definition: TGo4Log.cxx:358
static const char * fgcRIGHT
Definition: TGo4Log.h:160
static void OpenLogfile(const char *name=0, const char *headercomment=0, Bool_t appendmode=kFALSE)
Definition: TGo4Log.cxx:391
static const char * fgcDEBUG
Definition: TGo4Log.h:163
static Bool_t fgbOutputEnabled
Definition: TGo4Log.h:203
static TString fgsGO4SYS
Definition: TGo4Log.h:220
static int fgStdSave
redirected pipe for stdout
Definition: TGo4Log.h:225
static void ProcessRedirection(int kind=0)
Definition: TGo4Log.cxx:120
virtual ~TGo4Log()
Definition: TGo4Log.cxx:82
static void SetSniffer(TNamed *sniff)
Definition: TGo4Log.cxx:153
static const char * fgcINFO
Definition: TGo4Log.h:166
TGo4Log()
Definition: TGo4Log.cxx:69
static const char * GO4INCPATH()
Definition: TGo4Log.cxx:181
static void EnableRedirection()
Definition: TGo4Log.cxx:95
static int fgStdPipe[2]
optional object to get all output via SetTitle method
Definition: TGo4Log.h:224
static Bool_t IsLogfileEnabled()
Definition: TGo4Log.cxx:375
static const char * fgcDEFAULTLOG
Definition: TGo4Log.h:175
static void StopTracing()
Definition: TGo4Log.h:147
static const char * Message(Int_t prio, const char *text,...)
Definition: TGo4Log.cxx:209
static Int_t fgiIgnoreLevel
Definition: TGo4Log.h:200
static TString fgxLogName
Definition: TGo4Log.h:218
static void Printf(Bool_t _stdout, const char *text)
Definition: TGo4Log.cxx:255
static TMutex * fgxMutex
Definition: TGo4Log.h:197
static void * fgxLogfile
Definition: TGo4Log.h:215
static void set_trace_level(int)
Definition: TGo4Log.h:138
static Int_t GetIgnoreLevel()
Definition: TGo4Log.cxx:328
static TNamed * fgSniffer
value of GO4SYS during run
Definition: TGo4Log.h:222
static void StartTracing()
Definition: TGo4Log.h:144
static TString subGO4SYS(const char *subdir)
Definition: TGo4Log.cxx:192
static char fgcMessagetext[__MESSAGETEXTLENGTH__]
Definition: TGo4Log.h:212
static const char * fgcLEFT
Definition: TGo4Log.h:157
static const char * GO4SYS()
Definition: TGo4Log.cxx:158
static TLogTimer * fgTimer
saved file for stdout
Definition: TGo4Log.h:227
static void AutoEnable(Bool_t on=kTRUE)
Definition: TGo4Log.cxx:380
#define __MESSAGETEXTLENGTH__
Definition: TGo4Log.h:23
static const char * fgcERR
Definition: TGo4Log.h:172
TGo4Log TGo4Trace
Definition: TGo4Log.h:233
static void SetTracePriority(int)
Definition: TGo4Log.h:141
static void Error(const char *text,...)
Definition: TGo4Log.cxx:309
static Bool_t IsAutoEnabled()
Definition: TGo4Log.cxx:386
static void Info(const char *text,...)
Definition: TGo4Log.cxx:283
static void Debug(const char *text,...)
Definition: TGo4Log.cxx:270
static void LogfileEnable(Bool_t on=kTRUE)
Definition: TGo4Log.cxx:369