qoflog.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *            qof-log.h
00003  *
00004  *  Mon Nov 21 14:35:26 2005
00005  *  Author: Rob Clark (rclark@cs.hmc.edu)
00006  *  Copyright (C) 1998-2003 Linas Vepstas <linas@linas.org>
00007  *  Copyright  2005  Neil Williams
00008  *  linux@codehelp.co.uk
00009  ****************************************************************************/
00010 /*
00011  *  This program is free software; you can redistribute it and/or modify
00012  *  it under the terms of the GNU General Public License as published by
00013  *  the Free Software Foundation; either version 2 of the License, or
00014  *  (at your option) any later version.
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU General Public License for more details.
00020  *
00021  *  You should have received a copy of the GNU General Public License
00022  *  along with this program; if not, write to the Free Software
00023  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00024  *  02110-1301,  USA
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 /* _QOF_LOG_H */
00253 

Generated on Thu Jan 31 22:50:26 2008 for QOF by  doxygen 1.5.4