00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00036 #ifndef _SCRIBBLELOG_H_
00037 #define _SCRIBBLELOG_H_
00038
00039 #define SB_LOGGING_ON 0
00040 #define SB_WARNING_ON 0
00041 #define SB_ERROR_ON 1
00042
00043 #define SB_PAGEBAR_ON 0
00044 #define SB_TOOLBAR_ON 0
00045 #define SB_IPC_ON 0
00046
00047 #define SB_FM_ON 0
00048
00049 #define SB_INK_ON 0
00050 #define SB_INKERR_ON 1
00051 #define SB_TIME_ON 0
00052
00053 #define SYSLOG_ON 1
00054 #if (SYSLOG_ON)
00055 #include <syslog.h>
00056 #endif
00057
00058 #if (SB_LOGGING_ON)
00059 #if (SYSLOG_ON)
00060 #define SB_LOGPRINTF(x, args...) \
00061 {\
00062 syslog(LOG_INFO, "(SB_L)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00063 fprintf(stderr, "(SB_L)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00064 }
00065 #else
00066 #define SB_LOGPRINTF(x, args...) fprintf(stderr, "(SB_L)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args)
00067 #endif
00068 #else
00069 #define SB_LOGPRINTF(x, args...) do {} while (0)
00070 #endif
00071
00072 #if (SB_WARNING_ON)
00073 #if (SYSLOG_ON)
00074 #define SB_WARNPRINTF(x, args...) \
00075 {\
00076 syslog(LOG_WARNING, "(SB_W)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00077 fprintf(stderr, "(SB_W)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00078 }
00079 #else
00080 #define SB_WARNPRINTF(x, args...) fprintf(stderr, "(SB_W)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args)
00081 #endif
00082 #else
00083 #define SB_WARNPRINTF(x, args...) do {} while (0)
00084 #endif
00085
00086 #if (SB_ERROR_ON)
00087 #if (SYSLOG_ON)
00088 #define SB_ERRORPRINTF(x, args...) \
00089 {\
00090 syslog(LOG_ERR, "(SB_E)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00091 fprintf(stderr, "(SB_E)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00092 }
00093 #else
00094 #define SB_ERRORPRINTF(x, args...) fprintf(stderr, "(SB_E)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args)
00095 #endif
00096 #else
00097 #define SB_ERRORPRINTF(x, args...) do {} while (0)
00098 #endif
00099
00100 #if (SB_IPC_ON)
00101 #if (SYSLOG_ON)
00102 #define SB_IPCPRINTF(x, args...) \
00103 {\
00104 syslog(LOG_INFO, "(SB_IP)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00105 fprintf(stderr, "(SB_IP)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00106 }
00107 #else
00108 #define SB_IPCPRINTF(x, args...) fprintf(stderr, "(SB_IP)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args)
00109 #endif
00110 #else
00111 #define SB_IPCPRINTF(x, args...) do {} while (0)
00112 #endif
00113
00114 #if (SB_PAGEBAR_ON)
00115 #if (SYSLOG_ON)
00116 #define SB_PAGEBARPRINTF(x, args...) \
00117 {\
00118 syslog(LOG_INFO, "(SB_PB)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00119 fprintf(stderr, "(SB_PB)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00120 }
00121 #else
00122 #define SB_PAGEBARPRINTF(x, args...) fprintf(stderr, "(SB_PB)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args)
00123 #endif
00124 #else
00125 #define SB_PAGEBARPRINTF(x, args...) do {} while (0)
00126 #endif
00127
00128 #if (SB_TOOLBAR_ON)
00129 #if (SYSLOG_ON)
00130 #define SB_TOOLBARPRINTF(x, args...) \
00131 {\
00132 syslog(LOG_INFO, "(SB_TB)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00133 fprintf(stderr, "(SB_TB)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00134 }
00135 #else
00136 #define SB_TOOLBARPRINTF(x, args...) fprintf(stderr, "(SB_TB)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args)
00137 #endif
00138 #else
00139 #define SB_TOOLBARPRINTF(x, args...) do {} while (0)
00140 #endif
00141
00142 #if (SB_FM_ON)
00143 #if (SYSLOG_ON)
00144 #define SB_FMPRINTF(x, args...) \
00145 {\
00146 syslog(LOG_INFO, "(SB_FM)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00147 fprintf(stderr, "(SB_FM)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00148 }
00149 #else
00150 #define SB_FMPRINTF(x, args...) fprintf(stderr, "(SB_FM)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args)
00151 #endif
00152 #else
00153 #define SB_FMPRINTF(x, args...) do {} while (0)
00154 #endif
00155
00156 #if (SB_INK_ON)
00157 #if (SYSLOG_ON)
00158 #define SB_INKPRINTF(x, args...) \
00159 {\
00160 syslog(LOG_INFO, "(SB_INK)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00161 fprintf(stderr, "(SB_INK)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00162 }
00163 #else
00164 #define SB_INKPRINTF(x, args...) fprintf(stderr, "(SB_INK)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args)
00165 #endif
00166 #else
00167 #define SB_INKPRINTF(x, args...) do {} while (0)
00168 #endif
00169
00170 #if (SB_INKERR_ON)
00171 #if (SYSLOG_ON)
00172 #define SB_INKERRPRINTF(x, args...) \
00173 {\
00174 syslog(LOG_INFO, "(SB_INKERR)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00175 fprintf(stderr, "(SB_INKERR)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args);\
00176 }
00177 #else
00178 #define SB_INKERRPRINTF(x, args...) fprintf(stderr, "(SB_INKERR)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args)
00179 #endif
00180 #else
00181 #define SB_INKERRPRINTF(x, args...) do {} while (0)
00182 #endif
00183
00184
00185 #if (SB_TIME_ON)
00186 #include <sys/time.h>
00187 #include <time.h>
00188 #include <glib.h>
00189 #if (SYSLOG_ON)
00190 #define SB_TIMEDISPLAY(x, args...) \
00191 {\
00192 struct timeval now;\
00193 gettimeofday(&now, NULL);\
00194 syslog(LOG_INFO, "(SB_T)" __FILE__ ":%d,%s() " "%ld.%06ld: " x "\n", __LINE__, __func__ , now.tv_sec, now.tv_usec, ##args);\
00195 fprintf(stderr, "(SB_T)" __FILE__ ":%d,%s() " "%ld.%06ld: " x "\n", __LINE__, __func__ , now.tv_sec, now.tv_usec, ##args);\
00196 }
00197 #else
00198 #define SB_TIMEDISPLAY(x, args...) \
00199 {\
00200 struct timeval now;\
00201 gettimeofday(&now, NULL);\
00202 fprintf(stderr, "(SB_T)" __FILE__ ":%d,%s() " "%ld.%06ld: " x "\n", __LINE__, __func__ , now.tv_sec, now.tv_usec, ##args);\
00203 }
00204 #endif
00205 #else
00206 #define SB_TIMEDISPLAY(x, args...) do {} while (0)
00207 #endif
00208
00209 #endif //_SCRIBBLE_LOG_H_