Signed-off-by: Colin McCabe <cmccabe@xxxxxxxxxxxxxx> --- include/common.h | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/include/common.h b/include/common.h index 52e5603..f6ad4f6 100644 --- a/include/common.h +++ b/include/common.h @@ -8,4 +8,31 @@ void __cld_rand64(void *p); const char *cld_errstr(enum cle_err_codes ecode); int cld_readport(const char *fname); +/** Print out a debug message if 'verbose' is enabled */ +#define HAIL_DEBUG(log, ...) \ + if ((log)->verbose) { \ + (log)->func(LOG_DEBUG, __VA_ARGS__); \ + } + +/** Print out an informational log message */ +#define HAIL_INFO(log, ...) \ + (log)->func(LOG_INFO, __VA_ARGS__); + +/** Print out a warning message */ +#define HAIL_WARN(log, ...) \ + (log)->func(LOG_WARNING, __VA_ARGS__); + +/** Print out an error message */ +#define HAIL_ERR(log, ...) \ + (log)->func(LOG_ERR, __VA_ARGS__); + +/** Print out a critical warning message */ +#define HAIL_CRIT(log, ...) \ + (log)->func(LOG_CRIT, __VA_ARGS__); + +struct hail_log { + void (*func)(int prio, const char *fmt, ...); + bool verbose; +}; + #endif /* __CLD_COMMON_H__ */ -- 1.6.2.5 -- To unsubscribe from this list: send the line "unsubscribe hail-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html