Skip to content

Commit

Permalink
Merge pull request #531 from alja/loggSys
Browse files Browse the repository at this point in the history
pfc: Use XrdSyTrace for logging
  • Loading branch information
abh3 committed Jun 21, 2017
2 parents eb65f02 + 5e04082 commit 7e4f1e8
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/XrdFileCache/XrdFileCache.cc
Expand Up @@ -28,7 +28,7 @@
#include "XrdOss/XrdOss.hh"
#include "XrdOuc/XrdOucEnv.hh"
#include "XrdOuc/XrdOucUtils.hh"
#include "XrdOuc/XrdOucTrace.hh"
#include "XrdSys/XrdSysTrace.hh"

#include "XrdFileCache.hh"
#include "XrdFileCacheTrace.hh"
Expand Down Expand Up @@ -150,7 +150,7 @@ Cache::Cache() : XrdOucCache(),
m_RAMblocks_used(0),
m_isClient(false)
{
m_trace = new XrdOucTrace(&m_log);
m_trace = new XrdSysTrace("XrdFileCache");
// default log level is Warning
m_trace->What = 2;
}
Expand Down
9 changes: 3 additions & 6 deletions src/XrdFileCache/XrdFileCache.hh
Expand Up @@ -31,7 +31,7 @@

class XrdOucStream;
class XrdSysError;
class XrdOucTrace;
class XrdSysTrace;

namespace XrdCl {
class Log;
Expand Down Expand Up @@ -197,11 +197,8 @@ public:

void Prefetch();


XrdOss* GetOss() const { return m_output_fs; }

XrdSysError& GetSysError() { return m_log; }

bool HaveActiveFileWithLocalPath(std::string);

File* GetFile(const std::string&, IO*, long long off = 0, long long filesize = 0);
Expand All @@ -212,7 +209,7 @@ public:

void FileSyncDone(File*);

XrdOucTrace* GetTrace() { return m_trace; }
XrdSysTrace* GetTrace() { return m_trace; }

private:
bool ConfigParameters(std::string, XrdOucStream&, TmpConfiguration &tmpc);
Expand All @@ -225,7 +222,7 @@ private:
XrdScheduler *schedP;

XrdSysError m_log; //!< XrdFileCache namespace logger
XrdOucTrace *m_trace;
XrdSysTrace *m_trace;
const char *m_traceID;

XrdOucCacheStats m_stats; //!<
Expand Down
2 changes: 1 addition & 1 deletion src/XrdFileCache/XrdFileCacheFile.cc
Expand Up @@ -939,7 +939,7 @@ float File::GetPrefetchScore() const
return m_prefetchScore;
}

XrdOucTrace* File::GetTrace()
XrdSysTrace* File::GetTrace()
{
return Cache::GetInstance().GetTrace();
}
Expand Down
4 changes: 2 additions & 2 deletions src/XrdFileCache/XrdFileCacheFile.hh
Expand Up @@ -187,9 +187,9 @@ public:
//! Log path
const char* lPath() const;

std::string GetLocalPath() { return m_filename; }
std::string& GetLocalPath() { return m_filename; }

XrdOucTrace* GetTrace();
XrdSysTrace* GetTrace();

long long GetFileSize() { return m_fileSize; }

Expand Down
4 changes: 2 additions & 2 deletions src/XrdFileCache/XrdFileCacheIO.hh
@@ -1,7 +1,7 @@
#ifndef __XRDFILECACHE_CACHE_IO_HH__
#define __XRDFILECACHE_CACHE_IO_HH__

class XrdOucTrace;
class XrdSysTrace;

#include "XrdFileCache.hh"
#include "XrdOuc/XrdOucCache2.hh"
Expand Down Expand Up @@ -41,7 +41,7 @@ public:

virtual void RelinquishFile(File*) = 0;

XrdOucTrace* GetTrace() { return m_cache.GetTrace(); }
XrdSysTrace* GetTrace() { return m_cache.GetTrace(); }

XrdOucCacheIO2* GetInput();

Expand Down
10 changes: 5 additions & 5 deletions src/XrdFileCache/XrdFileCacheInfo.cc
Expand Up @@ -26,7 +26,7 @@
#include "XrdOss/XrdOss.hh"
#include "XrdCks/XrdCksCalcmd5.hh"
#include "XrdOuc/XrdOucSxeq.hh"
#include "XrdOuc/XrdOucTrace.hh"
#include "XrdSys/XrdSysTrace.hh"
#include "XrdCl/XrdClLog.hh"
#include "XrdCl/XrdClConstants.hh"
#include "XrdFileCacheInfo.hh"
Expand All @@ -40,14 +40,14 @@ struct FpHelper
{
XrdOssDF *f_fp;
off_t f_off;
XrdOucTrace *f_trace;
XrdSysTrace *f_trace;
const char *m_traceID;
std::string f_ttext;

XrdOucTrace* GetTrace() const { return f_trace; }
XrdSysTrace* GetTrace() const { return f_trace; }

FpHelper(XrdOssDF* fp, off_t off,
XrdOucTrace *trace, const char *tid, const std::string &ttext) :
XrdSysTrace *trace, const char *tid, const std::string &ttext) :
f_fp(fp), f_off(off),
f_trace(trace), m_traceID(tid), f_ttext(ttext)
{}
Expand Down Expand Up @@ -104,7 +104,7 @@ const size_t Info::m_maxNumAccess = 20;

//------------------------------------------------------------------------------

Info::Info(XrdOucTrace* trace, bool prefetchBuffer) :
Info::Info(XrdSysTrace* trace, bool prefetchBuffer) :
m_trace(trace),
m_hasPrefetchBuffer(prefetchBuffer),
m_buff_written(0), m_buff_prefetch(0),
Expand Down
8 changes: 4 additions & 4 deletions src/XrdFileCache/XrdFileCacheInfo.hh
Expand Up @@ -29,7 +29,7 @@

class XrdOssDF;
class XrdCksCalc;
class XrdOucTrace;
class XrdSysTrace;


namespace XrdCl
Expand Down Expand Up @@ -77,7 +77,7 @@ public:
//------------------------------------------------------------------------
//! Constructor.
//------------------------------------------------------------------------
Info(XrdOucTrace* trace, bool prefetchBuffer = false);
Info(XrdSysTrace* trace, bool prefetchBuffer = false);

//------------------------------------------------------------------------
//! Destructor.
Expand Down Expand Up @@ -230,12 +230,12 @@ public:
const static int m_defaultVersion;
const static size_t m_maxNumAccess;

XrdOucTrace* GetTrace() const {return m_trace; }
XrdSysTrace* GetTrace() const {return m_trace; }

static size_t GetMaxNumAccess() { return m_maxNumAccess; }

protected:
XrdOucTrace* m_trace;
XrdSysTrace* m_trace;

Store m_store;
bool m_hasPrefetchBuffer; //!< constains current prefetch score
Expand Down
6 changes: 2 additions & 4 deletions src/XrdFileCache/XrdFileCachePrint.cc
Expand Up @@ -23,7 +23,7 @@
#include "XrdOuc/XrdOucEnv.hh"
#include "XrdOuc/XrdOucStream.hh"
#include "XrdOuc/XrdOucArgs.hh"
#include "XrdOuc/XrdOucTrace.hh"
#include "XrdSys/XrdSysTrace.hh"
#include "XrdOfs/XrdOfsConfigPI.hh"
#include "XrdSys/XrdSysLogger.hh"
#include "XrdFileCacheInfo.hh"
Expand Down Expand Up @@ -64,9 +64,7 @@ void Print::printFile(const std::string& path)
XrdOssDF* fh = m_oss->newFile(m_ossUser);
fh->Open((path).c_str(),O_RDONLY, 0600, m_env);

XrdSysLogger log;
XrdSysError err(&log);
XrdOucTrace tr(&err); tr.What = 2;
XrdSysTrace tr(""); tr.What = 2;
Info cfi(&tr);

if ( ! cfi.Read(fh, path))
Expand Down
4 changes: 2 additions & 2 deletions src/XrdFileCache/XrdFileCachePurge.cc
Expand Up @@ -5,7 +5,7 @@ using namespace XrdFileCache;

#include <fcntl.h>
#include "XrdOuc/XrdOucEnv.hh"
#include "XrdOuc/XrdOucTrace.hh"
#include "XrdSys/XrdSysTrace.hh"

namespace
{
Expand Down Expand Up @@ -49,7 +49,7 @@ class FPurgeState
long long nByteAccum;
};

XrdOucTrace* GetTrace()
XrdSysTrace* GetTrace()
{
// needed for logging macros
return Cache::GetInstance().GetTrace();
Expand Down
13 changes: 8 additions & 5 deletions src/XrdFileCache/XrdFileCacheTrace.hh
Expand Up @@ -21,27 +21,30 @@
#ifndef NODEBUG

#include "XrdSys/XrdSysHeaders.hh"
#include "XrdOuc/XrdOucTrace.hh"
#include "XrdSys/XrdSysTrace.hh"

#ifndef XRD_TRACE
#define XRD_TRACE GetTrace()->
#endif

#define TRACE(act, x) \
if (XRD_TRACE What >= TRACE_ ## act) \
{XRD_TRACE Beg(m_traceID); cerr << TRACE_STR_ ## act <<x; XRD_TRACE End(); }
{XRD_TRACE Beg(0, m_traceID) << TRACE_STR_ ## act << x; XRD_TRACE End(); }

#define TRACE_TEST(act, x) \
XRD_TRACE Beg("", m_traceID) << TRACE_STR_ ## act << x; XRD_TRACE End();

#define TRACE_PC(act, pre_code, x) \
if (XRD_TRACE What >= TRACE_ ## act) \
{pre_code; XRD_TRACE Beg(m_traceID); cerr << TRACE_STR_ ## act <<x; XRD_TRACE End(); }
{pre_code; XRD_TRACE Beg(0, m_traceID) << TRACE_STR_ ## act <<x; XRD_TRACE End(); }

#define TRACEIO(act, x) \
if (XRD_TRACE What >= TRACE_ ## act) \
{XRD_TRACE Beg(m_traceID); cerr << TRACE_STR_ ## act <<x << " " << GetPath(); XRD_TRACE End(); }
{XRD_TRACE Beg(0, m_traceID) << TRACE_STR_ ## act <<x << " " << GetPath(); XRD_TRACE End(); }

#define TRACEF(act, x) \
if (XRD_TRACE What >= TRACE_ ## act) \
{XRD_TRACE Beg(m_traceID); cerr << TRACE_STR_ ## act << x << " " << GetLocalPath(); XRD_TRACE End(); }
{XRD_TRACE Beg(0, m_traceID) << TRACE_STR_ ## act << x << " " << GetLocalPath(); XRD_TRACE End(); }

#else

Expand Down
9 changes: 9 additions & 0 deletions src/XrdSys/XrdSysTrace.cc
Expand Up @@ -175,6 +175,15 @@ XrdSysTrace& XrdSysTrace::operator<<(const char *val)
return *this;
}


/******************************************************************************/
/* < < std::string */
/******************************************************************************/
XrdSysTrace& XrdSysTrace::operator<<(const std::string& val)
{
return (*this << val.c_str());
}

/******************************************************************************/
/* < < s h o r t */
/******************************************************************************/
Expand Down
1 change: 1 addition & 0 deletions src/XrdSys/XrdSysTrace.hh
Expand Up @@ -60,6 +60,7 @@ XrdSysTrace& operator<<(bool val);

XrdSysTrace& operator<<( char val);
XrdSysTrace& operator<<(const char *val);
XrdSysTrace& operator<<(const std::string& val);

XrdSysTrace& operator<<(short val);
XrdSysTrace& operator<<(int val);
Expand Down

0 comments on commit 7e4f1e8

Please sign in to comment.