33 #include <sys/types.h>
37 #include "XrdVersion.hh"
75 virtual void Write(
const std::string &msg);
84 void LogMCB::Write(
const std::string &msg)
87 const char *brak, *cBeg, *cMsg = msg.c_str();
89 int cLen = msg.size();
93 gettimeofday(&tNow, 0);
98 for (
int i = 0; i < 4; i++)
99 {
if (*cMsg !=
'[' || !(brak = index(cMsg,
']')))
break;
105 while(*cMsg ==
' ') cMsg++;
109 cLen = cLen - (cMsg - cBeg);
110 if (cLen < 0) cLen = strlen(cMsg);
111 mcbP(tNow, tID, cMsg, cLen);
120 const char *txt2,
const char *txt3)
125 if (pfx)
Log.
Emsg(pfx, txt1, txt2, txt3);
126 else {
const char *tout[6] = {txt1, 0};
128 if (txt2) {tout[i++] =
" "; tout[i++] = txt2;}
129 if (txt3) {tout[i++] =
" "; tout[i++] = txt3;}
131 Log.
Say(tout[0], tout[1], tout[2], tout[3], tout[4], tout[5]);
143 va_start (args, fmt);
147 vsnprintf(buffer,
sizeof(buffer), fmt, args);
151 if (pfx)
Log.
Emsg(pfx, buffer);
165 vsnprintf(buffer,
sizeof(buffer), fmt, aP);
169 if (pfx)
Log.
Emsg(pfx, buffer);
189 if (mcbt == mcbAll || mcbt == mcbServer)
msgCB = mcbP;
194 if (mcbt == mcbAll || mcbt == mcbClient)
196 if (!logP)
return false;
218 std::cerr <<std::endl;
static Log * GetLog()
Get default log.
Interface for logger outputs.
void SetOutput(LogOut *output)
Set the output that should be used.
void() MCB_t(struct timeval const &mtime, unsigned long tID, const char *msg, int mlen)
Length of message text.
static bool SetMCB(MCB_t &mcbP, mcbType mcbt=mcbAll)
static void Msgf(const char *pfx, const char *fmt,...)
static void Msg(const char *pfx, const char *txt1, const char *txt2=0, const char *txt3=0)
static const char * TBeg()
static void Msgv(const char *pfx, const char *fmt, va_list aP)
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)
void Put(int iovcnt, struct iovec *iov)
static unsigned long Num(void)
XrdSsiLogger::MCB_t * msgCB
XrdSsiLogger::MCB_t * msgCBCl