Skip to content

Commit

Permalink
Parse trace level.
Browse files Browse the repository at this point in the history
  • Loading branch information
alja committed May 27, 2016
1 parent 660d82d commit 8969ab3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/XrdFileCache/XrdFileCache.hh
Expand Up @@ -197,6 +197,7 @@ namespace XrdFileCache
bool ConfigParameters(std::string, XrdOucStream&);
bool ConfigXeq(char *, XrdOucStream &);
bool xdlib(XrdOucStream &);
bool xtrace(XrdOucStream &);
static Cache *m_factory; //!< this object

XrdSysError m_log; //!< XrdFileCache namespace logger
Expand Down
42 changes: 41 additions & 1 deletion src/XrdFileCache/XrdFileCacheConfiguration.cc
@@ -1,4 +1,5 @@
#include "XrdFileCache.hh"
#include "XrdFileCacheTrace.hh"

#include "XrdOss/XrdOss.hh"
#include "XrdOss/XrdOssCache.hh"
Expand Down Expand Up @@ -65,6 +66,37 @@ bool Cache::xdlib(XrdOucStream &Config)
return true;
}

/* Function: xtrace
Purpose: To parse the directive: trace <level>
Output: true upon success or false upon failure.
*/
bool Cache::xtrace(XrdOucStream &Config)
{
char *val;
static struct traceopts {const char *opname; int opval;} tropts[] =
{
{"none", 0},
{"error", 1},
{"warning", 2},
{"info", 3},
{"debug", 4},
{"dump", 5}
};
int numopts = sizeof(tropts)/sizeof(struct traceopts);

if (!(val = Config.GetWord()))
{m_log.Emsg("Config", "trace option not specified"); return 1;}

for (int i = 0; i < numopts; i++)
{
if (!strcmp(val, tropts[i].opname))
m_trace->What = tropts[i].opval;
return true;
}
return 0;
}

//______________________________________________________________________________

bool Cache::Config(XrdSysLogger *logger, const char *config_filename, const char *parameters)
Expand Down Expand Up @@ -123,7 +155,11 @@ bool Cache::Config(XrdSysLogger *logger, const char *config_filename, const char
}
else if (!strcmp(var,"pfc.decisionlib"))
{
xdlib(Config);
retval = xdlib(Config);
}
else if (!strcmp(var,"pfc.trace"))
{
retval = xtrace(Config);
}
else if (!strncmp(var,"pfc.", 4))
{
Expand Down Expand Up @@ -159,6 +195,10 @@ bool Cache::Config(XrdSysLogger *logger, const char *config_filename, const char
}
m_configuration.m_NRamBuffers = static_cast<int>(m_configuration.m_RamAbsAvailable/ m_configuration.m_bufferSize);

// Set tracing to debug if this is set in environment
char* cenv = getenv("XRDDEBUG");
if (cenv && !strcmp(cenv,"1")) m_trace->What = 4;

if (retval)
{
int loff = 0;
Expand Down

0 comments on commit 8969ab3

Please sign in to comment.