00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _VMTOOLS_LOG_H_
00020 #define _VMTOOLS_LOG_H_
00021
00136 #if !defined(G_LOG_DOMAIN)
00137 # error "G_LOG_DOMAIN must be defined."
00138 #endif
00139
00140 #include <glib.h>
00141
00142 #if defined(__GNUC__)
00143 # define FUNC __func__
00144 #else
00145 # define FUNC __FUNCTION__
00146 #endif
00147
00148
00149
00150
00160 #if !defined(g_info)
00161 # define g_info(fmt, ...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, fmt, ## __VA_ARGS__)
00162 #endif
00163
00165 #ifdef VMX86_DEBUG
00166 #define VMTOOLS_LOGGING_LEVEL_DEFAULT "info"
00167 #else
00168 #define VMTOOLS_LOGGING_LEVEL_DEFAULT "message"
00169 #endif
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191 #if defined(_WIN32) && GLIB_CHECK_VERSION(2, 46, 0)
00192 static inline void
00193 g_critical_inline(const gchar *fmt,
00194 ...)
00195 {
00196 va_list args;
00197 va_start(args, fmt);
00198 g_logv(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, fmt, args);
00199 va_end(args);
00200 }
00201
00202
00203
00204
00215 #define vm_critical(fmt, ...) g_critical_inline("%s: " fmt, FUNC, ## __VA_ARGS__)
00216
00217 static inline void
00218 g_debug_inline(const gchar *fmt,
00219 ...)
00220 {
00221 va_list args;
00222 va_start(args, fmt);
00223 g_logv(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, fmt, args);
00224 va_end(args);
00225 }
00226
00228 #define vm_debug(fmt, ...) g_debug_inline("%s: " fmt, FUNC, ## __VA_ARGS__)
00229
00230 static inline void
00231 g_error_inline(const gchar *fmt,
00232 ...)
00233 {
00234 va_list args;
00235 va_start(args, fmt);
00236 g_logv(G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, fmt, args);
00237 va_end(args);
00238 }
00239
00241 #define vm_error(fmt, ...) g_error_inline("%s: " fmt, FUNC, ## __VA_ARGS__)
00242
00243
00244 static inline void
00245 g_info_inline(const gchar *fmt,
00246 ...)
00247 {
00248 va_list args;
00249 va_start(args, fmt);
00250 g_logv(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, fmt, args);
00251 va_end(args);
00252 }
00253
00255 #define vm_info(fmt, ...) g_info_inline("%s: " fmt, FUNC, ## __VA_ARGS__)
00256
00257 static inline void
00258 g_message_inline(const gchar *fmt,
00259 ...)
00260 {
00261 va_list args;
00262 va_start(args, fmt);
00263 g_logv(G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, fmt, args);
00264 va_end(args);
00265 }
00266
00268 #define vm_message(fmt, ...) g_message_inline("%s: " fmt, FUNC, ## __VA_ARGS__)
00269
00270 static inline void
00271 g_warning_inline(const gchar *fmt,
00272 ...)
00273 {
00274 va_list args;
00275 va_start(args, fmt);
00276 g_logv(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, fmt, args);
00277 va_end(args);
00278 }
00279
00281 #define vm_warning(fmt, ...) g_warning_inline("%s: " fmt, FUNC, ## __VA_ARGS__)
00282
00283 #else // ! (windows & glib >= 2.46)
00284
00285
00286
00287
00298 #define vm_critical(fmt, ...) g_critical("%s: " fmt, FUNC, ## __VA_ARGS__)
00299
00301 #define vm_debug(fmt, ...) g_debug("%s: " fmt, FUNC, ## __VA_ARGS__)
00302
00304 #define vm_error(fmt, ...) g_error("%s: " fmt, FUNC, ## __VA_ARGS__)
00305
00307 #define vm_info(fmt, ...) g_info("%s: " fmt, FUNC, ## __VA_ARGS__)
00308
00310 #define vm_message(fmt, ...) g_message("%s: " fmt, FUNC, ## __VA_ARGS__)
00311
00313 #define vm_warning(fmt, ...) g_warning("%s: " fmt, FUNC, ## __VA_ARGS__)
00314 #endif // ! (windows & glib >= 2.46)
00315
00316
00317 G_BEGIN_DECLS
00318
00319 void
00320 VMTools_ConfigLogToStdio(const gchar *domain);
00321
00322 void
00323 VMTools_ConfigLogging(const gchar *defaultDomain,
00324 GKeyFile *cfg,
00325 gboolean force,
00326 gboolean reset);
00327
00328 G_END_DECLS
00329
00332 #endif
00333