From: Colin McCabe <cmcc...@cobalt.club.cc.cmu.edu>

Signed-off-by: Colin McCabe <cmcc...@alumni.cmu.edu>
---
 include/common.h |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/include/common.h b/include/common.h
index 52e5603..30610d8 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 CLD_DEBUG(cld_log, ...) \
+       if ((cld_log)->verbose) { \
+               (cld_log)->func(LOG_DEBUG, __VA_ARGS__); \
+       }
+
+/** Print out an informational log message */
+#define CLD_INFO(cld_log, ...) \
+       (cld_log)->func(LOG_INFO, __VA_ARGS__);
+
+/** Print out a warning message */
+#define CLD_WARN(cld_log, ...) \
+       (cld_log)->func(LOG_WARNING, __VA_ARGS__);
+
+/** Print out an error message */
+#define CLD_ERR(cld_log, ...) \
+       (cld_log)->func(LOG_ERR, __VA_ARGS__);
+
+/** Print out a critical warning message */
+#define CLD_CRIT(cld_log, ...) \
+       (cld_log)->func(LOG_CRIT, __VA_ARGS__);
+
+struct cld_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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to