hello-world/settings/log.h

Go to the documentation of this file.
00001 #ifndef __LOG_H__
00002 #define __LOG_H__
00003 
00004 /**
00005  * File Name  : log.h
00006  *
00007  * Description: Macros for debug printing
00008  *
00009  * The value of ERREGLOG_X_ON (with X one of LOGGING, WARNING or ERROR)
00010  * determines whether a message will be printed. The value as defined
00011  * in this file can be overruled by defining them before the inclusion of this file.
00012  *
00013  * This file is best included in c files only.
00014  */
00015 
00016 /*
00017  * This file is part of hello-world-settings.
00018  *
00019  * hello-world is free software: you can redistribute it and/or modify
00020  * it under the terms of the GNU General Public License as published by
00021  * the Free Software Foundation, either version 2 of the License, or
00022  * (at your option) any later version.
00023  *
00024  * hello-world is distributed in the hope that it will be useful,
00025  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00026  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00027  * GNU General Public License for more details.
00028  *
00029  * You should have received a copy of the GNU General Public License
00030  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00031  */
00032 
00033 /**
00034  * Copyright (C) 2009 iRex Technologies B.V.
00035  * All rights reserved.
00036  */
00037 
00038 
00039 #define LOG_PREFIX  PACKAGE "-settings"
00040 
00041 
00042 #ifndef LOGGING_ON
00043 #define LOGGING_ON 1
00044 #endif
00045 
00046 #ifndef WARNING_ON
00047 #define WARNING_ON 1
00048 #endif
00049 
00050 #ifndef ERROR_ON
00051 #define ERROR_ON 1
00052 #endif
00053 
00054 
00055 #if (LOGGING_ON)
00056 #define LOGPRINTF(format, args...) fprintf(stderr, "(" LOG_PREFIX "_L)" __FILE__ ":%d,%s() " format "\n", __LINE__, __func__ , ##args)
00057 #else
00058 #define LOGPRINTF(format, args...) do {} while (0)
00059 #endif
00060 
00061 #if (WARNING_ON)
00062 #define WARNPRINTF(format, args...) fprintf(stderr, "(" LOG_PREFIX "_W)" __FILE__ ":%d,%s() " format "\n", __LINE__, __func__ , ##args)
00063 #else
00064 #define WARNPRINTF(format, args...) do {} while (0)
00065 #endif
00066 
00067 #if (ERROR_ON)
00068 #include <errno.h>
00069 #include <string.h>
00070 #define ERRORPRINTF(format, args...) fprintf(stderr, "(" LOG_PREFIX "_E)" __FILE__ ":%d,%s() --- " format "\n", __LINE__, __func__ , ##args)
00071 #define ERRNOPRINTF(format, args...) fprintf(stderr, "(" LOG_PREFIX "_E)" __FILE__ ":%d,%s() --- " format ", errno [%d] [%s]\n", __LINE__, __func__ , ##args, errno, strerror(errno))
00072 #else
00073 #define ERRORPRINTF(format, args...) do {} while (0)
00074 #define ERRNOPRINTF(format, args...) do {} while (0)
00075 #endif
00076 
00077 
00078 #endif // __LOG_H__
Generated by  doxygen 1.6.2-20100208