Skip to content

Commit

Permalink
[Server] Add new logging plugin interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 committed May 24, 2016
1 parent c68aa51 commit 671b98b
Show file tree
Hide file tree
Showing 11 changed files with 1,018 additions and 33 deletions.
40 changes: 16 additions & 24 deletions src/Xrd/XrdConfig.cc
Expand Up @@ -60,6 +60,7 @@

#include "XrdOuc/XrdOuca2x.hh"
#include "XrdOuc/XrdOucEnv.hh"
#include "XrdOuc/XrdOucLogging.hh"
#include "XrdOuc/XrdOucSiteName.hh"
#include "XrdOuc/XrdOucStream.hh"
#include "XrdOuc/XrdOucUtils.hh"
Expand Down Expand Up @@ -215,19 +216,20 @@ int XrdConfig::Configure(int argc, char **argv)

int retc, NoGo = 0, clPort = -1, optbg = 0;
const char *temp;
char c, buff[512], *dfltProt, *libProt = 0, *logfn = 0;
char c, buff[512], *dfltProt, *libProt = 0;
uid_t myUid = 0;
gid_t myGid = 0;
extern char *optarg;
extern int optind, opterr;
struct XrdOucLogging::configLogInfo LogInfo;
int pipeFD[2] = {-1, -1};
const char *pidFN = 0;
static const int myMaxc = 80;
char **urArgv, *myArgv[myMaxc], argBuff[myMaxc*3+8];
char *argbP = argBuff, *argbE = argbP+sizeof(argBuff)-4;
char *ifList = 0;
int myArgc = 1, bindArg = 1, urArgc = argc, i;
bool noV6, ipV4 = false, ipV6 = false, pureLFN = false;
int myArgc = 1, urArgc = argc, i;
bool noV6, ipV4 = false, ipV6 = false;

// Obtain the protocol name we will be using
//
Expand Down Expand Up @@ -303,18 +305,12 @@ int XrdConfig::Configure(int argc, char **argv)
Usage(1);
}
break;
case 'k': if (!(bindArg = Log.logger()->ParseKeep(optarg)))
case 'k': if (!(LogInfo.keepV = Log.logger()->ParseKeep(optarg)))
{Log.Emsg("Config","Invalid -k argument -",optarg);
Usage(1);
}
break;
case 'l': if ((pureLFN = *optarg == '=')) optarg++;
if (!*optarg)
{Log.Emsg("Config", "Logfile name not specified.");
Usage(1);
}
if (logfn) free(logfn);
logfn = strdup(optarg);
case 'l': LogInfo.logArg = optarg;
break;
case 'L': if (!*optarg)
{Log.Emsg("Config", "Protocol library path not specified.");
Expand Down Expand Up @@ -343,7 +339,7 @@ int XrdConfig::Configure(int argc, char **argv)
case 'v': cerr <<XrdVSTRING <<endl;
_exit(0);
break;
case 'z': Log.logger()->setHiRes();
case 'z': LogInfo.hiRes = true;
break;

default: if (optopt == '-' && *(argv[optind]+1) == '-')
Expand Down Expand Up @@ -401,25 +397,22 @@ int XrdConfig::Configure(int argc, char **argv)
if (optbg)
{
#ifdef WIN32
XrdOucUtils::Undercover(&Log, !logfn);
XrdOucUtils::Undercover(&Log, !LogInfo.logArg);
#else
if (pipe( pipeFD ) == -1)
{Log.Emsg("Config", errno, "create a pipe"); exit(17);}
XrdOucUtils::Undercover(Log, !logfn, pipeFD);
XrdOucUtils::Undercover(Log, !LogInfo.logArg, pipeFD);
#endif
}

// Bind the log file if we have one
//
if (logfn)
{char *lP;
if (!pureLFN && !(logfn = XrdOucUtils::subLogfn(Log,myInsName,logfn)))
_exit(16);
if (LogInfo.logArg)
{LogInfo.xrdEnv = &theEnv;
LogInfo.iName = myInsName;
LogInfo.cfgFn = ConfigFN;
if (!XrdOucLogging::configLog(Log, LogInfo)) _exit(16);
Log.logger()->AddMsg(XrdBANNER);
if (Log.logger()->Bind(logfn, bindArg)) exit(19);
if ((lP = rindex(logfn,'/'))) {*(lP+1) = '\0'; lP = logfn;}
else lP = (char *)"./";
XrdOucEnv::Export("XRDLOGDIR", lP);
}

// Get the full host name. In theory, we should always get some kind of name.
Expand Down Expand Up @@ -545,12 +538,11 @@ int XrdConfig::Configure(int argc, char **argv)
temp = (NoGo ? " initialization failed." : " initialization completed.");
sprintf(buff, "%s:%d", myInstance, PortTCP);
Log.Say("------ ", buff, temp);
if (logfn)
if (LogInfo.logArg)
{strcat(buff, " running ");
retc = strlen(buff);
XrdSysUtils::FmtUname(buff+retc, sizeof(buff)-retc);
Log.logger()->AddMsg(buff);
free(logfn);
}
return NoGo;
}
Expand Down
1 change: 1 addition & 0 deletions src/XrdHeaders.cmake
Expand Up @@ -89,6 +89,7 @@ set( XROOTD_PUBLIC_HEADERS
XrdSys/XrdSysHeaders.hh
XrdSys/XrdSysLinuxSemaphore.hh
XrdSys/XrdSysLogger.hh
XrdSys/XrdSysLogPI.hh
XrdSys/XrdSysPlatform.hh
XrdSys/XrdSysPlugin.hh
XrdSys/XrdSysPthread.hh
Expand Down

0 comments on commit 671b98b

Please sign in to comment.