File indexing completed on 2026-01-08 10:33:34
0001 #ifndef __XRDSYSTRACE_HH__
0002 #define __XRDSYSTRACE_HH__
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 #include <iostream>
0034 #include <sys/uio.h>
0035
0036 class XrdSysLogger;
0037
0038 #include "XrdSys/XrdSysPthread.hh"
0039
0040 namespace Xrd
0041 {
0042 enum Fmt {dec=0, hex=2, hex1=3, oct=4, oct1=5};
0043 }
0044
0045 #define SYSTRACE(obj, usr, epn, txt, dbg) \
0046 obj Beg(usr, epn, txt) <<dbg <<obj End();
0047
0048 class XrdSysTrace
0049 {
0050 public:
0051
0052 XrdSysTrace& Beg(const char *usr=0, const char *epn=0, const char *txt=0);
0053
0054 XrdSysTrace *End() {return this;}
0055
0056 void SetLogger(XrdSysLogger *logp);
0057
0058 typedef void (*msgCB_t)(const char *tid, const char *msg, bool dbgmsg);
0059
0060 void SetLogger(msgCB_t cbP);
0061
0062 inline bool Tracing(int mask) {return (mask & What) != 0;}
0063
0064 int What;
0065
0066 XrdSysTrace& operator<<(bool val);
0067
0068 XrdSysTrace& operator<<( char val);
0069 XrdSysTrace& operator<<(const char *val);
0070 XrdSysTrace& operator<<(const std::string& val);
0071
0072 XrdSysTrace& operator<<(short val);
0073 XrdSysTrace& operator<<(int val);
0074 XrdSysTrace& operator<<(long val);
0075 XrdSysTrace& operator<<(long long val);
0076
0077 XrdSysTrace& operator<<(unsigned short val);
0078 XrdSysTrace& operator<<(unsigned int val);
0079 XrdSysTrace& operator<<(unsigned long val);
0080 XrdSysTrace& operator<<(unsigned long long val);
0081
0082 XrdSysTrace& operator<<(float val)
0083 {return Insert(static_cast<long double>(val));}
0084 XrdSysTrace& operator<<(double val)
0085 {return Insert(static_cast<long double>(val));}
0086 XrdSysTrace& operator<<(long double val)
0087 {return Insert(val);}
0088
0089 XrdSysTrace& operator<<(void* val);
0090
0091 XrdSysTrace& operator<<(Xrd::Fmt val) {doFmt = val; return *this;}
0092
0093 XrdSysTrace& operator<<(XrdSysTrace *stp);
0094
0095 XrdSysTrace(const char *pfx, XrdSysLogger *logp=0, int tf=0)
0096 : What(tf), logP(logp), iName(pfx), dPnt(0),
0097 dFree(txtMax), vPnt(1), doFmt(Xrd::dec) {}
0098 ~XrdSysTrace() {}
0099
0100 private:
0101
0102 XrdSysTrace& Insert(long double val);
0103
0104 static const int iovMax = 16;
0105 static const int pfxMax = 256;
0106 static const int txtMax = 256;
0107
0108 static const int doOne =0x01;
0109
0110 XrdSysMutex myMutex;
0111 XrdSysLogger *logP;
0112 const char *iName;
0113 short dPnt;
0114 short dFree;
0115 short vPnt;
0116 Xrd::Fmt doFmt;
0117 struct iovec ioVec[iovMax];
0118 char pBuff[pfxMax];
0119 char dBuff[txtMax];
0120 };
0121 #endif