--- common/log.h | 59 ++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/common/log.h b/common/log.h index b83b0e0..8520b42 100644 --- a/common/log.h +++ b/common/log.h @@ -47,47 +47,52 @@ void spice_log(const char *log_domain, const char *format, ...) SPICE_ATTR_PRINTF(5, 6); -#define spice_return_if_fail(x) G_STMT_START { \ - if G_LIKELY(x) { } else { \ - spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_CRITICAL, SPICE_STRLOC, G_STRFUNC, "condition `%s' failed", #x); \ - return; \ - } \ + +#define SPICE_LOG(level, format, ...) G_STMT_START { \ + spice_log(SPICE_LOG_DOMAIN, \ + (level), \ + SPICE_STRLOC, \ + G_STRFUNC, \ + format, \ + ## __VA_ARGS__); \ } G_STMT_END -#define spice_return_val_if_fail(x, val) G_STMT_START { \ - if G_LIKELY(x) { } else { \ - spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__, "condition `%s' failed", #x); \ - return (val); \ - } \ +#define spice_return_if_fail(x) G_STMT_START { \ + if G_LIKELY(x) { } else { \ + SPICE_LOG(SPICE_LOG_LEVEL_CRITICAL, "condition `%s' failed", #x); \ + return; \ + } \ } G_STMT_END -#define spice_warn_if_reached() G_STMT_START { \ - spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_WARNING, SPICE_STRLOC, __FUNCTION__, "should not be reached"); \ +#define spice_return_val_if_fail(x, val) G_STMT_START { \ + if G_LIKELY(x) { } else { \ + SPICE_LOG(SPICE_LOG_LEVEL_CRITICAL, "condition `%s' failed", #x); \ + return (val); \ + } \ } G_STMT_END + +#define spice_warn_if_reached() \ + SPICE_LOG(SPICE_LOG_LEVEL_WARNING, "should not be reached") + #define spice_printerr(format, ...) G_STMT_START { \ fprintf(stderr, "%s: " format "\n", __FUNCTION__, ## __VA_ARGS__); \ } G_STMT_END -#define spice_info(format, ...) G_STMT_START { \ - spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_INFO, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \ -} G_STMT_END +#define spice_info(format, ...) \ + SPICE_LOG(SPICE_LOG_LEVEL_INFO, format, ## __VA_ARGS__) -#define spice_debug(format, ...) G_STMT_START { \ - spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_DEBUG, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \ -} G_STMT_END +#define spice_debug(format, ...) \ + SPICE_LOG(SPICE_LOG_LEVEL_DEBUG, format, ## __VA_ARGS__) -#define spice_warning(format, ...) G_STMT_START { \ - spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_WARNING, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \ -} G_STMT_END +#define spice_warning(format, ...) \ + SPICE_LOG(SPICE_LOG_LEVEL_WARNING, format, ## __VA_ARGS__) -#define spice_critical(format, ...) G_STMT_START { \ - spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \ -} G_STMT_END +#define spice_critical(format, ...) \ + SPICE_LOG(SPICE_LOG_LEVEL_CRITICAL, format, ## __VA_ARGS__) -#define spice_error(format, ...) G_STMT_START { \ - spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_ERROR, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \ -} G_STMT_END +#define spice_error(format, ...) \ + SPICE_LOG(SPICE_LOG_LEVEL_ERROR, format, ## __VA_ARGS__) #define spice_warn_if_fail(x) G_STMT_START { \ if G_LIKELY(x) { } else { \ -- 2.5.0 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel