Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

logging.h

Go to the documentation of this file.
00001 /*
00002  * XetPan: a libEtPan! based Mail User Agent
00003  * Copyright (C) 2002 Melvin Hadasht
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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

Generated on Wed Oct 22 15:50:40 2003 for XetPan by doxygen 1.3.2