FEDRA emulsion software from the OPERA Collaboration
EdbLog.cxx File Reference
#include "snprintf.h"
#include "Varargs.h"
#include "TVirtualMutex.h"
#include "TSystem.h"
#include "TDatime.h"
#include "EdbLog.h"
Include dependency graph for EdbLog.cxx:

Macros

#define R__VA_COPY(to, from)   ((to) = (from))
 

Functions

bool Log (int level, const char *location, const char *fmt,...)
 
void Log0 (int level, const char *location, const char *fmt, va_list ap)
 

Variables

TNtuple * gDIFF =0
 
Int_t gEDBDEBUGLEVEL = 2
 
FILE * gEDBLOGFILE =0
 

Macro Definition Documentation

◆ R__VA_COPY

#define R__VA_COPY (   to,
  from 
)    ((to) = (from))

Function Documentation

◆ Log()

bool Log ( int  level,
const char *  location,
const char *  fmt,
  ... 
)
76 {
77 // Print message to the logfile and to stdout.
78  if(level>gEDBDEBUGLEVEL) return 0;
79  va_list ap;
80  va_start(ap,va_(fmt));
81  Log0(level, location, va_(fmt), ap);
82  va_end(ap);
83  return 1;
84 }
Int_t gEDBDEBUGLEVEL
Definition: EdbLog.cxx:24
void Log0(int level, const char *location, const char *fmt, va_list ap)
Definition: EdbLog.cxx:87

◆ Log0()

void Log0 ( int  level,
const char *  location,
const char *  fmt,
va_list  ap 
)
88 {
89 // Print message to the logfile and to stdout.
90 
91  R__LOCKGUARD2(gGlobalMutex);
92 
93  static Int_t buf_size = 2048;
94  static char *buf = 0;
95 
96  va_list sap;
97  R__VA_COPY(sap, ap);
98 
99  again:
100  if (!buf)
101  buf = new char[buf_size];
102 
103  if (!fmt)
104  fmt = "no error message provided";
105 
106  Int_t n = vsnprintf(buf, buf_size, fmt, ap);
107  // old vsnprintf's return -1 if string is truncated new ones return
108  // total number of characters that would have been written
109  if (n == -1 || n >= buf_size) {
110  if (n == -1)
111  buf_size *= 2;
112  else
113  buf_size = n+1;
114  delete [] buf;
115  buf = 0;
116  va_end(ap);
117  R__VA_COPY(ap, sap);
118  goto again;
119  }
120  va_end(sap);
121 
122  if(level<=gEDBDEBUGLEVEL) {
123  fprintf(stdout, "%-16s: ", location);
124  fprintf(stdout, "%s\n", buf);
125  }
126  if(level>2) return; // do not print to file not important mesages
127  TDatime t;
128  if(gEDBLOGFILE) {
129  fprintf(gEDBLOGFILE, "%s> ", t.AsSQLString());
130  fprintf(gEDBLOGFILE, "%-16s: ", location);
131  fprintf(gEDBLOGFILE, "%s\n", buf);
132  }
133 }
FILE * gEDBLOGFILE
Definition: EdbLog.cxx:25
#define R__VA_COPY(to, from)
Definition: EdbLog.cxx:20
FILE * stdout
TTree * t
Definition: check_shower.C:4

Variable Documentation

◆ gDIFF

TNtuple* gDIFF =0

◆ gEDBDEBUGLEVEL

Int_t gEDBDEBUGLEVEL = 2

◆ gEDBLOGFILE

FILE* gEDBLOGFILE =0