00001 #ifndef __SYS_LOGGER_H__
00002 #define __SYS_LOGGER_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <stdlib.h>
00016 #ifndef WIN32
00017 #include <unistd.h>
00018 #include <string.h>
00019 #include <strings.h>
00020 #else
00021 #include <string.h>
00022 #include <io.h>
00023 #include "XrdSys/XrdWin32.hh"
00024 #endif
00025
00026 #include "XrdSys/XrdSysPthread.hh"
00027
00028 class XrdSysLogger
00029 {
00030 public:
00031 XrdSysLogger(int ErrFD=STDERR_FILENO, int xrotate=1);
00032
00033 ~XrdSysLogger() {if (ePath) free(ePath);}
00034
00035
00036
00037
00038 int Bind(const char *path, int intsec=0);
00039
00040
00041
00042 void Flush() {fsync(eFD);}
00043
00044
00045
00046 int originalFD() {return baseFD;}
00047
00048
00049
00050 void Put(int iovcnt, struct iovec *iov);
00051
00052
00053
00054
00055 void setKeep(long long knum) {eKeep = knum;}
00056
00057
00058
00059 void setRotate(int onoff) {doLFR = onoff;}
00060
00061
00062
00063 int Time(char *tbuff);
00064
00065
00066
00067
00068 char *traceBeg() {Logger_Mutex.Lock(); Time(TBuff); return TBuff;}
00069 char traceEnd() {Logger_Mutex.UnLock(); return '\n';}
00070
00071
00072
00073
00074 int xlogFD();
00075
00076 private:
00077
00078 XrdSysMutex Logger_Mutex;
00079 static int extLFD[4];
00080 long long eKeep;
00081 char TBuff[24];
00082 int eFD;
00083 int baseFD;
00084 char *ePath;
00085 char Filesfx[8];
00086 time_t eNTC;
00087 int eInt;
00088 time_t eNow;
00089 int doLFR;
00090
00091 void putEmsg(char *msg, int msz);
00092 int ReBind(int dorename=1);
00093 void Trim();
00094 };
00095 #endif