00001
00002
00003
00004
00005
00006
00007
00008
00014
00015
00016
00017 #ifndef _LOG_H_
00018 #define _LOG_H_
00019
00020 #include <unistd.h>
00021 #include <string.h>
00022 #include <stdlib.h>
00023 #include <fcntl.h>
00024 #include <sys/types.h>
00025 #include <sys/stat.h>
00026
00027 #ifndef WIN32
00028 #include <syslog.h>
00029 #endif
00030
00031 #include "liberopops.h"
00032
00039
00040 #define LOGIT(b...) {logit(b);}
00041
00042 #define LOG_INIT(logfile,sysmode) {log_init(logfile,sysmode);}
00043
00044 #define LOG_END() {log_end();}
00045
00046 #define MALLOC_CHECK(p) {\
00047 if(p == NULL) \
00048 ERROR_ABORT("Unable to malloc\n");\
00049 }
00050
00051 #define ERROR_ABORT(a) {\
00052 LOGIT(LOG_ZONE,"ABORT(%s,%4d): %s",__FILE__,__LINE__,a);\
00053 abort();\
00054 }
00055
00056 #define ERROR_PRINT(a) {\
00057 LOGIT(LOG_ZONE,"ERROR(%s,%4d): %s",__FILE__,__LINE__,a);\
00058 }
00059
00060 #define DBG(a...) {\
00061 if (log_get_verbosity() >= 2) {\
00062 LOGIT(LOG_ZONE,"DBG(%s,%4d): ",\
00063 __FILE__,__LINE__);\
00064 LOGIT(LOG_ZONE,a);\
00065 }\
00066 }
00067
00068 #define SAY(a...) {\
00069 if (log_get_verbosity() >= 1) {\
00070 LOGIT(LOG_ZONE,a);\
00071 }\
00072 }
00073
00074
00076 #define MAX_LOG_SIZE 3000000
00077
00079 #define MAX_LOG_STRING 1000
00080
00089 int logit(char* zone, char *str, ...);
00090
00092 int log_init(char* logfile, int syslogmode);
00093
00095 int log_end(void);
00096
00098 int log_get_verbosity(void);
00099
00101 void log_set_verbosity(int v);
00102
00103 int log_rotate(char *logfile);
00104
00105 char *log_get_logfile(void);
00106
00107 #endif