/Users/huttone/Devel/sedflux-new/sedflux/trunk/ew/utils/eh_logging.h

Go to the documentation of this file.
00001 //---
00002 //
00003 // This file is part of sedflux.
00004 //
00005 // sedflux is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // sedflux is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with sedflux; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //
00019 //---
00020 
00021 #ifndef __EH_LOGGING_H__
00022 #define __EH_LOGGING_H__
00023 
00024 #include <stdio.h>
00025 #include <glib.h>
00026 #include <string.h>
00027 #include <stdarg.h>
00028 
00029 #define EH_LOG_LEVEL_DATA (1<<G_LOG_LEVEL_USER_SHIFT)
00030 
00031 #define DEFAULT_LOG "stdout"
00032 #define DEFAULT_ERROR_LOG "stderr"
00033 
00034 // open a log.
00035 // log_name     : the name of the log to open.
00036 // return value : nothing.
00037 FILE* eh_open_log(const char *log_name);
00038 
00039 // close a log.
00040 // log_name     : the name of the log to close.
00041 // return value : nothing.
00042 void eh_close_log(const char *log_name);
00043 
00044 // print a message to a log.
00045 // log_name     : the name of the log to print to.
00046 // message      : a format string to print.
00047 // ...          : arguments to substitute into message.
00048 // return value : nothing.
00049 void eh_print_log(const char *log_name, const char *message,...);
00050 
00051 // open a file pointer to a log.
00052 // log_name     : the name of the log to open.
00053 // return value : a file pointer for the log.
00054 FILE *eh_open_log_file(const char *log_name);
00055 
00056 // reset a log to it's original state.
00057 // log_file     : the name of a log.
00058 // return value : nothing.
00059 void eh_reset_log(const char *log_file);
00060 
00061 // rediret a log to another file.
00062 // log_file     : the name of a log.
00063 // return value : nothing.
00064 void eh_redirect_log(const char *log_file1,const char *log_file2);
00065 
00066 #ifndef EH_LOG_DOMAIN
00067 # define EH_LOG_DOMAIN ((gchar*)0)
00068 #endif
00069 
00070 void eh_set_ignore_log_level( GLogLevelFlags ignore );
00071 GLogLevelFlags eh_set_verbosity_level( gint verbosity );
00072 void eh_logger( const gchar *log_domain ,
00073                 GLogLevelFlags log_level ,
00074                 const gchar *message ,
00075                 gpointer user_data );
00076 #ifdef G_HAVE_ISO_VARARGS
00077 #define eh_message(...)  g_log( EH_LOG_DOMAIN ,       \
00078                                 G_LOG_LEVEL_MESSAGE , \
00079                                 __VA_ARGS__ )
00080 #define eh_info(...)     g_log( EH_LOG_DOMAIN ,    \
00081                                 G_LOG_LEVEL_INFO , \
00082                                 __VA_ARGS__ )
00083 #define eh_warning(...)  g_log( EH_LOG_DOMAIN ,       \
00084                                 G_LOG_LEVEL_WARNING , \
00085                                 __VA_ARGS__ )
00086 #define eh_error(...)    g_log( EH_LOG_DOMAIN ,     \
00087                                 G_LOG_LEVEL_ERROR , \
00088                                 __VA_ARGS__ )
00089 #define eh_debug(...)    g_log( EH_LOG_DOMAIN ,     \
00090                                 G_LOG_LEVEL_DEBUG , \
00091                                 __VA_ARGS__ )
00092 #define eh_data(...)     g_log( EH_LOG_DOMAIN ,     \
00093                                 EH_LOG_LEVEL_DATA , \
00094                                 __VA_ARGS__ )
00095 #elif defined(G_HAVE_GNUC_VARARGS)
00096 #define eh_message(format...)  g_log( EH_LOG_DOMAIN ,       \
00097                                       G_LOG_LEVEL_MESSAGE , \
00098                                       format )
00099 #define eh_info(format...)     g_log( EH_LOG_DOMAIN ,    \
00100                                       G_LOG_LEVEL_INFO , \
00101                                       format )
00102 #define eh_warning(format...)  g_log( EH_LOG_DOMAIN ,       \
00103                                       G_LOG_LEVEL_WARNING , \
00104                                       format )
00105 #define eh_error(format...)    g_log( EH_LOG_DOMAIN ,     \
00106                                       G_LOG_LEVEL_ERROR , \
00107                                       format )
00108 #define eh_debug(format...)    g_log( EH_LOG_DOMAIN ,     \
00109                                       G_LOG_LEVEL_DEBUG , \
00110                                       format )
00111 #define eh_data(format...)     g_log( EH_LOG_DOMAIN ,     \
00112                                       EH_LOG_LEVEL_DATA , \
00113                                       format )
00114 #else
00115 static void eh_message( const char *format , ... )
00116 {
00117    va_list args;
00118    va_start( args , format );
00119    g_logv( EH_LOG_DOMAIN , G_LOG_LEVEL_MESSAGE , format , args );
00120    va_end( args );
00121 }
00122 static void eh_info( const char *format , ... )
00123 {
00124    va_list args;
00125    va_start( args , format );
00126    g_logv( EH_LOG_DOMAIN , G_LOG_LEVEL_INFO , format , args );
00127    va_end( args );
00128 }
00129 
00130 static void eh_warning( const char *format , ... )
00131 {
00132    va_list args;
00133    va_start( args , format );
00134    g_logv( EH_LOG_DOMAIN , G_LOG_LEVEL_WARNING , format , args );
00135    va_end( args );
00136 }
00137 
00138 static void eh_error( const char *format , ... )
00139 {
00140    va_list args;
00141    va_start( args , format );
00142    g_logv( EH_LOG_DOMAIN , G_LOG_LEVEL_ERROR , format , args );
00143    va_end( args );
00144 }
00145 
00146 static void eh_debug( const char *format , ... )
00147 {
00148    va_list args;
00149    va_start( args , format );
00150    g_logv( EH_LOG_DOMAIN , G_LOG_LEVEL_DEBUG , format , args );
00151    va_end( args );
00152 }
00153 
00154 static void eh_data( const char* format , ... )
00155 {
00156    va_list args;
00157    va_start( args , format );
00158    g_logv( EH_LOG_DOMAIN , EH_LOG_LEVEL_DATA , format , args );
00159    va_end( args );
00160 }
00161 #endif
00162 
00163 #endif /* eh_logging.h is included */

Generated on Fri Jan 4 18:04:16 2008 for sedflux by  doxygen 1.5.2