00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef LOGGING_H
00021 #define LOGGING_H
00022
00023 #include <stdio.h>
00024 #include <time.h>
00025
00026 #include "xetpan-types.h"
00027
00036 int
00037 a_Logging_redirect(XetPan *xetpan, const char *path);
00038
00041 extern int verbose;
00042
00044 #define XETPAN_LOG_FILE "xetpan.log"
00045
00047 #define XETPAN_LOG_FILE_BAK "xetpan.log~"
00048
00049 #define SIZE_OF_TIME_STRING 9
00050
00052 #define A_LOGGING_ERROR(...) \
00053 ({char ts[SIZE_OF_TIME_STRING]; \
00054 time_t t; \
00055 t = time(NULL); \
00056 strftime(ts, SIZE_OF_TIME_STRING, "%H:%M:%S", localtime(&t)); \
00057 fprintf(stderr, "[%s] ERROR: ", ts); \
00058 fprintf(stderr, __VA_ARGS__); \
00059 fprintf(stderr, "\n");})
00060
00061 #define A_LOGGING_SYSTEM_ERROR(...) \
00062 ({fprintf(stderr, "%s (%s +%d) SYSTEM ERROR: ", __FUNCTION__, __FILE__, __LINE__), \
00063 fprintf(stderr, __VA_ARGS__), \
00064 fprintf(stderr, "\n");})
00065
00066 #define A_LOGGING_INFO(...) \
00067 ({if (verbose) \
00068 { \
00069 char ts[SIZE_OF_TIME_STRING]; \
00070 time_t t; \
00071 t = time(NULL); \
00072 strftime(ts, SIZE_OF_TIME_STRING, "%H:%M:%S", localtime(&t)); \
00073 fprintf(stderr, "[%s] ", ts); \
00074 fprintf(stderr, __VA_ARGS__); \
00075 fprintf(stderr, "\n");} \
00076 } )
00077
00079 #define A_LOGGING_DEBUG(...) \
00080 ({if (verbose > 1) \
00081 fprintf(stderr, "%s:%d %s: ",__FILE__ , __LINE__ , __FUNCTION__), \
00082 fprintf(stderr, __VA_ARGS__), \
00083 fprintf(stderr, "\n");})
00084
00085 #define A_LOGGING_TRACE \
00086 ({if (verbose > 1) \
00087 fprintf(stderr,"%s:%d %s \n", __FILE__, __LINE__ , __FUNCTION__);})
00088
00089 #endif