112 long flags = fcntl(
fgStdPipe[0], F_GETFL, 0);
113 fcntl(
fgStdPipe[0], F_SETFL, flags | O_NONBLOCK);
116 fcntl(
fgStdPipe[1], F_SETFL, flags | O_NONBLOCK);
138 memset(buffer, 0,
sizeof(buffer));
139 int len = read(
fgStdPipe[0], buffer,
sizeof(buffer)-1);
142 if (len == 0)
return;
146 printf(
"%s", buffer);
167 const char *go4sys = gSystem->Getenv(
"GO4SYS");
169 if (!go4sys || (strlen(go4sys) == 0)) go4sys = COMP_GO4SYS;
171 if (!go4sys || (strlen(go4sys) == 0))
return "";
176 char lastsymbol =
'\\';
179 char lastsymbol =
'/';
199 const char *go4sys =
GO4SYS();
201 if (!subdir || (strlen(subdir) == 0))
return TString(go4sys);
203 TString res = go4sys;
206 res += TString(subdir).ReplaceAll(
"/",
"\\");
221 va_start(args, text);
222 vsnprintf(txtbuf,
fguMESLEN-20, text, args);
227 case -1: prefix =
fgcINFO;
break;
229 case 1: prefix =
fgcINFO;
break;
230 case 2: prefix =
fgcWARN;
break;
231 case 3: prefix =
fgcERR;
break;
267 fprintf(stdout,
"%s", text);
270 fprintf(stderr,
"%s", text);
282 int width = (rate > 1e4) ? 0 : (rate < 1. ? 3 : 1);
283 fprintf(stdout,
"\rCnt = %llu Rate = %5.*f Ev/s", cnt, width, rate);
296 va_start(args, text);
297 vsnprintf(txtbuf,
fguMESLEN, text, args);
309 va_start(args, text);
310 vsnprintf(txtbuf,
fguMESLEN, text, args);
322 va_start(args, text);
323 vsnprintf(txtbuf,
fguMESLEN, text, args);
334 va_start(args, text);
335 vsnprintf(txtbuf,
fguMESLEN, text, args);
400 snprintf(txtbuf,
fguMESLEN,
"go4log-%d.txt", gSystem->GetPid());
404 std::ofstream* lf =
new std::ofstream(txtbuf, appendmode ? std::ios::app : std::ios::out);
409 std::cerr <<
"TGo4Log::OpenLogfile() - Error opening logfile "<< name << std::endl;
418 catch(std::exception& ex)
420 std::cerr <<
"standard exception "<<ex.what()<<
"in TGo4Log::OpenLogfile" << std::endl;
424 std::cerr <<
"!!! Unexpected exception in TGo4Log::OpenLogfile !!!" << std::endl;
433 std::ofstream *lf =
static_cast<std::ofstream*
>(
fgxLogfile);
437 *lf << now.AsSQLString() <<
": ";
439 *lf << text << std::endl;
442 catch(std::exception& ex)
444 std::cerr <<
"standard exception "<<ex.what()<<
"in TGo4Log::WriteLogfile" << std::endl;
448 std::cerr <<
"!!! Unexpected exception in TGo4Log::WriteLogfile !!!" << std::endl;
462 catch(std::exception& ex)
464 std::cerr <<
"standard exception "<<ex.what()<<
"in TGo4Log::CloseLogfile" << std::endl;
468 std::cerr <<
"!!! Unexpected exception in TGo4Log::CloseLogfile !!!" << std::endl;
#define __MESSAGETEXTLENGTH__
This class handles all logging messages inside Go4.
static TGo4Log * Instance()
static TString subGO4SYS(const char *subdir)
Return subdirectory in the GO4SYS.
static const char * fgcLEFT
Prompt character left side.
static void Warn(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 2.
static Bool_t IsAutoEnabled()
get current user boolean
static void ProcessRedirection(int kind=0)
static void Info(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 1.
static char fgcMessagetext[__MESSAGETEXTLENGTH__]
Keeps latest message with all format indicators.
static Bool_t fgbLogfileEnabled
General switch on/off log file output.
static int fgStdSave
redirected pipe for stdout
static void PrintRate(ULong64_t cnt, double rate)
Printout rate and events count, handle redirection.
static const char * GetLogname()
get name of last opened logfile
static void WriteLogfile(const char *text, Bool_t withtime=kTRUE)
Write text to current logfile if this is open.
static const char * Message(Int_t prio, const char *text,...) GO4_PRINTF2_ARGS
Display a message.
static const char * fgcDEBUG
System debug message indicator.
static const char * GO4SYS()
Return GO4SYS environment variable or Go4 top directory during compile (if GO4SYS) not set.
static const char * fgcINFO
Info message indicator.
static const char * fgcDEFAULTLOG
Name of default logfile.
static Bool_t IsLogfileEnabled()
get current logfile state
static void Printf(Bool_t _stdout, const char *text)
Make direct printf without log file or logger.
static TGo4Log * fgxInstance
static TMutex * fgxMutex
we use own mutex to protect the logging instance
static void SetIgnoreLevel(Int_t level)
Define threshold for output.
static TLogTimer * fgTimer
saved file for stdout
static void LogfileEnable(Bool_t on=kTRUE)
switch writing to logfile on or off
static void SetSniffer(TNamed *sniff)
static const char * fgcWARN
Warning message indicator.
static void Debug(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 0.
static Int_t fgiIgnoreLevel
all Messages with lower level are suppressed
static const char * GO4INCPATH()
Return include path for this Go4 installation.
static TString fgxLogName
Name of last logfile set.
static void AutoEnable(Bool_t on=kTRUE)
set boolean for user action
static void EnableRedirection()
static void * fgxLogfile
optional logfile to store messages with time
static void OutputEnable(Bool_t on=kTRUE)
switch output on or off
static void Error(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 3.
static Bool_t fgbOutputEnabled
General switch on/off log output.
static Bool_t IsOutputEnabled()
get current output state
static Int_t GetIgnoreLevel()
Get threshold for output.
static TNamed * fgSniffer
value of GO4SYS during run
static void OpenLogfile(const char *name=nullptr, const char *headercomment=nullptr, Bool_t appendmode=kFALSE)
Open file of name for logmessage output.
static void CloseLogfile()
Close logfile if existing.
static int fgStdPipe[2]
optional object to get all output via SetTitle method
static Bool_t fgbAutoMode
User boolean to write log on demand or not.
static const char * fgcRIGHT
Prompt character right side.
static const char * GetDefaultLogname()
Return default name of log file.
static const char * fgcERR
Error message indicator.
TLogTimer(Int_t millisec)
#define __MESSAGETEXTLENGTH__