00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00023 #ifndef SCBLOG_H_
00024 #define SCBLOG_H_
00025 #include <stdio.h>
00026 #include <glib.h>
00027
00028 #define SCB_TRACE_ON 0
00029 #define SCB_DUMP_ON 0
00030 #define SCB_WARNING_ON 0
00031 #define SCB_ERROR_ON 1
00032 #define SCB_ENABLE_CHECK 1
00033 #define SCB_DEBUG_ON 0
00034
00035 #define SYSLOG_ON 1
00036 #if (SYSLOG_ON)
00037 #include <syslog.h>
00038 #endif
00039
00040 #if (SCB_TRACE_ON)
00041 #if (SYSLOG_ON)
00042 #define SCB_TRACE(x, args...) \
00043 {\
00044 syslog(LOG_INFO, "(SCB_TRACE)" __FILE__ ":%d,%s() " x "\n", __LINE__, __FUNCTION__ , ##args);\
00045 fprintf(stderr, "(SCB_TRACE)" __FILE__ ":%d,%s() " x "\n", __LINE__, __FUNCTION__ , ##args);\
00046 }
00047 #else
00048 #define SCB_TRACE(x, args...) fprintf(stderr, "(SCB_TRACE)" __FILE__ ":%d,%s() " x "\n", __LINE__, __FUNCTION__ , ##args)
00049 #endif
00050 #else
00051 #define SCB_TRACE(x, args...) do {} while (0)
00052 #endif
00053
00054 #if (SCB_DUMP_ON)
00055 #if (SYSLOG_ON)
00056 #define SCB_DUMP(x, args...) \
00057 {\
00058 syslog(LOG_INFO, "(SCB_DUMP)" x "\n", ##args);\
00059 fprintf(stderr, "(SCB_DUMP)" x "\n", ##args);\
00060 }
00061 #else
00062 #define SCB_DUMP(x, args...) fprintf(stderr, "(SCB_DUMP)" x "\n", ##args)
00063 #endif
00064 #else
00065 #define SCB_DUMP(x, args...) do {} while (0)
00066 #endif
00067
00068
00069 #if (SCB_WARNING_ON)
00070 #if (SYSLOG_ON)
00071 #define SCB_WARN(x, args...) \
00072 {\
00073 syslog(LOG_WARNING, "(SCB_WARNING)" __FILE__ ":%d,%s() " x "\n", __LINE__, __FUNCTION__ , ##args);\
00074 fprintf(stderr, "(SCB_WARNING)" __FILE__ ":%d,%s() " x "\n", __LINE__, __FUNCTION__ , ##args);\
00075 }
00076 #else
00077 #define SCB_WARN(x, args...) fprintf(stderr, "(SCB_WARNING)" __FILE__ ":%d,%s() " x "\n", __LINE__, __FUNCTION__ , ##args)
00078 #endif
00079 #else
00080 #define SCB_WARN(x, args...) do {} while (0)
00081 #endif
00082
00083 #if (SCB_ERROR_ON)
00084 #if (SYSLOG_ON)
00085 #define SCB_ERROR(x, args...) \
00086 {\
00087 syslog(LOG_ERR, "(SCB_ERROR)" __FILE__ ":%d,%s() " x "\n", __LINE__, __FUNCTION__ , ##args);\
00088 fprintf(stderr, "(SCB_ERROR)" __FILE__ ":%d,%s() " x "\n", __LINE__, __FUNCTION__ , ##args);\
00089 }
00090 #else
00091 #define SCB_ERROR(x, args...) fprintf(stderr, "(SCB_ERROR)" __FILE__ ":%d,%s() " x "\n", __LINE__, __FUNCTION__ , ##args)
00092 #endif
00093 #else
00094 #define SCB_ERROR(x, args...) do {} while (0)
00095 #endif
00096
00097 #if (SCB_ENABLE_CHECK)
00098 #define SCB_RET_FALSE_IF(expr, x, args...) if (expr) { SCB_ERROR(x, ##args); return FALSE; }
00099 #define SCB_RET_NULL_IF(expr, x, args...) if (expr) { SCB_ERROR(x, ##args); return NULL; }
00100 #define SCB_RET_IF(expr, x, args...) if (expr) { SCB_ERROR(x, ##args); return; }
00101 #define SCB_RET_INT_IF(expr, ret, x, args...) if (expr) { SCB_ERROR(x, ##args); return ret; }
00102 #else
00103 #define SCB_RET_BOOL_IF(expr, x, args...) do {} while(0)
00104 #define SCB_RET_NULL_IF(expr, x, args...) do {} while(0)
00105 #define SCB_RET_IF(expr, x, args...) do {} while(0)
00106 #define SCB_RET_INT_IF(expr, ret, x, args...) do {} while(0)
00107 #endif
00108
00109 #endif