GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Log.h
Go to the documentation of this file.
1 // $Id: TGo4Log.h 3515 2022-01-24 11:06:44Z 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 fuer 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 class TGo4Log {
48 
49  public:
50  static TGo4Log *Instance();
51 
55  static const char* GO4SYS();
56 
58  static const char* GO4INCPATH();
59 
62  static TString subGO4SYS(const char* subdir);
63 
65  static void SetIgnoreLevel(Int_t level);
66 
68  static Int_t GetIgnoreLevel();
69 
71  static void OutputEnable(Bool_t on=kTRUE);
72 
74  static Bool_t IsOutputEnabled();
75 
77  static void LogfileEnable(Bool_t on=kTRUE);
78 
80  static Bool_t IsLogfileEnabled();
81 
83  static void AutoEnable(Bool_t on=kTRUE);
84 
86  static Bool_t IsAutoEnabled();
87 
92  static void OpenLogfile(const char* name=0,
93  const char* headercomment=0,
94  Bool_t appendmode=kFALSE);
95 
97  static void CloseLogfile();
98 
100  static const char* GetLogname();
101 
108  static const char* Message(Int_t prio, const char* text,...);
109 
111  static void Debug(const char* text,...);
112 
114  static void Info(const char* text,...);
115 
117  static void Warn(const char* text,...);
118 
120  static void Error(const char* text,...);
121 
123  static void Printf(Bool_t _stdout, const char* text);
124 
126  static void PrintRate(ULong64_t cnt, double rate);
127 
130  static void WriteLogfile(const char* text, Bool_t withtime=kTRUE);
131 
133  static void set_trace_level(int) {}
134 
136  static void SetTracePriority(int) {}
137 
139  static void StartTracing() { Instance(); SetIgnoreLevel(0); }
140 
142  static void StopTracing() { Instance(); SetIgnoreLevel(1); }
143 
145  static const char* GetDefaultLogname();
146 
148  static const char* fgcLEFT;
149 
151  static const char* fgcRIGHT;
152 
154  static const char* fgcDEBUG;
155 
157  static const char* fgcINFO;
158 
160  static const char* fgcWARN;
161 
163  static const char* fgcERR;
164 
166  static const char* fgcDEFAULTLOG;
167 
170 
171  virtual ~TGo4Log();
172 
173  static void SetSniffer(TNamed* sniff);
174 
175  static void EnableRedirection();
176 
177  private:
178 
179  friend class TLogTimer;
180 
181  TGo4Log();
182 
183  static void ProcessRedirection(int kind = 0);
184 
186 
188  static TMutex* fgxMutex;
189 
191  static Int_t fgiIgnoreLevel;
192 
194  static Bool_t fgbOutputEnabled;
195 
197  static Bool_t fgbLogfileEnabled;
198 
200  static Bool_t fgbAutoMode;
201 
204 
206  static void* fgxLogfile;
207 
209  static TString fgxLogName;
210 
211  static TString fgsGO4SYS;
212 
213  static TNamed* fgSniffer;
214 
215  static int fgStdPipe[2];
216  static int fgStdSave;
217 
218  static TLogTimer* fgTimer;
219 
220  ClassDef(TGo4Log,1)
221 };
222 
223 /* for backward compatibility in user code: */
225 
226 #endif //TGO4LOG_H
static const char * GetLogname()
Definition: TGo4Log.cxx:347
static TGo4Log * Instance()
Definition: TGo4Log.cxx:86
static TGo4Log * fgxInstance
Definition: TGo4Log.h:185
static const char * fgcWARN
Definition: TGo4Log.h:160
static void WriteLogfile(const char *text, Bool_t withtime=kTRUE)
Definition: TGo4Log.cxx:424
static void CloseLogfile()
Definition: TGo4Log.cxx:448
static Bool_t IsOutputEnabled()
Definition: TGo4Log.cxx:362
static void Warn(const char *text,...)
Definition: TGo4Log.cxx:310
static Bool_t fgbLogfileEnabled
Definition: TGo4Log.h:197
static const char * GetDefaultLogname()
Definition: TGo4Log.cxx:352
static Bool_t fgbAutoMode
Definition: TGo4Log.h:200
static void SetIgnoreLevel(Int_t level)
Definition: TGo4Log.cxx:336
static void OutputEnable(Bool_t on=kTRUE)
Definition: TGo4Log.cxx:357
static const char * fgcRIGHT
Definition: TGo4Log.h:151
static void OpenLogfile(const char *name=0, const char *headercomment=0, Bool_t appendmode=kFALSE)
Definition: TGo4Log.cxx:387
static const char * fgcDEBUG
Definition: TGo4Log.h:154
static Bool_t fgbOutputEnabled
Definition: TGo4Log.h:194
static TString fgsGO4SYS
Definition: TGo4Log.h:211
static int fgStdSave
redirected pipe for stdout
Definition: TGo4Log.h:216
static void ProcessRedirection(int kind=0)
Definition: TGo4Log.cxx:119
virtual ~TGo4Log()
Definition: TGo4Log.cxx:81
static void SetSniffer(TNamed *sniff)
Definition: TGo4Log.cxx:152
static const char * fgcINFO
Definition: TGo4Log.h:157
TGo4Log()
Definition: TGo4Log.cxx:68
static const char * GO4INCPATH()
Definition: TGo4Log.cxx:180
static void EnableRedirection()
Definition: TGo4Log.cxx:94
static int fgStdPipe[2]
optional object to get all output via SetTitle method
Definition: TGo4Log.h:215
static Bool_t IsLogfileEnabled()
Definition: TGo4Log.cxx:372
static const char * fgcDEFAULTLOG
Definition: TGo4Log.h:166
static void StopTracing()
Definition: TGo4Log.h:142
static const char * Message(Int_t prio, const char *text,...)
Definition: TGo4Log.cxx:207
static Int_t fgiIgnoreLevel
Definition: TGo4Log.h:191
static TString fgxLogName
Definition: TGo4Log.h:209
static void Printf(Bool_t _stdout, const char *text)
Definition: TGo4Log.cxx:257
static void PrintRate(ULong64_t cnt, double rate)
Definition: TGo4Log.cxx:273
static TMutex * fgxMutex
Definition: TGo4Log.h:188
static void * fgxLogfile
Definition: TGo4Log.h:206
static void set_trace_level(int)
Definition: TGo4Log.h:133
static Int_t GetIgnoreLevel()
Definition: TGo4Log.cxx:342
static TNamed * fgSniffer
value of GO4SYS during run
Definition: TGo4Log.h:213
static void StartTracing()
Definition: TGo4Log.h:139
static TString subGO4SYS(const char *subdir)
Definition: TGo4Log.cxx:190
static char fgcMessagetext[__MESSAGETEXTLENGTH__]
Definition: TGo4Log.h:203
static const char * fgcLEFT
Definition: TGo4Log.h:148
static const char * GO4SYS()
Definition: TGo4Log.cxx:157
static TLogTimer * fgTimer
saved file for stdout
Definition: TGo4Log.h:218
static void AutoEnable(Bool_t on=kTRUE)
Definition: TGo4Log.cxx:377
#define __MESSAGETEXTLENGTH__
Definition: TGo4Log.h:23
static const char * fgcERR
Definition: TGo4Log.h:163
TGo4Log TGo4Trace
Definition: TGo4Log.h:224
static void SetTracePriority(int)
Definition: TGo4Log.h:136
static void Error(const char *text,...)
Definition: TGo4Log.cxx:323
static Bool_t IsAutoEnabled()
Definition: TGo4Log.cxx:382
static void Info(const char *text,...)
Definition: TGo4Log.cxx:297
static void Debug(const char *text,...)
Definition: TGo4Log.cxx:284
static void LogfileEnable(Bool_t on=kTRUE)
Definition: TGo4Log.cxx:367