GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4Log.h
Go to the documentation of this file.
1// $Id$
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
19class TMutex;
20class TLogTimer;
21
22#define __MESSAGETEXTLENGTH__ 1024
23
24// define previous trace macro void
25#define GO4TRACE(X) ;
26
27// optional definitions
28#define GO4MESSAGE( X ) TGo4Log::Message X;
29#define GO4INFO(X) TGo4Log::Info X ;
30#define GO4WARN(X) TGo4Log::Warn X ;
31#define GO4ERROR(X) TGo4Log::Error X ;
32
33#if defined(__GNUC__) && !defined(__CLING__)
34#define GO4_PRINTF_ARGS __attribute__((format(printf, 1, 2)))
35#define GO4_PRINTF2_ARGS __attribute__((format(printf, 2, 3)))
36#else
37#define GO4_PRINTF_ARGS
38#define GO4_PRINTF2_ARGS
39#endif
40
41
48
49
50class TGo4Log {
51
52 public:
53 static TGo4Log *Instance();
54
58 static const char *GO4SYS();
59
61 static const char *GO4INCPATH();
62
65 static TString subGO4SYS(const char *subdir);
66
68 static void SetIgnoreLevel(Int_t level);
69
71 static Int_t GetIgnoreLevel();
72
74 static void OutputEnable(Bool_t on=kTRUE);
75
77 static Bool_t IsOutputEnabled();
78
80 static void LogfileEnable(Bool_t on=kTRUE);
81
83 static Bool_t IsLogfileEnabled();
84
86 static void AutoEnable(Bool_t on=kTRUE);
87
89 static Bool_t IsAutoEnabled();
90
95 static void OpenLogfile(const char *name = nullptr,
96 const char *headercomment = nullptr,
97 Bool_t appendmode = kFALSE);
98
100 static void CloseLogfile();
101
103 static const char *GetLogname();
104
111 static const char *Message(Int_t prio, const char *text,...) GO4_PRINTF2_ARGS;
112
114 static void Debug(const char *text,...) GO4_PRINTF_ARGS;
115
117 static void Info(const char *text,...) GO4_PRINTF_ARGS;
118
120 static void Warn(const char *text,...) GO4_PRINTF_ARGS;
121
123 static void Error(const char *text,...) GO4_PRINTF_ARGS;
124
126 static void Printf(Bool_t _stdout, const char *text);
127
129 static void PrintRate(ULong64_t cnt, double rate);
130
133 static void WriteLogfile(const char *text, Bool_t withtime = kTRUE);
134
136 static void set_trace_level(int) {}
137
139 static void SetTracePriority(int) {}
140
142 static void StartTracing() { Instance(); SetIgnoreLevel(0); }
143
145 static void StopTracing() { Instance(); SetIgnoreLevel(1); }
146
148 static const char *GetDefaultLogname();
149
151 static const char *fgcLEFT;
152
154 static const char *fgcRIGHT;
155
157 static const char *fgcDEBUG;
158
160 static const char *fgcINFO;
161
163 static const char *fgcWARN;
164
166 static const char *fgcERR;
167
169 static const char *fgcDEFAULTLOG;
170
173
174 virtual ~TGo4Log();
175
176 static void SetSniffer(TNamed *sniff);
177
178 static void EnableRedirection();
179
180 private:
181
182 friend class TLogTimer;
183
184 TGo4Log();
185
186 static void ProcessRedirection(int kind = 0);
187
189
191 static TMutex *fgxMutex;
192
194 static Int_t fgiIgnoreLevel;
195
197 static Bool_t fgbOutputEnabled;
198
200 static Bool_t fgbLogfileEnabled;
201
203 static Bool_t fgbAutoMode;
204
207
209 static void *fgxLogfile;
210
212 static TString fgxLogName;
213
214 static TString fgsGO4SYS;
215
216 static TNamed *fgSniffer;
217
218 static int fgStdPipe[2];
219 static int fgStdSave;
220
222
223 ClassDef(TGo4Log,0)
224};
225
226/* for backward compatibility in user code: */
228
229#endif //TGO4LOG_H
#define GO4_PRINTF2_ARGS
Definition TGo4Log.h:38
#define __MESSAGETEXTLENGTH__
Definition TGo4Log.h:22
TGo4Log TGo4Trace
Definition TGo4Log.h:227
#define GO4_PRINTF_ARGS
Definition TGo4Log.h:37
This class handles all logging messages inside Go4.
Definition TGo4Log.h:50
static void StartTracing()
For backward compatibility.
Definition TGo4Log.h:142
static const char * fgcDEFAULTLOG
Name of default logfile.
Definition TGo4Log.h:169
static void set_trace_level(int)
dummy for compatibility
Definition TGo4Log.h:136
static TGo4Log * Instance()
Definition TGo4Log.cxx:85
static TString subGO4SYS(const char *subdir)
Return subdirectory in the GO4SYS.
Definition TGo4Log.cxx:189
static void StopTracing()
For backward compatibility.
Definition TGo4Log.h:145
static void Warn(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 2.
Definition TGo4Log.cxx:307
static Bool_t IsAutoEnabled()
get current user boolean
Definition TGo4Log.cxx:378
static void ProcessRedirection(int kind=0)
Definition TGo4Log.cxx:118
static void Info(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 1.
Definition TGo4Log.cxx:294
static void PrintRate(ULong64_t cnt, double rate)
Printout rate and events count, handle redirection.
Definition TGo4Log.cxx:270
static Bool_t fgbOutputEnabled
General switch on/off log output.
Definition TGo4Log.h:197
static const char * GetLogname()
get name of last opened logfile
Definition TGo4Log.cxx:343
static void WriteLogfile(const char *text, Bool_t withtime=kTRUE)
Write text to current logfile if this is open.
Definition TGo4Log.cxx:420
friend class TLogTimer
Definition TGo4Log.h:182
static const char * Message(Int_t prio, const char *text,...) GO4_PRINTF2_ARGS
Display a message.
Definition TGo4Log.cxx:206
static const char * GO4SYS()
Return GO4SYS environment variable or Go4 top directory during compile (if GO4SYS) not set.
Definition TGo4Log.cxx:156
static const char * fgcINFO
Info message indicator.
Definition TGo4Log.h:160
static char fgcMessagetext[__MESSAGETEXTLENGTH__]
Keeps latest message with all format indicators.
Definition TGo4Log.h:206
static Bool_t IsLogfileEnabled()
get current logfile state
Definition TGo4Log.cxx:368
static void Printf(Bool_t _stdout, const char *text)
Make direct printf without log file or logger.
Definition TGo4Log.cxx:254
static const char * fgcRIGHT
Prompt character right side.
Definition TGo4Log.h:154
static const char * fgcERR
Error message indicator.
Definition TGo4Log.h:166
static void SetIgnoreLevel(Int_t level)
Define threshold for output.
Definition TGo4Log.cxx:332
static const char * fgcWARN
Warning message indicator.
Definition TGo4Log.h:163
static void LogfileEnable(Bool_t on=kTRUE)
switch writing to logfile on or off
Definition TGo4Log.cxx:363
static void SetSniffer(TNamed *sniff)
Definition TGo4Log.cxx:151
static int fgStdPipe[2]
optional object to get all output via SetTitle method
Definition TGo4Log.h:55
static Int_t fgiIgnoreLevel
all Messages with lower level are suppressed
Definition TGo4Log.h:194
static void Debug(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 0.
Definition TGo4Log.cxx:281
static const char * fgcDEBUG
System debug message indicator.
Definition TGo4Log.h:157
static TString fgxLogName
Name of last logfile set.
Definition TGo4Log.h:212
static const char * GO4INCPATH()
Return include path for this Go4 installation.
Definition TGo4Log.cxx:179
static void SetTracePriority(int)
dummy for compatibility
Definition TGo4Log.h:139
static void AutoEnable(Bool_t on=kTRUE)
set boolean for user action
Definition TGo4Log.cxx:373
static TMutex * fgxMutex
we use own mutex to protect the logging instance
Definition TGo4Log.h:191
static void EnableRedirection()
Definition TGo4Log.cxx:93
static void OutputEnable(Bool_t on=kTRUE)
switch output on or off
Definition TGo4Log.cxx:353
static void Error(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 3.
Definition TGo4Log.cxx:320
static int fgStdSave
redirected pipe for stdout
Definition TGo4Log.h:219
static Bool_t fgbAutoMode
User boolean to write log on demand or not.
Definition TGo4Log.h:203
static Bool_t IsOutputEnabled()
get current output state
Definition TGo4Log.cxx:358
@ fguMESLEN
Definition TGo4Log.h:172
static TString fgsGO4SYS
Definition TGo4Log.h:214
static TNamed * fgSniffer
value of GO4SYS during run
Definition TGo4Log.h:216
virtual ~TGo4Log()
Definition TGo4Log.cxx:80
static Int_t GetIgnoreLevel()
Get threshold for output.
Definition TGo4Log.cxx:338
static void OpenLogfile(const char *name=nullptr, const char *headercomment=nullptr, Bool_t appendmode=kFALSE)
Open file of name for logmessage output.
Definition TGo4Log.cxx:383
static void * fgxLogfile
optional logfile to store messages with time
Definition TGo4Log.h:209
static void CloseLogfile()
Close logfile if existing.
Definition TGo4Log.cxx:444
TGo4Log()
Definition TGo4Log.cxx:68
static const char * fgcLEFT
Prompt character left side.
Definition TGo4Log.h:151
static const char * GetDefaultLogname()
Return default name of log file.
Definition TGo4Log.cxx:348
static Bool_t fgbLogfileEnabled
General switch on/off log file output.
Definition TGo4Log.h:200
static TGo4Log * fgxInstance
Definition TGo4Log.h:188
static TLogTimer * fgTimer
saved file for stdout
Definition TGo4Log.h:221