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

#include <XrdSsiLogger.hh>

+ Collaboration diagram for XrdSsiLogger:

Public Types

typedef void MCB_t(struct timeval const &mtime, unsigned long tID, const char *msg, int mlen)
 Length of message text.
 
enum  mcbType {
  mcbAll =0 ,
  mcbClient ,
  mcbServer
}
 

Public Member Functions

 XrdSsiLogger ()
 Constructor and destructor.
 
 ~XrdSsiLogger ()
 

Static Public Member Functions

static void Msg (const char *pfx, const char *txt1, const char *txt2=0, const char *txt3=0)
 
static void Msgf (const char *pfx, const char *fmt,...)
 
static void Msgv (const char *pfx, const char *fmt, va_list aP)
 
static void Msgv (struct iovec *iovP, int iovN)
 
static bool SetMCB (MCB_t &mcbP, mcbType mcbt=mcbAll)
 
static const char * TBeg ()
 
static void TEnd ()
 

Detailed Description

Definition at line 40 of file XrdSsiLogger.hh.

Member Typedef Documentation

◆ MCB_t

void XrdSsiLogger::MCB_t(struct timeval const &mtime, unsigned long tID, const char *msg, int mlen)

Length of message text.

Set a message callback function for messages issued via this object. This method should be called during static initialization (this means the call needs to occur at global scope).

Parameters
mCBReference to the message callback function as defined by the typedef MCB_t.
mcbtSpecifies the type of callback being set, as follows: mcbAll - callback for client-side and server-side logging. mcbClient - Callback for client-side logging. mcbServer - Callback for server-side logging.
Returns
bool A value of true indicates success, otherwise false returned. The return value can generally be ignored and is provided as a means to call this method via dynamic global initialization.

Definition at line 111 of file XrdSsiLogger.hh.

Member Enumeration Documentation

◆ mcbType

Enumerator
mcbAll 
mcbClient 
mcbServer 

Definition at line 116 of file XrdSsiLogger.hh.

Constructor & Destructor Documentation

◆ XrdSsiLogger()

XrdSsiLogger::XrdSsiLogger ( )
inline

Constructor and destructor.

Definition at line 137 of file XrdSsiLogger.hh.

137{}

◆ ~XrdSsiLogger()

XrdSsiLogger::~XrdSsiLogger ( )
inline

Definition at line 138 of file XrdSsiLogger.hh.

138{}

Member Function Documentation

◆ Msg()

void XrdSsiLogger::Msg ( const char * pfx,
const char * txt1,
const char * txt2 = 0,
const char * txt3 = 0 )
static

Insert a space delimited error message into the log file.

Parameters
pfx!0 -> the text to prefix the message; the message is formed as <timestamp> pfx: txt1 [txt2] [txt3]
pfx =0 -> add message to the log without a time stamp or prefix.
txt1,txt2,txt3the message to be added to the log.

Definition at line 119 of file XrdSsiLogger.cc.

121{
122
123// Route the message appropriately
124//
125 if (pfx) Log.Emsg(pfx, txt1, txt2, txt3);
126 else {const char *tout[6] = {txt1, 0};
127 int i = 1;
128 if (txt2) {tout[i++] = " "; tout[i++] = txt2;}
129 if (txt3) {tout[i++] = " "; tout[i++] = txt3;}
130 tout[i] = txt3;
131 Log.Say(tout[0], tout[1], tout[2], tout[3], tout[4], tout[5]);
132 }
133}
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)
XrdSysError Log

References XrdSysError::Emsg(), XrdSsi::Log, and XrdSysError::Say().

+ Here is the call graph for this function:

◆ Msgf()

void XrdSsiLogger::Msgf ( const char * pfx,
const char * fmt,
... )
static

Insert a formated error message into the log file using variable args.

Parameters
pfx!0 -> the text to prefix the message; the message is formed as <timestamp> <pfx>: <formated_text>
pfx =0 -> add message to the log without a time stamp or prefix.
fmtthe message formatting template (i.e. sprintf format). Note that a newline character is always appended to the message.
...the arguments that should be used with the template. The formatted message is truncated at 2048 bytes.

Definition at line 139 of file XrdSsiLogger.cc.

140{
141 char buffer[2048];
142 va_list args;
143 va_start (args, fmt);
144
145// Format the message
146//
147 vsnprintf(buffer, sizeof(buffer), fmt, args);
148
149// Route it
150//
151 if (pfx) Log.Emsg(pfx, buffer);
152 else Log.Say(buffer);
153}

References XrdSysError::Emsg(), XrdSsi::Log, and XrdSysError::Say().

+ Here is the call graph for this function:

◆ Msgv() [1/2]

void XrdSsiLogger::Msgv ( const char * pfx,
const char * fmt,
va_list aP )
static

Insert a formated error message into the log file using a va_list.

Parameters
pfx!0 -> the text to prefix the message; the message is formed as <timestamp> <pfx>: <formated_text>
pfx =0 -> add message to the log without a time stamp or prefix.
fmtthe message formatting template (i.e. sprintf format). Note that a newline character is always appended to the message.
aPthe arguments that should be used with the template. The formatted message is truncated at 2048 bytes.

Definition at line 159 of file XrdSsiLogger.cc.

160{
161 char buffer[2048];
162
163// Format the message
164//
165 vsnprintf(buffer, sizeof(buffer), fmt, aP);
166
167// Route it
168//
169 if (pfx) Log.Emsg(pfx, buffer);
170 else Log.Say(buffer);
171}

References XrdSysError::Emsg(), XrdSsi::Log, and XrdSysError::Say().

+ Here is the call graph for this function:

◆ Msgv() [2/2]

void XrdSsiLogger::Msgv ( struct iovec * iovP,
int iovN )
static

Insert a formated error message into the log file using a iovec.

Parameters
iovPpointer to an iovec that contains the message. that a newline character is always appended to the message.
iovNthe number of elements in the iovec.

Definition at line 175 of file XrdSsiLogger.cc.

176{
177 Logger->Put(iovN, iovP);
178}
static XrdSysLogger Logger
void Put(int iovcnt, struct iovec *iov)

References Logger, and XrdSysLogger::Put().

+ Here is the call graph for this function:

◆ SetMCB()

bool XrdSsiLogger::SetMCB ( XrdSsiLogger::MCB_t & mcbP,
XrdSsiLogger::mcbType mcbt = mcbAll )
static

Definition at line 184 of file XrdSsiLogger.cc.

186{
187// Record the callback, this may be on the server or the client
188//
189 if (mcbt == mcbAll || mcbt == mcbServer) msgCB = mcbP;
190
191// If setting the clientside, get the client logging object and set a new
192// logging intercept object that will route the messages here.
193//
194 if (mcbt == mcbAll || mcbt == mcbClient)
196 if (!logP) return false;
197 logP->SetOutput(new LogMCB(&mcbP));
198 msgCBCl = mcbP;
199 }
200
201// All done
202//
203 return true;
204}
static Log * GetLog()
Get default log.
Handle diagnostics.
Definition XrdClLog.hh:101
void SetOutput(LogOut *output)
Set the output that should be used.
Definition XrdClLog.hh:215
XrdSsiLogger::MCB_t * msgCB
XrdSsiLogger::MCB_t * msgCBCl

References XrdCl::DefaultEnv::GetLog(), XrdSsi::msgCB, XrdSsi::msgCBCl, and XrdCl::Log::SetOutput().

+ Here is the call graph for this function:

◆ TBeg()

const char * XrdSsiLogger::TBeg ( )
static

Definition at line 210 of file XrdSsiLogger.cc.

210{return Logger->traceBeg();}
char * traceBeg()

References Logger, and XrdSysLogger::traceBeg().

+ Here is the call graph for this function:

◆ TEnd()

void XrdSsiLogger::TEnd ( )
static

Definition at line 216 of file XrdSsiLogger.cc.

217{
218 std::cerr <<std::endl;
219 Logger->traceEnd();
220}

References Logger, and XrdSysLogger::traceEnd().

+ Here is the call graph for this function:

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