XrdSysLogger Class Reference

#include <XrdSysLogger.hh>

Collaboration diagram for XrdSysLogger:

Collaboration graph
[legend]
List of all members.

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 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 Attributes

static const int onFifo = (int)0x80000000

Private Member Functions

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

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

Classes

struct  mmMsg
class  Task

Detailed Description

XrdSysLogger is the object that is used to route messages to wherever they need to go and also handles log file rotation and trimming.


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.


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 
)

int XrdSysLogger::FifoMake (  )  [private]

void XrdSysLogger::FifoWait (  )  [private]

void XrdSysLogger::Flush (  )  [inline]

Flush any pending output.

int XrdSysLogger::originalFD (  )  [inline]

Get the file descriptor passed at construction time.

Returns:
the file descriptor passed to the constructor.

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::setHiRes (  )  [inline]

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

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.

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.

int XrdSysLogger::Time ( char *  tbuff  )  [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.

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.

void XrdSysLogger::Trim (  )  [private]

const char* XrdSysLogger::xlogFN (  )  [inline]

Get the log file routing.

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

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]

bool XrdSysLogger::doLFR [private]

int XrdSysLogger::eFD [private]

int XrdSysLogger::eInt [private]

long long XrdSysLogger::eKeep [private]

char* XrdSysLogger::ePath [private]

char* XrdSysLogger::fifoFN [private]

char XrdSysLogger::Filesfx[8] [private]

bool XrdSysLogger::hiRes [private]

pthread_t XrdSysLogger::lfhTID [private]

XrdSysMutex XrdSysLogger::Logger_Mutex [private]

mmMsg* XrdSysLogger::msgList [private]

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]

Task* XrdSysLogger::taskQ [private]

char XrdSysLogger::TBuff[32] [private]


The documentation for this class was generated from the following file:
Generated on 12 Dec 2014 for xrootd by  doxygen 1.4.7