xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdClient
XrdClientDebug.hh
Go to the documentation of this file.
1
2
// //
3
// XrdClientDebug //
4
// //
5
// Author: Fabrizio Furano (INFN Padova, 2004) //
6
// Adapted from TXNetFile (root.cern.ch) originally done by //
7
// Alvise Dorigo, Fabrizio Furano //
8
// INFN Padova, 2003 //
9
// //
10
// Singleton used to handle the debug level and the log output //
11
// //
13
14
// $Id$
15
16
#ifndef XRC_DEBUG_H
17
#define XRC_DEBUG_H
18
19
#include <sstream>
20
#include "
XrdClient/XrdClientConst.hh
"
21
#include "
XrdSys/XrdSysPthread.hh
"
22
#include "
XrdClient/XrdClientEnv.hh
"
23
#include "
XrdSys/XrdSysHeaders.hh
"
24
#include "
XrdSys/XrdSysLogger.hh
"
25
#include "
XrdSys/XrdSysError.hh
"
26
27
using namespace
std;
28
29
30
31
#define DebugLevel() XrdClientDebug::Instance()->GetDebugLevel()
32
#define DebugSetLevel(l) XrdClientDebug::Instance()->SetLevel(l)
33
34
#define Info(lvl, where, what) { \
35
XrdClientDebug::Instance()->Lock();\
36
if (XrdClientDebug::Instance()->GetDebugLevel() >= lvl) {\
37
ostringstream outs;\
38
outs << where << ": " << what; \
39
XrdClientDebug::Instance()->TraceStream((short)lvl, outs);\
40
}\
41
XrdClientDebug::Instance()->Unlock();\
42
}
43
44
#define Error(where, what) { \
45
ostringstream outs;\
46
outs << where << ": " << what; \
47
XrdClientDebug::Instance()->TraceStream((short)XrdClientDebug::kNODEBUG, outs);\
48
}
49
50
51
class
XrdClientDebug
{
52
private
:
53
short
fDbgLevel
;
54
55
XrdSysLogger
*
fOucLog
;
56
XrdSysError
*
fOucErr
;
57
58
static
XrdClientDebug
*
fgInstance
;
59
60
XrdSysRecMutex
fMutex
;
61
62
protected
:
63
XrdClientDebug
();
64
~
XrdClientDebug
();
65
66
public
:
67
68
enum
{
69
kNODEBUG = 0,
70
kUSERDEBUG = 1,
71
kHIDEBUG = 2,
72
kDUMPDEBUG = 3
73
};
74
75
short
GetDebugLevel
() {
76
XrdSysMutexHelper
m(fMutex);
77
return
fDbgLevel;
78
}
79
80
static
XrdClientDebug
*Instance();
81
82
inline
void
SetLevel
(
int
l) {
83
XrdSysMutexHelper
m(fMutex);
84
fDbgLevel = l;
85
}
86
87
inline
void
TraceStream
(
short
DbgLvl, ostringstream &s) {
88
XrdSysMutexHelper
m(fMutex);
89
90
if
(DbgLvl <= GetDebugLevel())
91
fOucErr->Emsg(
""
, s.str().c_str() );
92
93
s.str(
""
);
94
}
95
96
// ostringstream outs; // Declare an output string stream.
97
98
inline
void
TraceString
(
short
DbgLvl,
char
* s) {
99
XrdSysMutexHelper
m(fMutex);
100
if
(DbgLvl <= GetDebugLevel())
101
fOucErr->Emsg(
""
, s);
102
}
103
104
inline
void
Lock
() { fMutex.Lock(); }
105
inline
void
Unlock
() { fMutex.UnLock(); }
106
107
};
108
109
#endif
Generated by
1.8.1.2