xrootd
Loading...
Searching...
No Matches
XrdSysLogging.hh
Go to the documentation of this file.
1#ifndef __SYS_LOGGING_H__
2#define __SYS_LOGGING_H__
3/******************************************************************************/
4/* */
5/* X r d S y s L o g g i n g . h h */
6/* */
7/*(c) 2016 by the Board of Trustees of the Leland Stanford, Jr., University */
8/*Produced by Andrew Hanushevsky for Stanford University under contract */
9/* DE-AC02-76-SFO0515 with the Deprtment of Energy */
10/* */
11/* This file is part of the XRootD software suite. */
12/* */
13/* XRootD is free software: you can redistribute it and/or modify it under */
14/* the terms of the GNU Lesser General Public License as published by the */
15/* Free Software Foundation, either version 3 of the License, or (at your */
16/* option) any later version. */
17/* */
18/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21/* License for more details. */
22/* */
23/* You should have received a copy of the GNU Lesser General Public License */
24/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26/* */
27/* The copyright holder's institutional names and contributor's names may not */
28/* be used to endorse or promote products derived from this software without */
29/* specific prior written permission of the institution or contributor. */
30/******************************************************************************/
31
32#include <limits.h>
33#include <cstdlib>
34#include <sys/time.h>
35#include <sys/uio.h>
36
37#include "XrdSys/XrdSysLogPI.hh"
39
40//-----------------------------------------------------------------------------
43//-----------------------------------------------------------------------------
44
45class XrdSysLogger;
46
48{
49public:
50
51//-----------------------------------------------------------------------------
54//-----------------------------------------------------------------------------
55
57
59
60//-----------------------------------------------------------------------------
62//-----------------------------------------------------------------------------
63
64struct Parms
65 {const char *logfn;
67 int bufsz;
68 int keepV;
69 bool hiRes;
70 Parms() : logfn(0), logpi(0), bufsz(-1), keepV(0), hiRes(false) {}
71 ~Parms() {}
72 };
73
74//-----------------------------------------------------------------------------
81//-----------------------------------------------------------------------------
82
83static bool Configure(XrdSysLogger &logr, Parms &parms);
84
85//-----------------------------------------------------------------------------
95//-----------------------------------------------------------------------------
96
97static bool Forward(struct timeval mtime, unsigned long tID,
98 struct iovec *iov, int iovcnt);
99
100private:
102 {struct timeval msgtod; // time message was generated
103 unsigned long tID; // Thread ID issuing message
104 unsigned int next; // Offset to next message, 0 if none
105 unsigned short buffsz; // In doublewords (max is 512K-8)
106 short msglen; // Len of msg text (max 32K-1) if <0 ->lost msgs
107// char msgtxt; // Text follows the message header
108 };
109static const int msgOff = sizeof(MsgBuff);
110static const int mbDwords = (sizeof(MsgBuff)+7)/8*8;
111static const int maxMsgLen = SHRT_MAX;
112
113static int CopyTrunc(char *mbuff, struct iovec *iov, int iovcnt);
114static bool EMsg(XrdSysLogger &logr, const char *msg);
115static MsgBuff *getMsg(char **msgTxt, bool cont);
116static void *Send2PI(void *arg);
117
118static pthread_t lpiTID;
119static bool lclOut;
120static bool rmtOut;
121};
122#endif
void(* XrdSysLogPI_t)(struct timeval const &mtime, unsigned long tID, const char *msg, int mlen)
Definition XrdSysLogPI.hh:51
Definition XrdSysLogger.hh:53
Definition XrdSysLogging.hh:48
static MsgBuff * getMsg(char **msgTxt, bool cont)
static bool Forward(struct timeval mtime, unsigned long tID, struct iovec *iov, int iovcnt)
static bool EMsg(XrdSysLogger &logr, const char *msg)
static bool rmtOut
Definition XrdSysLogging.hh:120
XrdSysLogging()
Definition XrdSysLogging.hh:56
static pthread_t lpiTID
Definition XrdSysLogging.hh:118
static bool lclOut
Definition XrdSysLogging.hh:119
static int CopyTrunc(char *mbuff, struct iovec *iov, int iovcnt)
static const int mbDwords
Definition XrdSysLogging.hh:110
static const int maxMsgLen
Definition XrdSysLogging.hh:111
static const int msgOff
Definition XrdSysLogging.hh:109
~XrdSysLogging()
Definition XrdSysLogging.hh:58
static void * Send2PI(void *arg)
static bool Configure(XrdSysLogger &logr, Parms &parms)
Definition XrdSysLogging.hh:102
struct timeval msgtod
Definition XrdSysLogging.hh:102
unsigned int next
Definition XrdSysLogging.hh:104
unsigned short buffsz
Definition XrdSysLogging.hh:105
unsigned long tID
Definition XrdSysLogging.hh:103
short msglen
Definition XrdSysLogging.hh:106
Parameters to be passed to configure.
Definition XrdSysLogging.hh:65
Parms()
Definition XrdSysLogging.hh:70
XrdSysLogPI_t logpi
-> log plugin object or nil if none
Definition XrdSysLogging.hh:66
int keepV
log keep argument
Definition XrdSysLogging.hh:68
const char * logfn
-> log file name or nil if none.
Definition XrdSysLogging.hh:65
bool hiRes
log using high resolution timestamp
Definition XrdSysLogging.hh:69
int bufsz
size of message buffer, -1 default, or 0
Definition XrdSysLogging.hh:67
~Parms()
Definition XrdSysLogging.hh:71
Definition XrdOucIOVec.hh:65