21#ifndef LIBGPHOTO2_GPHOTO2_PORT_LOG_H 
   22#define LIBGPHOTO2_GPHOTO2_PORT_LOG_H 
   50#define GP_LOG_ALL GP_LOG_DATA 
   67#ifndef DISABLE_DEBUGGING 
   75        __attribute__((__format__(printf,3,4)))
 
   78void gp_log_with_source_location(
 
   79                  GPLogLevel level, 
const char *file, 
int line, 
const char *func,
 
   80                  const char *format, ...)
 
   82        __attribute__((__format__(printf,5,6)))
 
   85void gp_logv     (
GPLogLevel level, 
const char *domain, 
const char *format, va_list args)
 
   87        __attribute__((__format__(printf,3,0)))
 
   90void gp_log_data (
const char *domain, 
const char *data, 
unsigned int size,
 
   91                  const char *format, ...)
 
   93__attribute__((__format__(printf,4,5)))
 
  108#ifdef _GPHOTO2_INTERNAL_CODE 
  109#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 
  110#define GP_DEBUG(...) \ 
  111        gp_log(GP_LOG_DEBUG, GP_MODULE "/" __FILE__, __VA_ARGS__) 
  118#define GP_LOG_D(...) gp_log(GP_LOG_DEBUG, __func__, __VA_ARGS__) 
  119#define GP_LOG_E(...) gp_log_with_source_location(GP_LOG_ERROR, __FILE__, __LINE__, __func__, __VA_ARGS__) 
  120#define GP_LOG_DATA(DATA, SIZE, MSG, ...) gp_log_data(__func__, DATA, SIZE, MSG, ##__VA_ARGS__) 
  122#elif defined(__GNUC__) &&  __GNUC__ >= 2 
  123#define GP_DEBUG(msg, params...) \ 
  124        gp_log(GP_LOG_DEBUG, GP_MODULE "/" __FILE__, msg, ##params) 
  130#define GP_LOG_D(...) gp_log(GP_LOG_DEBUG, __func__, __VA_ARGS__) 
  131#define GP_LOG_E(...) gp_log_with_source_location(GP_LOG_ERROR, __FILE__, __LINE__, __func__, __VA_ARGS__) 
  132#define GP_LOG_DATA(DATA, SIZE, MSG, ...) gp_log_data(__func__, DATA, SIZE, MSG, ##__VA_ARGS__) 
  136#  warning Disabling GP_DEBUG because variadic macros are not allowed 
  138#define GP_DEBUG (void) 
  141#define GP_LOG_DATA(DATA, SIZE, ...)  
  148#define gp_log_add_func(level, func, data) (0) 
  149#define gp_log_remove_func(id) (0) 
  150#define gp_log(level, domain, format, args...)  
  151#define gp_log_with_source_location(level, file, line, func, format, ...) 
  152#define gp_logv(level, domain, format, args)  
  153#define gp_log_data(domain, data, size)  
  155#ifdef _GPHOTO2_INTERNAL_CODE 
  156#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 
  160#define GP_LOG_DATA(DATA, SIZE, ...)  
  162#elif defined(__GNUC__) 
  163#define GP_DEBUG(msg, params...)  
  166#define GP_LOG_DATA(DATA, SIZE, ...)  
  168#define GP_DEBUG (void) 
  169#define GP_LOG_D (void  
  170#define GP_LOG_E (void)  
  171#define GP_LOG_DATA(void)  
  177#ifdef _GPHOTO2_INTERNAL_CODE 
  179typedef struct StringFlagItem {
 
  184typedef void (*string_item_func) (
const char *str, 
void *data);
 
  186const char * gpi_enum_to_string (
unsigned int _enum, 
const StringFlagItem *map);
 
  187int gpi_string_to_enum (
const char *str, 
unsigned int *result, 
const StringFlagItem *map);
 
  188void gpi_flags_to_string_list (
unsigned int flags, 
const StringFlagItem *map, string_item_func func, 
void *data);
 
  189int gpi_string_or_to_flags (
const char *str, 
unsigned int *flags, 
const StringFlagItem *map);
 
  190unsigned int gpi_string_to_flag (
const char *str, 
const StringFlagItem *map);
 
  191unsigned int gpi_string_list_to_flags (
const char *str[], 
const StringFlagItem *map);
 
  197__attribute__((__format__(printf,1,0)))
 
  200gpi_vsnprintf (
const char* format, va_list args);
 
  203__attribute__((__format__(printf,1,2)))
 
  206aprintf(
const char *fmt, ...)
 
  212        res = gpi_vsnprintf(fmt, ap);
 
  218#define C_MEM(MEM) do {\ 
  219        if ((MEM) == NULL) {\ 
  220                GP_LOG_E ("Out of memory: '%s' failed.", #MEM);\ 
  221                return GP_ERROR_NO_MEMORY;\ 
  225#define C_PARAMS(PARAMS) do {\ 
  227                GP_LOG_E ("Invalid parameters: '%s' is NULL/FALSE.", #PARAMS);\ 
  228                return GP_ERROR_BAD_PARAMETERS;\ 
  232#define C_PARAMS_MSG(PARAMS, MSG, ...) do {\ 
  234                GP_LOG_E ("Invalid parameters: " #MSG " ('%s' is NULL/FALSE.)", ##__VA_ARGS__, #PARAMS);\ 
  235                return GP_ERROR_BAD_PARAMETERS;\ 
void gp_logv(GPLogLevel level, const char *domain, const char *format, va_list args)
Log a debug or error message with va_list.
Definition gphoto2-port-log.c:301
int gp_log_remove_func(int id)
Remove a logging receiving function.
Definition gphoto2-port-log.c:130
void(* GPLogFunc)(GPLogLevel level, const char *domain, const char *str, void *data)
Logging function hook.
Definition gphoto2-port-log.h:65
void gp_log(GPLogLevel level, const char *domain, const char *format,...)
Log a debug or error message.
Definition gphoto2-port-log.c:341
int gp_log_add_func(GPLogLevel level, GPLogFunc func, void *data)
Add a function to get logging information.
Definition gphoto2-port-log.c:100
GPLogLevel
Logging level Specifies the logging severity level.
Definition gphoto2-port-log.h:34
@ GP_LOG_VERBOSE
Log message is an verbose debug information.
Definition gphoto2-port-log.h:36
@ GP_LOG_ERROR
Log message is an error information.
Definition gphoto2-port-log.h:35
@ GP_LOG_DATA
Log message is a data hex dump.
Definition gphoto2-port-log.h:38
@ GP_LOG_DEBUG
Log message is an debug information.
Definition gphoto2-port-log.h:37
void gp_log_data(const char *domain, const char *data, unsigned int size, const char *format,...)
Log data.
Definition gphoto2-port-log.c:203