XRootD
Loading...
Searching...
No Matches
XrdSysTrace Class Reference

#include <XrdSysTrace.hh>

+ Collaboration diagram for XrdSysTrace:

Public Types

typedef void(* msgCB_t) (const char *tid, const char *msg, bool dbgmsg)
 

Public Member Functions

 XrdSysTrace (const char *pfx, XrdSysLogger *logp=0, int tf=0)
 
 ~XrdSysTrace ()
 
XrdSysTraceBeg (const char *usr=0, const char *epn=0, const char *txt=0)
 
XrdSysTraceEnd ()
 
XrdSysTraceoperator<< (bool val)
 
XrdSysTraceoperator<< (char val)
 
XrdSysTraceoperator<< (const char *val)
 
XrdSysTraceoperator<< (const std::string &val)
 
XrdSysTraceoperator<< (double val)
 
XrdSysTraceoperator<< (float val)
 
XrdSysTraceoperator<< (int val)
 
XrdSysTraceoperator<< (long double val)
 
XrdSysTraceoperator<< (long long val)
 
XrdSysTraceoperator<< (long val)
 
XrdSysTraceoperator<< (short val)
 
XrdSysTraceoperator<< (unsigned int val)
 
XrdSysTraceoperator<< (unsigned long long val)
 
XrdSysTraceoperator<< (unsigned long val)
 
XrdSysTraceoperator<< (unsigned short val)
 
XrdSysTraceoperator<< (void *val)
 
XrdSysTraceoperator<< (Xrd::Fmt val)
 
XrdSysTraceoperator<< (XrdSysTrace *stp)
 
void SetLogger (msgCB_t cbP)
 
void SetLogger (XrdSysLogger *logp)
 
bool Tracing (int mask)
 

Public Attributes

int What
 

Detailed Description

Definition at line 48 of file XrdSysTrace.hh.

Member Typedef Documentation

◆ msgCB_t

typedef void(* XrdSysTrace::msgCB_t) (const char *tid, const char *msg, bool dbgmsg)

Definition at line 58 of file XrdSysTrace.hh.

Constructor & Destructor Documentation

◆ XrdSysTrace()

XrdSysTrace::XrdSysTrace ( const char * pfx,
XrdSysLogger * logp = 0,
int tf = 0 )
inline

Definition at line 95 of file XrdSysTrace.hh.

96 : What(tf), logP(logp), iName(pfx), dPnt(0),
97 dFree(txtMax), vPnt(1), doFmt(Xrd::dec) {}

References What.

Referenced by Beg(), End(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), and operator<<().

+ Here is the caller graph for this function:

◆ ~XrdSysTrace()

XrdSysTrace::~XrdSysTrace ( )
inline

Definition at line 98 of file XrdSysTrace.hh.

98{}

Member Function Documentation

◆ Beg()

XrdSysTrace & XrdSysTrace::Beg ( const char * usr = 0,
const char * epn = 0,
const char * txt = 0 )

Definition at line 73 of file XrdSysTrace.cc.

76{
77 char fmt[16];
78 const char *fmt1, *fmt2, *fmt3;
79 int n;
80
81// Generate prefix format (way too complicated)
82//
83 if (usr) fmt1 = "%s ";
84 else {usr = "", fmt1 = "%s";}
85 if (epn) fmt2 = "%s_%s: ";
86 else {epn = ""; fmt2 = "%s%s: ";}
87 if (txt) fmt3 = "%s";
88 else {txt = ""; fmt3 = "";}
89 sprintf(fmt, "%s%s%s", fmt1, fmt2, fmt3);
90
91// Format the header
92//
93 myMutex.Lock();
94 n = snprintf(pBuff, sizeof(pBuff), fmt, usr, iName, epn, txt);
95 if (n >= (int)sizeof(pBuff)) n = sizeof(pBuff)-1;
96
97// Start the trace procedure
98//
99 ioVec[0].iov_base = 0; ioVec[0].iov_len = 0;
100 ioVec[1].iov_base = pBuff; ioVec[1].iov_len = n;
101
102// Reset ourselves
103//
104 dPnt = 0;
105 dFree = txtMax;
106 vPnt = 2;
107
108// All done
109//
110 return *this;
111}

References XrdSysTrace().

+ Here is the call graph for this function:

◆ End()

XrdSysTrace * XrdSysTrace::End ( )
inline

Definition at line 54 of file XrdSysTrace.hh.

54{return this;}

References XrdSysTrace().

+ Here is the call graph for this function:

◆ operator<<() [1/18]

XrdSysTrace & XrdSysTrace::operator<< ( bool val)

Definition at line 145 of file XrdSysTrace.cc.

146{
147
148// If we have enough space then format the value
149//
150 if (vPnt < iovMax)
151 {if (val)
152 {ioVec[vPnt] .iov_base = (char *)"True";
153 ioVec[vPnt++].iov_len = 4;
154 } else {
155 ioVec[vPnt] .iov_base = (char *)"False";
156 ioVec[vPnt++].iov_len = 5;
157 }
158 }
159 return *this;
160}

References XrdSysTrace().

+ Here is the call graph for this function:

◆ operator<<() [2/18]

XrdSysTrace & XrdSysTrace::operator<< ( char val)

Definition at line 166 of file XrdSysTrace.cc.

167{
168 static char hv[] = "0123456789abcdef";
169
170// If we have enough space then format the value
171//
172 if (vPnt < iovMax && dFree > 1)
173 {if (doFmt)
174 {if (doFmt & Xrd::hex)
175 {ioVec[vPnt].iov_base = (char *)(&dBuff[dPnt]);
176 if (doFmt & Xrd::hex)
177 {ioVec[vPnt++].iov_len = 2;
178 dBuff[dPnt++] = hv[(val >> 4) & 0x0f];
179 dBuff[dPnt++] = hv[ val & 0xf0];
180 dFree -= 2;
181 } else if (doFmt & Xrd::oct && dFree > 2) {
182 ioVec[vPnt++].iov_len = 3;
183 dBuff[dPnt+2] = hv[val & 0x07]; val >>= 3;
184 dBuff[dPnt+1] = hv[val & 0x07]; val >>= 3;
185 dBuff[dPnt+1] = hv[val & 0x03];
186 dPnt += 3;
187 dFree -= 3;
188 }
189 }
190 if (doFmt & doOne) doFmt = Xrd::dec;
191 } else {
192 ioVec[vPnt] .iov_base = (char *)(&dBuff[dPnt]);
193 ioVec[vPnt++].iov_len = 1;
194 dBuff[dPnt++] = val; dFree--;
195 }
196 }
197 return *this;
198}

References XrdSysTrace(), Xrd::dec, Xrd::hex, and Xrd::oct.

+ Here is the call graph for this function:

◆ operator<<() [3/18]

XrdSysTrace & XrdSysTrace::operator<< ( const char * val)

Definition at line 204 of file XrdSysTrace.cc.

205{
206
207// If we have enough space then format the value
208//
209 if (vPnt < iovMax)
210 {ioVec[vPnt] .iov_base = (char *)val;
211 ioVec[vPnt++].iov_len = strlen(val);
212 }
213 return *this;
214}

References XrdSysTrace().

+ Here is the call graph for this function:

◆ operator<<() [4/18]

XrdSysTrace & XrdSysTrace::operator<< ( const std::string & val)

Definition at line 220 of file XrdSysTrace.cc.

221{
222 return (*this << val.c_str());
223}

References XrdSysTrace().

+ Here is the call graph for this function:

◆ operator<<() [5/18]

XrdSysTrace & XrdSysTrace::operator<< ( double val)
inline

Definition at line 84 of file XrdSysTrace.hh.

85 {return Insert(static_cast<long double>(val));}

References XrdSysTrace().

+ Here is the call graph for this function:

◆ operator<<() [6/18]

XrdSysTrace & XrdSysTrace::operator<< ( float val)
inline

Definition at line 82 of file XrdSysTrace.hh.

83 {return Insert(static_cast<long double>(val));}

References XrdSysTrace().

+ Here is the call graph for this function:

◆ operator<<() [7/18]

XrdSysTrace & XrdSysTrace::operator<< ( int val)

Definition at line 252 of file XrdSysTrace.cc.

253{
254 static const int xSz = sizeof("-2147483648");
255
256// If we have enough space then format the value
257//
258 if (dFree >= xSz && vPnt < iovMax)
259 {const char *fmt = (doFmt ? (doFmt & Xrd::hex ? "%x" : "%o") : "%d");
260 int n = snprintf(&dBuff[dPnt], dFree, fmt, val);
261 if (n > dFree) dFree = 0;
262 else {ioVec[vPnt] .iov_base = &dBuff[dPnt];
263 ioVec[vPnt++].iov_len = n;
264 dPnt += n; dFree -= n;
265 }
266 }
267 if (doFmt & doOne) doFmt = Xrd::dec;
268 return *this;
269}

References XrdSysTrace(), Xrd::dec, and Xrd::hex.

+ Here is the call graph for this function:

◆ operator<<() [8/18]

XrdSysTrace & XrdSysTrace::operator<< ( long double val)
inline

Definition at line 86 of file XrdSysTrace.hh.

87 {return Insert(val);}

References XrdSysTrace().

+ Here is the call graph for this function:

◆ operator<<() [9/18]

XrdSysTrace & XrdSysTrace::operator<< ( long long val)

Definition at line 288 of file XrdSysTrace.cc.

289{
290 static const int xSz = sizeof("-9223372036854775808");
291
292// If we have enough space then format the value
293//
294 if (dFree >= xSz && vPnt < iovMax)
295 {const char *fmt = (doFmt ? (doFmt & Xrd::hex ? "%llx" : "%llo") : "%lld");
296 int n = snprintf(&dBuff[dPnt], dFree, fmt, val);
297 if (n > dFree) dFree = 0;
298 else {ioVec[vPnt] .iov_base = &dBuff[dPnt];
299 ioVec[vPnt++].iov_len = n;
300 dPnt += n; dFree -= n;
301 }
302 }
303 if (doFmt & doOne) doFmt = Xrd::dec;
304 return *this;
305}

References XrdSysTrace(), Xrd::dec, and Xrd::hex.

+ Here is the call graph for this function:

◆ operator<<() [10/18]

XrdSysTrace & XrdSysTrace::operator<< ( long val)

Definition at line 275 of file XrdSysTrace.cc.

276{
277
278// Fan out based on length of a long
279//
280 if (sizeof(long) > 4) return *this<<static_cast<long long>(val);
281 else return *this<<static_cast<int>(val);
282}

References XrdSysTrace().

+ Here is the call graph for this function:

◆ operator<<() [11/18]

XrdSysTrace & XrdSysTrace::operator<< ( short val)

Definition at line 229 of file XrdSysTrace.cc.

230{
231 static const int xSz = sizeof("-32768");
232
233// If we have enough space then format the value
234//
235 if (dFree >= xSz && vPnt < iovMax)
236 {const char *fmt = (doFmt ? (doFmt & Xrd::hex ? "%hx" : "%ho") : "%hd");
237 int n = snprintf(&dBuff[dPnt], dFree, fmt, val);
238 if (n > dFree) dFree = 0;
239 else {ioVec[vPnt] .iov_base = &dBuff[dPnt];
240 ioVec[vPnt++].iov_len = n;
241 dPnt += n; dFree -= n;
242 }
243 }
244 if (doFmt & doOne) doFmt = Xrd::dec;
245 return *this;
246}

References XrdSysTrace(), Xrd::dec, and Xrd::hex.

+ Here is the call graph for this function:

◆ operator<<() [12/18]

XrdSysTrace & XrdSysTrace::operator<< ( unsigned int val)

Definition at line 334 of file XrdSysTrace.cc.

335{
336 static const int xSz = sizeof("4294967295");
337
338// If we have enough space then format the value
339//
340 if (dFree >= xSz && vPnt < iovMax)
341 {const char *fmt = (doFmt ? (doFmt & Xrd::hex ? "%x" : "%o") : "%u");
342 int n = snprintf(&dBuff[dPnt], dFree, fmt, val);
343 if (n > dFree) dFree = 0;
344 else {ioVec[vPnt] .iov_base = &dBuff[dPnt];
345 ioVec[vPnt++].iov_len = n;
346 dPnt += n; dFree -= n;
347 }
348 }
349 if (doFmt & doOne) doFmt = Xrd::dec;
350 return *this;
351}

References XrdSysTrace(), Xrd::dec, and Xrd::hex.

+ Here is the call graph for this function:

◆ operator<<() [13/18]

XrdSysTrace & XrdSysTrace::operator<< ( unsigned long long val)

Definition at line 370 of file XrdSysTrace.cc.

371{
372 static const int xSz = sizeof("18446744073709551615");
373
374// If we have enough space then format the value
375//
376 if (dFree >= xSz && vPnt < iovMax)
377 {const char *fmt = (doFmt ? (doFmt & Xrd::hex ? "%llx" : "%llo") : "%llu");
378 int n = snprintf(&dBuff[dPnt], dFree, fmt, val);
379 if (n > dFree) dFree = 0;
380 else {ioVec[vPnt] .iov_base = &dBuff[dPnt];
381 ioVec[vPnt++].iov_len = n;
382 dPnt += n; dFree -= n;
383 }
384 }
385 if (doFmt & doOne) doFmt = Xrd::dec;
386 return *this;
387}

References XrdSysTrace(), Xrd::dec, and Xrd::hex.

+ Here is the call graph for this function:

◆ operator<<() [14/18]

XrdSysTrace & XrdSysTrace::operator<< ( unsigned long val)

Definition at line 357 of file XrdSysTrace.cc.

358{
359
360// Fan out based on length of a long
361//
362 if (sizeof(long) > 4) return *this<<static_cast<unsigned long long>(val);
363 else return *this<<static_cast<unsigned int>(val);
364}

References XrdSysTrace().

+ Here is the call graph for this function:

◆ operator<<() [15/18]

XrdSysTrace & XrdSysTrace::operator<< ( unsigned short val)

Definition at line 311 of file XrdSysTrace.cc.

312{
313 static const int xSz = sizeof("65535");
314
315// If we have enough space then format the value
316//
317 if (dFree >= xSz && vPnt < iovMax)
318 {const char *fmt = (doFmt ? (doFmt & Xrd::hex ? "%hx" : "%ho") : "%hu");
319 int n = snprintf(&dBuff[dPnt], dFree, fmt, val);
320 if (n > dFree) dFree = 0;
321 else {ioVec[vPnt] .iov_base = &dBuff[dPnt];
322 ioVec[vPnt++].iov_len = n;
323 dPnt += n; dFree -= n;
324 }
325 }
326 if (doFmt & doOne) doFmt = Xrd::dec;
327 return *this;
328}

References XrdSysTrace(), Xrd::dec, and Xrd::hex.

+ Here is the call graph for this function:

◆ operator<<() [16/18]

XrdSysTrace & XrdSysTrace::operator<< ( void * val)

Definition at line 393 of file XrdSysTrace.cc.

394{
395 static const int xSz = sizeof(void *)*2+1;
396
397// If we have enough space then format the value
398//
399 if (dFree >= xSz && vPnt < iovMax)
400 {int n = snprintf(&dBuff[dPnt], dFree, "%p", val);
401 if (n > dFree) dFree = 0;
402 else {ioVec[vPnt] .iov_base = &dBuff[dPnt];
403 ioVec[vPnt++].iov_len = n;
404 dPnt += n; dFree -= n;
405 }
406 }
407 return *this;
408}

References XrdSysTrace().

+ Here is the call graph for this function:

◆ operator<<() [17/18]

XrdSysTrace & XrdSysTrace::operator<< ( Xrd::Fmt val)
inline

Definition at line 91 of file XrdSysTrace.hh.

91{doFmt = val; return *this;}

References XrdSysTrace().

+ Here is the call graph for this function:

◆ operator<<() [18/18]

XrdSysTrace & XrdSysTrace::operator<< ( XrdSysTrace * stp)

Definition at line 117 of file XrdSysTrace.cc.

118{
119 (void)val;
120
121// Make sure an endline character appears
122//
123 if (vPnt >= iovMax) vPnt = iovMax-1;
124 ioVec[vPnt] .iov_base = (char *)"\n";
125 ioVec[vPnt++].iov_len = 1;
126
127// Output the line
128//
129 if (logP) logP->Put(vPnt, ioVec);
130 else if (msgCB) ToMsgCB(vPnt, ioVec);
131 else {static XrdSysLogger tLog(XrdSysFD_Dup(STDERR_FILENO), 0);
132 tLog.Put(vPnt, ioVec);
133 }
134
135// All done
136//
137 myMutex.UnLock();
138 return *this;
139}

References XrdSysTrace(), and XrdSysLogger::Put().

+ Here is the call graph for this function:

◆ SetLogger() [1/2]

void XrdSysTrace::SetLogger ( msgCB_t cbP)

Definition at line 67 of file XrdSysTrace.cc.

67{msgCB = cbP;}
XrdSsiLogger::MCB_t * msgCB

◆ SetLogger() [2/2]

void XrdSysTrace::SetLogger ( XrdSysLogger * logp)

Definition at line 65 of file XrdSysTrace.cc.

65{logP = logp;}

◆ Tracing()

bool XrdSysTrace::Tracing ( int mask)
inline

Definition at line 62 of file XrdSysTrace.hh.

62{return (mask & What) != 0;}

References What.

Member Data Documentation

◆ What

int XrdSysTrace::What

Definition at line 64 of file XrdSysTrace.hh.

Referenced by XrdSysTrace(), and Tracing().


The documentation for this class was generated from the following files: