xrootd
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
XrdSysLogger Class Reference

#include <XrdSysLogger.hh>

Collaboration diagram for XrdSysLogger:
Collaboration graph
[legend]

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::XrdSysLogger ( int  ErrFD = STDERR_FILENO,
int  xrotate = 1 
)

Constructor

Parameters
ErrFDis the filedescriptor of where error messages normally go if this class is not used. Default is stderr.
xrotatewhen not zero performs internal log rotatation. Otherwise, log rotation is suppressed. See also setRotate().

◆ ~XrdSysLogger()

XrdSysLogger::~XrdSysLogger ( )
inline

Destructor.

References ePath, and RmLogRotateLock().

Member Function Documentation

◆ AddMsg()

void XrdSysLogger::AddMsg ( const char *  msg)

Add a message to be printed at midnight.

Parameters
msgThe message to be printed. A copy of the message is saved.

◆ AtMidnight()

void XrdSysLogger::AtMidnight ( Task mnTask)

◆ Bind()

int XrdSysLogger::Bind ( const char *  path,
int  lfh = 0 
)

◆ Capture()

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
tFIFOPointer to the XrdOucTListFIFO where messages are saved. If the pointer is nil, capturing is turned off.

◆ FifoMake()

int XrdSysLogger::FifoMake ( )
private

◆ FifoWait()

void XrdSysLogger::FifoWait ( )
private

◆ Flush()

void XrdSysLogger::Flush ( )
inline

Flush any pending output.

References eFD, and fsync.

◆ HandleLogRotateLock()

int XrdSysLogger::HandleLogRotateLock ( bool  dorotate)
private

◆ originalFD()

int XrdSysLogger::originalFD ( )
inline

Get the file descriptor passed at construction time.

Returns
the file descriptor passed to the constructor.

References baseFD.

◆ ParseKeep()

int XrdSysLogger::ParseKeep ( const char *  arg)

Parse the keep option argument.

Parameters
argPointer 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.

◆ Put()

void XrdSysLogger::Put ( int  iovcnt,
struct iovec *  iov 
)

Output data and optionally prefix with date/time

Parameters
iovcntThe number of elements in iov vector.
iovThe vector describing what to print. If iov[0].iov_base is zero, the message is prefixed by date and time.

◆ putEmsg()

void XrdSysLogger::putEmsg ( char *  msg,
int  msz 
)
private

◆ ReBind()

int XrdSysLogger::ReBind ( int  dorename = 1)
private

◆ RmLogRotateLock()

void XrdSysLogger::RmLogRotateLock ( )
private

Referenced by ~XrdSysLogger().

◆ setForwarding()

static void XrdSysLogger::setForwarding ( bool  onoff)
inlinestatic

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

References doForward.

◆ setHiRes()

void XrdSysLogger::setHiRes ( )
inline

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

References hiRes.

◆ setKeep()

void XrdSysLogger::setKeep ( long long  knum)
inline

Set log file keep value.

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

References eKeep.

◆ setRotate()

void XrdSysLogger::setRotate ( int  onoff)
inline

Set log file rotation on/off.

Parameters
onoffWhen !0 turns on log file rotations. Otherwise, rotation is turned off.

References doLFR.

◆ Time()

int XrdSysLogger::Time ( char *  tbuff)
private

Referenced by traceBeg().

◆ TimeStamp()

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

◆ traceBeg()

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().

◆ traceEnd()

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().

◆ Trim()

void XrdSysLogger::Trim ( )
private

◆ xlogFN()

const char * XrdSysLogger::xlogFN ( )
inline

Get the log file routing.

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

References ePath.

◆ zHandler()

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

◆ baseFD

int XrdSysLogger::baseFD
private

Referenced by originalFD().

◆ doForward

bool XrdSysLogger::doForward
staticprivate

Referenced by setForwarding().

◆ doLFR

bool XrdSysLogger::doLFR
private

Referenced by setRotate().

◆ eFD

int XrdSysLogger::eFD
private

Referenced by Flush().

◆ eInt

int XrdSysLogger::eInt
private

◆ eKeep

long long XrdSysLogger::eKeep
private

Referenced by setKeep().

◆ ePath

char* XrdSysLogger::ePath
private

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

◆ fifoFN

char* XrdSysLogger::fifoFN
private

◆ Filesfx

char XrdSysLogger::Filesfx[8]
private

◆ hiRes

bool XrdSysLogger::hiRes
private

Referenced by setHiRes().

◆ lfhTID

pthread_t XrdSysLogger::lfhTID
private

◆ Logger_Mutex

XrdSysMutex XrdSysLogger::Logger_Mutex
private

Referenced by traceBeg(), and traceEnd().

◆ msgList

mmMsg* XrdSysLogger::msgList
private

◆ onFifo

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
pathThe 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.
lfhLog 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.

◆ reserved1

int XrdSysLogger::reserved1
private

◆ taskQ

Task* XrdSysLogger::taskQ
private

◆ TBuff

char XrdSysLogger::TBuff[32]
private

Referenced by traceBeg().


The documentation for this class was generated from the following file: