XrdSysLogger Class Reference

#include <XrdSysLogger.hh>

Collaboration diagram for XrdSysLogger:
Collaboration graph
[legend]

List of all members.

Classes

struct  mmMsg
class  Task

Public Member Functions

 XrdSysLogger (int ErrFD=STDERR_FILENO, int xrotate=1)
 ~XrdSysLogger ()
 Destructor.
void AddMsg (const char *msg)
void AtMidnight (Task *mnTask)
int Bind (const char *path, int lfh=0)
void Capture (XrdOucTListFIFO *tFIFO)
void Flush ()
 Flush any pending output.
int originalFD ()
int ParseKeep (const char *arg)
void Put (int iovcnt, struct iovec *iov)
void setHiRes ()
 Set log file timstamp to high resolution (hh:mm:ss.uuuu).
void setKeep (long long knum)
void setRotate (int onoff)
char * traceBeg ()
char traceEnd ()
const char * xlogFN ()
void zHandler ()

Static Public Member Functions

static void setForwarding (bool onoff)
 Set call-out to logging plug-in on or off.

Static Public Attributes

static const int onFifo = (int)0x80000000

Private Member Functions

int FifoMake ()
void FifoWait ()
int Time (char *tbuff)
int HandleLogRotateLock (bool dorotate)
void RmLogRotateLock ()
void putEmsg (char *msg, int msz)
int ReBind (int dorename=1)
void Trim ()

Static Private Member Functions

static int TimeStamp (struct timeval &tVal, unsigned long tID, char *tbuff, int tbsz, bool hires)

Private Attributes

mmMsgmsgList
TasktaskQ
XrdSysMutex Logger_Mutex
long long eKeep
char TBuff [32]
int eFD
int baseFD
char * ePath
char Filesfx [8]
int eInt
int reserved1
char * fifoFN
bool hiRes
bool doLFR
pthread_t lfhTID

Static Private Attributes

static bool doForward

Constructor & Destructor Documentation

XrdSysLogger::XrdSysLogger ( int  ErrFD = STDERR_FILENO,
int  xrotate = 1 
)

Constructor

Parameters:
ErrFD is the filedescriptor of where error messages normally go if this class is not used. Default is stderr.
xrotate when not zero performs internal log rotatation. Otherwise, log rotation is suppressed. See also setRotate().
XrdSysLogger::~XrdSysLogger (  )  [inline]

Destructor.

References ePath, and RmLogRotateLock().


Member Function Documentation

void XrdSysLogger::AddMsg ( const char *  msg  ) 

Add a message to be printed at midnight.

Parameters:
msg The message to be printed. A copy of the message is saved.
void XrdSysLogger::AtMidnight ( Task mnTask  ) 
int XrdSysLogger::Bind ( const char *  path,
int  lfh = 0 
)
void XrdSysLogger::Capture ( XrdOucTListFIFO tFIFO  ) 

Capture allows you to capture all messages (they are not routed). This is a global setting so use with caution!

Parameters:
tBase Pointer to the XrdOucTListFIFO where messages are saved. If the pointer is nil, capturing is turned off.
int XrdSysLogger::FifoMake (  )  [private]
void XrdSysLogger::FifoWait (  )  [private]
void XrdSysLogger::Flush (  )  [inline]

Flush any pending output.

References eFD, and fsync.

int XrdSysLogger::HandleLogRotateLock ( bool  dorotate  )  [private]
int XrdSysLogger::originalFD (  )  [inline]

Get the file descriptor passed at construction time.

Returns:
the file descriptor passed to the constructor.

References baseFD.

int XrdSysLogger::ParseKeep ( const char *  arg  ) 

Parse the keep option argument.

Parameters:
arg Pointer to the argument. The argument syntax is: <count> | <size> | fifo | <signame>
Returns:
!0 Parsing succeeded. The return value is the argument that must be passed as the lfh parameter to Bind().
=0 Invalid keep argument.
void XrdSysLogger::Put ( int  iovcnt,
struct iovec *  iov 
)

Output data and optionally prefix with date/time

Parameters:
iovcnt The number of elements in iov vector.
iov The vector describing what to print. If iov[0].iov_base is zero, the message is prefixed by date and time.
void XrdSysLogger::putEmsg ( char *  msg,
int  msz 
) [private]
int XrdSysLogger::ReBind ( int  dorename = 1  )  [private]
void XrdSysLogger::RmLogRotateLock (  )  [private]

Referenced by ~XrdSysLogger().

static void XrdSysLogger::setForwarding ( bool  onoff  )  [inline, static]

Set call-out to logging plug-in on or off.

References doForward.

void XrdSysLogger::setHiRes (  )  [inline]

Set log file timstamp to high resolution (hh:mm:ss.uuuu).

References hiRes.

void XrdSysLogger::setKeep ( long long  knum  )  [inline]

Set log file keep value.

Parameters:
knum The keep value. If knum < 0 then abs(knum) files are kept. Otherwise, only knum bytes of log files are kept.

References eKeep.

void XrdSysLogger::setRotate ( int  onoff  )  [inline]

Set log file rotation on/off.

Parameters:
onoff When !0 turns on log file rotations. Otherwise, rotation is turned off.

References doLFR.

int XrdSysLogger::Time ( char *  tbuff  )  [private]

Referenced by traceBeg().

static int XrdSysLogger::TimeStamp ( struct timeval &  tVal,
unsigned long  tID,
char *  tbuff,
int  tbsz,
bool  hires 
) [static, private]
char* XrdSysLogger::traceBeg (  )  [inline]

Start trace message serialization. This method must be followed by a call to traceEnd().

Returns:
pointer to the time buffer to be used as the msg timestamp.

References XrdSysMutex::Lock(), Logger_Mutex, TBuff, and Time().

char XrdSysLogger::traceEnd (  )  [inline]

Stop trace message serialization. This method must be preceeded by a call to traceBeg().

Returns:
pointer to a new line character to terminate the message.

References Logger_Mutex, and XrdSysMutex::UnLock().

void XrdSysLogger::Trim (  )  [private]
const char* XrdSysLogger::xlogFN (  )  [inline]

Get the log file routing.

Returns:
the filename of the log file or "stderr".

References ePath.

void XrdSysLogger::zHandler (  ) 

Internal method to handle the logfile. This is public because it needs to be called by an external thread.


Member Data Documentation

int XrdSysLogger::baseFD [private]

Referenced by originalFD().

bool XrdSysLogger::doForward [static, private]

Referenced by setForwarding().

bool XrdSysLogger::doLFR [private]

Referenced by setRotate().

int XrdSysLogger::eFD [private]

Referenced by Flush().

int XrdSysLogger::eInt [private]
long long XrdSysLogger::eKeep [private]

Referenced by setKeep().

char* XrdSysLogger::ePath [private]

Referenced by xlogFN(), and ~XrdSysLogger().

char* XrdSysLogger::fifoFN [private]
char XrdSysLogger::Filesfx[8] [private]
bool XrdSysLogger::hiRes [private]

Referenced by setHiRes().

pthread_t XrdSysLogger::lfhTID [private]

Referenced by traceBeg(), and traceEnd().

const int XrdSysLogger::onFifo = (int)0x80000000 [static]

Bind allows you to bind the file descriptor passed at construction time to a file with an optional periodic closing and opening of the file.

Parameters:
path The log file path. The file is created, if need be. If path is null, messages are routed to stderr and the lfh argument is ignored.
lfh Log file handling: >0 file is to be closed and opened at midnight. This implies automatic log rotation. =0 file is to be left open all the time. This implies no log rotation. <0 file is to be closed and opened only on signal abs(lfh) unless the value equals onFifo. In this case a fifo is used to control log file rotation. The name of the fifo is path with the filename component prefixed by dot. This implies manual log rotation. Warning! Using signals requires that Bind() be called before starting any threads so that the signal is properly blocked.
Returns:
0 Processing successful.
<0 Unable to bind, returned value is -errno of the reason.
int XrdSysLogger::reserved1 [private]
char XrdSysLogger::TBuff[32] [private]

Referenced by traceBeg().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 19 Oct 2019 for xrootd by  doxygen 1.6.1