00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00034 #ifndef _QOF_LOG_H
00035 #define _QOF_LOG_H
00036
00037 #include <stdarg.h>
00038 #include <stdio.h>
00039 #include "qofutil.h"
00040
00041 #define QOF_MOD_ENGINE "qof-engine"
00042
00043 #define LOG_LEVEL_LIST(_) \
00044 _(QOF_LOG_FATAL, = 0) \
00045 _(QOF_LOG_ERROR, = 1) \
00046 _(QOF_LOG_WARNING, = 2) \
00047 _(QOF_LOG_INFO, = 3) \
00048 _(QOF_LOG_DEBUG, = 4) \
00049 _(QOF_LOG_DETAIL, = 5) \
00050 _(QOF_LOG_TRACE, = 6)
00051
00058 DEFINE_ENUM (QofLogLevel, LOG_LEVEL_LIST)
00059
00060
00064 AS_STRING_DEC (QofLogLevel, LOG_LEVEL_LIST)
00065
00070 FROM_STRING_DEC (QofLogLevel, LOG_LEVEL_LIST)
00071
00073 void qof_log_add_indent (void);
00074
00076 gint qof_log_get_indent (void);
00077
00082 void qof_log_drop_indent (void);
00083
00094 void qof_log_init (void);
00095
00101 void qof_log_set_level (QofLogModule module, QofLogLevel level);
00102
00123 void qof_log_set_level_registered (QofLogLevel level);
00124
00131 void qof_log_set_file (FILE * outfile);
00132
00137 void qof_log_init_filename (const gchar * logfilename);
00138
00140 void qof_log_shutdown (void);
00141
00145 const gchar *qof_log_prettify (const gchar * name);
00146
00148 gboolean qof_log_check (QofLogModule log_module, QofLogLevel log_level);
00149
00151 void qof_log_set_default (QofLogLevel log_level);
00152
00153 typedef void (*QofLogCB) (QofLogModule log_module,
00154 QofLogLevel * log_level, gpointer user_data);
00155
00161 void qof_log_module_foreach (QofLogCB cb, gpointer data);
00162
00164 gint qof_log_module_count (void);
00165
00166 #define FUNK qof_log_prettify(__FUNCTION__)
00167
00179 #define FATAL(format, args...) do { \
00180 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, \
00181 "Fatal Error: %s(): " format, FUNK , ## args); \
00182 } while (0)
00183
00185 #define PERR(format, args...) do { \
00186 if (qof_log_check (log_module, QOF_LOG_ERROR)) { \
00187 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \
00188 "Error: %s(): " format, FUNK , ## args); \
00189 } \
00190 } while (0)
00191
00193 #define PWARN(format, args...) do { \
00194 if (qof_log_check (log_module, QOF_LOG_WARNING)) { \
00195 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, \
00196 "Warning: %s(): " format, FUNK , ## args); \
00197 } \
00198 } while (0)
00199
00201 #define PINFO(format, args...) do { \
00202 if (qof_log_check (log_module, QOF_LOG_INFO)) { \
00203 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, \
00204 "Info: %s(): " format, \
00205 FUNK , ## args); \
00206 } \
00207 } while (0)
00208
00210 #define DEBUG(format, args...) do { \
00211 if (qof_log_check (log_module, QOF_LOG_DEBUG)) { \
00212 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
00213 "Debug: %s(): " format, \
00214 FUNK , ## args); \
00215 } \
00216 } while (0)
00217
00219 #define ENTER(format, args...) do { \
00220 if (qof_log_check (log_module, QOF_LOG_DEBUG)) { \
00221 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
00222 "Enter in %s: %s()" format, __FILE__, \
00223 FUNK , ## args); \
00224 qof_log_add_indent(); \
00225 } \
00226 } while (0)
00227
00229 #define LEAVE(format, args...) do { \
00230 if (qof_log_check (log_module, QOF_LOG_DEBUG)) { \
00231 qof_log_drop_indent(); \
00232 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
00233 "Leave: %s()" format, \
00234 FUNK , ## args); \
00235 } \
00236 } while (0)
00237
00239 #define TRACE(format, args...) do { \
00240 if (qof_log_check (log_module, QOF_LOG_TRACE)) { \
00241 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
00242 "Trace: %s(): " format, FUNK , ## args); \
00243 } \
00244 } while (0)
00245
00246 #define DEBUGCMD(x) do { \
00247 if (qof_log_check (log_module, QOF_LOG_DEBUG)) { \
00248 (x); \
00249 } \
00250 } while (0)
00251
00252 #endif
00253