34 #include <sys/types.h>
37 #include "XrdVersion.hh"
65 void ConfigLog(
const char *cFN)
69 char eBuff[2048], *var, *val, **lDest, *logPath = 0, *svcPath = 0;
73 XrdOucStream cStrm(0, getenv(
"XRDINSTANCE"), &myEnv,
"=====> ");
74 int cfgFD, retc, NoGo = 0;
78 if ((cfgFD =
open(cFN, O_RDONLY, 0)) < 0)
79 {std::cerr <<
"Config " <<
XrdSysE2T(errno) <<
" opening " <<cFN <<std::endl;
83 static const char *cvec[] = {
"*** ssi logging plugin config:", 0 };
88 while((var = cStrm.GetMyFirstWord()))
89 {
if (!strcmp(var,
"ssi.loglib")) {lDest = &logPath; lName =
"log";}
90 else if (!strcmp(var,
"ssi.svclib")) {lDest = &svcPath; lName =
"svc";}
92 if (!(val = cStrm.GetWord()) || !val[0])
93 {std::cerr <<
"Config "<<lName<<
"lib path not specified."<<std::endl; NoGo=1;}
94 else {
if (*lDest) free(*lDest);
101 if ((retc = cStrm.LastError()))
102 {std::cerr <<
"Config " <<
XrdSysE2T(-retc) <<
" reading " <<cFN <<std::endl;
109 if (!logPath) {logPath = svcPath; svcPath = 0; lName =
"svclib";}
110 else lName =
"loglib";
114 if (!NoGo && !logPath)
115 {std::cerr <<
"Config neither ssi.loglib nor ssi.svclib directive specified in "
122 if (!(myLib =
new XrdSysPlugin(eBuff,
sizeof(eBuff), logPath, lName,
124 {std::cerr <<
"Config " <<eBuff <<std::endl;
133 if (!
msgCB && !theCB) std::cerr <<
"Config " <<eBuff <<std::endl;
153 {
if (cfgfn && *cfgfn) ConfigLog(cfgfn);
155 std::cerr <<
"Config '-l@' requires a logmsg callback function "
156 <<
"but it was found!" <<std::endl;
int open(const char *path, int oflag,...)
XrdVERSIONINFO(XrdSysLogPInit, XrdSsiLPI)
XrdSysLogPI_t XrdSysLogPInit(const char *cfgfn, char **argv, int argc)
const char * XrdSysE2T(int errcode)
void(* XrdSysLogPI_t)(struct timeval const &mtime, unsigned long tID, const char *msg, int mlen)
void() MCB_t(struct timeval const &mtime, unsigned long tID, const char *msg, int mlen)
Length of message text.
void * getPlugin(const char *pname, int optional=0)
XrdVERSIONINFODEF(myVersion, cmsclient, XrdVNUMBER, XrdVERSION)
XrdSsiLogger::MCB_t * msgCB