libgphoto2 (libgphoto2): libgphoto2_port/libgphoto2_port/gphoto2-port-log.h Source File

Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

# gphoto2-port-log.h

    00001 /* gphoto2-port-log.h
    00002  *
    00003  * Copyright © 2001 Lutz Müller <lutz@users.sf.net>
    00004  *
    00005  * This library is free software; you can redistribute it and/or
    00006  * modify it under the terms of the GNU Lesser General Public
    00007  * License as published by the Free Software Foundation; either
    00008  * version 2 of the License, or (at your option) any later version.
    00009  *
    00010  * This library 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 GNU
    00013  * Lesser General Public License for more details.
    00014  *
    00015  * You should have received a copy of the GNU Lesser General Public
    00016  * License along with this library; if not, write to the
    00017  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00018  * Boston, MA 02111-1307, USA.
    00019  */
    00020
    00021 #ifndef __GPHOTO2_PORT_LOG_H__
    00022 #define __GPHOTO2_PORT_LOG_H__
    00023
    00024 #include <stdarg.h>
    00025
    00026 typedef enum {
    00027         GP_LOG_ERROR = 0,
    00028         GP_LOG_VERBOSE = 1,
    00029         GP_LOG_DEBUG = 2,
    00030         GP_LOG_DATA = 3
    00031 } GPLogLevel;
    00032
    00042 #define GP_LOG_ALL GP_LOG_DATA
    00043
    00044 typedef void (* GPLogFunc) (GPLogLevel level, const char *domain,
    00045                             const char *format, va_list args, void *data)
    00046 #if (__GNUC__ >= 3)
    00047         __attribute__((__format__(printf,3,0)))
    00048 #endif
    00049 ;
    00050
    00051 #ifndef DISABLE_DEBUGGING
    00052
    00053 int  gp_log_add_func    (GPLogLevel level, GPLogFunc func, void *data);
    00054 int  gp_log_remove_func (int id);
    00055
    00056 /* Logging */
    00057 void gp_log      (GPLogLevel level, const char *domain,
    00058                   const char *format, ...)
    00059 #ifdef __GNUC__
    00060         __attribute__((__format__(printf,3,4)))
    00061 #endif
    00062 ;
    00063 void gp_logv     (GPLogLevel level, const char *domain, const char *format,
    00064                   va_list args)
    00065 #ifdef __GNUC__
    00066         __attribute__((__format__(printf,3,0)))
    00067 #endif
    00068 ;
    00069 void gp_log_data (const char *domain, const char *data, unsigned int size);
    00070
    00082 #ifdef __GNUC__
    00083 #define GP_LOG(level, msg, params...) \
    00084         gp_log(level, GP_MODULE "/" __FILE__, msg, ##params)
    00085
    00086 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    00087 #define GP_LOG(level, ...) \
    00088         gp_log(level, GP_MODULE "/" __FILE__, __VA_ARGS__)
    00089
    00090 #else
    00091 # ifdef __GCC__
    00092 #  warning Disabling GP_LOG because variadic macros are not allowed
    00093 # endif
    00094 #define GP_LOG (void)
    00095 #endif
    00096
    00108 #ifdef __GNUC__
    00109 #define GP_DEBUG(msg, params...) \
    00110         gp_log(GP_LOG_DEBUG, GP_MODULE "/" __FILE__, msg, ##params)
    00111
    00112 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    00113 #define GP_DEBUG(...) \
    00114         gp_log(GP_LOG_DEBUG, GP_MODULE "/" __FILE__, __VA_ARGS__)
    00115
    00116 #else
    00117 # ifdef __GCC__
    00118 #  warning Disabling GP_DEBUG because variadic macros are not allowed
    00119 # endif
    00120 #define GP_DEBUG (void)
    00121 #endif
    00122
    00123 #else /* DISABLE_DEBUGGING */
    00124
    00125 /* Stub these functions out if debugging is disabled */
    00126 #define gp_log_add_func(level, func, data) (0)
    00127 #define gp_log_remove_func(id) (0)
    00128 #define gp_log(level, domain, format, args...)
    00129 #define gp_logv(level, domain, format, args)
    00130 #define gp_log_data(domain, data, size)
    00131
    00132 #ifdef __GNUC__
    00133 #define GP_LOG(level, msg, params...)
    00134 #define GP_DEBUG(msg, params...)
    00135
    00136 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    00137 #define GP_LOG(level, ...)
    00138 #define GP_DEBUG(...)
    00139
    00140 #else
    00141 #define GP_LOG (void)
    00142 #define GP_DEBUG (void)
    00143 #endif
    00144
    00145 #endif /* DISABLE_DEBUGGING */
    00146
    00147 #endif /* __GPHOTO2_PORT_LOG_H__ */