libgphoto2 photo camera library (libgphoto2) API 2.5.2

- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

gphoto2-port-log.h
Go to the documentation of this file.
1
21 #ifndef __GPHOTO2_PORT_LOG_H__
22 #define __GPHOTO2_PORT_LOG_H__
23
24 #include <stdarg.h>
25
30 typedef enum {
31 GP_LOG_ERROR = 0,
32 GP_LOG_VERBOSE = 1,
33 GP_LOG_DEBUG = 2,
34 GP_LOG_DATA = 3
35 } GPLogLevel;
36
46 #define GP_LOG_ALL GP_LOG_DATA
47
61 typedef void (* GPLogFunc) (GPLogLevel level, const char *domain, const char *str, void *data);
62
63 #ifndef DISABLE_DEBUGGING
64
65 int gp_log_add_func (GPLogLevel level, GPLogFunc func, void *data);
66 int gp_log_remove_func (int id);
67
68 /* Logging */
69 void gp_log (GPLogLevel level, const char *domain,
70 const char *format, ...)
71 #ifdef __GNUC__
72 __attribute__((__format__(printf,3,4)))
73 #endif
74 ;
75 void gp_logv (GPLogLevel level, const char *domain, const char *format,
76 va_list args)
77 #ifdef __GNUC__
78 __attribute__((__format__(printf,3,0)))
79 #endif
80 ;
81 void gp_log_data (const char *domain, const char *data, unsigned int size);
82
83
84 /*
85 * GP_DEBUG:
86 * msg: message to log
87 * params: params to message
88 *
89 * Logs message at log level #GP_LOG_DEBUG by calling #gp_log() with
90 * an automatically generated domain
91 * You have to define GP_MODULE as "mymod" for your module
92 * mymod before using #GP_DEBUG().
93 */
94
95 #ifdef _GPHOTO2_INTERNAL_CODE
96 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
97 #define GP_DEBUG(...) \
98 gp_log(GP_LOG_DEBUG, GP_MODULE "/" __FILE__, __VA_ARGS__)
99 #elif defined(__GNUC__) && __GNUC__ >= 2
100 #define GP_DEBUG(msg, params...) \
101 gp_log(GP_LOG_DEBUG, GP_MODULE "/" __FILE__, msg, ##params)
102 #else
103 # ifdef __GNUC__
104 # warning Disabling GP_DEBUG because variadic macros are not allowed
105 # endif
106 #define GP_DEBUG (void)
107 #endif
108 #endif /* _GPHOTO2_INTERNAL_CODE */
109
110 #else /* DISABLE_DEBUGGING */
111
112 /* Stub these functions out if debugging is disabled */
113 #define gp_log_add_func(level, func, data) (0)
114 #define gp_log_remove_func(id) (0)
115 #define gp_log(level, domain, format, args...)
116 #define gp_logv(level, domain, format, args)
117 #define gp_log_data(domain, data, size)
118
119 #ifdef _GPHOTO2_INTERNAL_CODE
120 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
121 #define GP_DEBUG(...) /* no-op */
122 #elif defined(__GNUC__)
123 #define GP_DEBUG(msg, params...) /* no-op */
124 #else
125 #define GP_DEBUG (void)
126 #endif
127 #endif /* _GPHOTO2_INTERNAL_CODE */
128
129 #endif /* DISABLE_DEBUGGING */
130
131 #ifdef _GPHOTO2_INTERNAL_CODE
132
133 typedef struct StringFlagItem {
134 char *str;
135 unsigned int flag;
136 } StringFlagItem;
137
138 typedef void (*string_item_func) (const char *str, void *data);
139
140 const char *
141 gpi_enum_to_string(const unsigned int _enum,
142 const StringFlagItem *map);
143
144 int
145 gpi_string_to_enum(const char *str,
146 unsigned int *result,
147 const StringFlagItem *map);
148
149 void
150 gpi_flags_to_string_list(const unsigned int flags,
151 const StringFlagItem *map,
152 string_item_func func, void *data);
153
154 int
155 gpi_string_or_to_flags(const char *str,
156 unsigned int *flags,
157 const StringFlagItem *map);
158
159 unsigned int
160 gpi_string_to_flag(const char *str,
161 const StringFlagItem *map);
162
163 unsigned int
164 gpi_string_list_to_flags(const char *str[],
165 const StringFlagItem *map);
166
167 #endif /* _GPHOTO2_INTERNAL_CODE */
168
169
170 #endif /* __GPHOTO2_PORT_LOG_H__ */