--- common/log.h | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/common/log.h b/common/log.h index ed9371b..4be201d 100644 --- a/common/log.h +++ b/common/log.h @@ -47,47 +47,50 @@ void spice_log(const char *log_domain, const char *format, ...) SPICE_ATTR_PRINTF(5, 6); + +#define SPICE_LOG(domain, level, format, ...) G_STMT_START { \ + spice_log((domain), (level), SPICE_STRLOC, G_STRFUNC, \ + format, ## __VA_ARGS__); \ +} G_STMT_END + #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); \ + SPICE_LOG(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_CRITICAL, \ + "condition `%s' failed", #x); \ return; \ } \ } 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); \ + SPICE_LOG(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_CRITICAL, \ + "condition `%s' failed", #x); \ return (val); \ } \ } 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"); \ -} G_STMT_END + +#define spice_warn_if_reached() \ + SPICE_LOG(SPICE_LOG_DOMAIN, 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_DOMAIN, 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_DOMAIN, 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_DOMAIN, 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_DOMAIN, 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_DOMAIN, 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