xrootd
Loading...
Searching...
No Matches
XrdSysTrace.hh
Go to the documentation of this file.
1#ifndef __XRDSYSTRACE_HH__
2#define __XRDSYSTRACE_HH__
3/******************************************************************************/
4/* */
5/* X r d S y s T r a c e . h h */
6/* */
7/* (c) 2016 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* All Rights Reserved */
9/* Produced by Andrew Hanushevsky for Stanford University under contract */
10/* DE-AC02-76-SFO0515 with the Department of Energy */
11/* */
12/* This file is part of the XRootD software suite. */
13/* */
14/* XRootD is free software: you can redistribute it and/or modify it under */
15/* the terms of the GNU Lesser General Public License as published by the */
16/* Free Software Foundation, either version 3 of the License, or (at your */
17/* option) any later version. */
18/* */
19/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22/* License for more details. */
23/* */
24/* You should have received a copy of the GNU Lesser General Public License */
25/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27/* */
28/* The copyright holder's institutional names and contributor's names may not */
29/* be used to endorse or promote products derived from this software without */
30/* specific prior written permission of the institution or contributor. */
31/******************************************************************************/
32
33#include <iostream>
34#include <sys/uio.h>
35
36class XrdSysLogger;
37
39
40namespace Xrd
41{
42enum Fmt {dec=0, hex=2, hex1=3, oct=4, oct1=5};
43}
44
45#define SYSTRACE(obj, usr, epn, txt, dbg) \
46 obj Beg(usr, epn, txt) <<dbg <<obj End();
47
49{
50public:
51
52XrdSysTrace& Beg(const char *usr=0, const char *epn=0, const char *txt=0);
53
54XrdSysTrace *End() {return this;}
55
57
58typedef void (*msgCB_t)(const char *tid, const char *msg, bool dbgmsg);
59
61
62inline bool Tracing(int mask) {return (mask & What) != 0;}
63
64 int What;
65
67
69XrdSysTrace& operator<<(const char *val);
70 XrdSysTrace& operator<<(const std::string& val);
71
75XrdSysTrace& operator<<(long long val);
76
77XrdSysTrace& operator<<(unsigned short val);
78XrdSysTrace& operator<<(unsigned int val);
79XrdSysTrace& operator<<(unsigned long val);
80XrdSysTrace& operator<<(unsigned long long val);
81
83 {return Insert(static_cast<long double>(val));}
85 {return Insert(static_cast<long double>(val));}
86XrdSysTrace& operator<<(long double val)
87 {return Insert(val);}
88
90
91XrdSysTrace& operator<<(Xrd::Fmt val) {doFmt = val; return *this;}
92
94
95 XrdSysTrace(const char *pfx, XrdSysLogger *logp=0, int tf=0)
96 : What(tf), logP(logp), iName(pfx), dPnt(0),
97 dFree(txtMax), vPnt(1), doFmt(Xrd::dec) {}
99
100private:
101
102XrdSysTrace& Insert(long double val);
103
104static const int iovMax = 16;
105static const int pfxMax = 256;
106static const int txtMax = 256;
107
108static const int doOne =0x01;
109
112const char *iName;
113short dPnt;
114short dFree;
115short vPnt;
117struct iovec ioVec[iovMax];
120};
121#endif
Definition XrdSysLogger.hh:53
Definition XrdSysPthread.hh:165
Definition XrdSysTrace.hh:49
XrdSysTrace(const char *pfx, XrdSysLogger *logp=0, int tf=0)
Definition XrdSysTrace.hh:95
Xrd::Fmt doFmt
Definition XrdSysTrace.hh:116
XrdSysTrace & operator<<(float val)
Definition XrdSysTrace.hh:82
const char * iName
Definition XrdSysTrace.hh:112
XrdSysTrace & operator<<(long val)
XrdSysTrace * End()
Definition XrdSysTrace.hh:54
XrdSysTrace & operator<<(unsigned int val)
XrdSysTrace & Beg(const char *usr=0, const char *epn=0, const char *txt=0)
XrdSysTrace & operator<<(unsigned long val)
XrdSysTrace & operator<<(long long val)
XrdSysTrace & operator<<(void *val)
static const int pfxMax
Definition XrdSysTrace.hh:105
XrdSysTrace & operator<<(Xrd::Fmt val)
Definition XrdSysTrace.hh:91
XrdSysTrace & Insert(long double val)
short vPnt
Definition XrdSysTrace.hh:115
XrdSysTrace & operator<<(unsigned long long val)
short dFree
Definition XrdSysTrace.hh:114
int What
Definition XrdSysTrace.hh:64
XrdSysTrace & operator<<(const std::string &val)
void(* msgCB_t)(const char *tid, const char *msg, bool dbgmsg)
Definition XrdSysTrace.hh:58
XrdSysTrace & operator<<(char val)
void SetLogger(msgCB_t cbP)
char pBuff[pfxMax]
Definition XrdSysTrace.hh:118
XrdSysMutex myMutex
Definition XrdSysTrace.hh:110
XrdSysTrace & operator<<(XrdSysTrace *stp)
XrdSysTrace & operator<<(bool val)
~XrdSysTrace()
Definition XrdSysTrace.hh:98
static const int doOne
Definition XrdSysTrace.hh:108
char dBuff[txtMax]
Definition XrdSysTrace.hh:119
XrdSysTrace & operator<<(const char *val)
XrdSysTrace & operator<<(short val)
short dPnt
Definition XrdSysTrace.hh:113
XrdSysTrace & operator<<(int val)
struct iovec ioVec[iovMax]
Definition XrdSysTrace.hh:117
XrdSysLogger * logP
Definition XrdSysTrace.hh:111
static const int txtMax
Definition XrdSysTrace.hh:106
void SetLogger(XrdSysLogger *logp)
bool Tracing(int mask)
Definition XrdSysTrace.hh:62
static const int iovMax
Definition XrdSysTrace.hh:104
XrdSysTrace & operator<<(unsigned short val)
XrdSysTrace & operator<<(double val)
Definition XrdSysTrace.hh:84
XrdSysTrace & operator<<(long double val)
Definition XrdSysTrace.hh:86
Definition XrdSysTrace.hh:41
Fmt
Definition XrdSysTrace.hh:42
@ oct
Definition XrdSysTrace.hh:42
@ dec
Definition XrdSysTrace.hh:42
@ hex1
Definition XrdSysTrace.hh:42
@ oct1
Definition XrdSysTrace.hh:42
@ hex
Definition XrdSysTrace.hh:42