summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common.c11
-rw-r--r--common.h31
2 files changed, 32 insertions, 10 deletions
diff --git a/common.c b/common.c
index c460815..540cec5 100644
--- a/common.c
+++ b/common.c
@@ -45,8 +45,19 @@ void mbox_log_console(int p, const char *fmt, va_list args)
__attribute__((format(printf, 2, 3)))
void mbox_log(int p, const char *fmt, ...)
{
+ static bool warned = false;
va_list args;
+ if (!mbox_vlog) {
+ if (!warned) {
+ fprintf(stderr, "Logging backend not configured, "
+ "log output disabled\n");
+ warned = true;
+ }
+
+ return;
+ }
+
va_start(args, fmt);
mbox_vlog(p, fmt, args);
va_end(args);
diff --git a/common.h b/common.h
index 90a0fc9..20dbf1a 100644
--- a/common.h
+++ b/common.h
@@ -26,23 +26,34 @@
#endif
enum verbose {
- MBOX_LOG_NONE = 0,
- MBOX_LOG_INFO = 1,
- MBOX_LOG_DEBUG = 2
+ MBOX_LOG_NONE = 0,
+ MBOX_LOG_INFO = 1,
+ MBOX_LOG_DEBUG = 2
};
extern enum verbose verbosity;
/* Error Messages */
-#define MSG_ERR(f_, ...) mbox_log(LOG_ERR, f_, ##__VA_ARGS__)
+#define MSG_ERR(f_, ...) \
+do { \
+ mbox_log(LOG_ERR, f_, ##__VA_ARGS__); \
+} while (0)
+
/* Informational Messages */
-#define MSG_INFO(f_, ...) do { if (verbosity >= MBOX_LOG_INFO) { \
- mbox_log(LOG_INFO, f_, ##__VA_ARGS__); \
- } } while (0)
+#define MSG_INFO(f_, ...) \
+do { \
+ if (verbosity >= MBOX_LOG_INFO) { \
+ mbox_log(LOG_INFO, f_, ##__VA_ARGS__); \
+ } \
+} while (0)
+
/* Debug Messages */
-#define MSG_DBG(f_, ...) do { if (verbosity >= MBOX_LOG_DEBUG) { \
- mbox_log(LOG_DEBUG, f_, ##__VA_ARGS__); \
- } } while(0)
+#define MSG_DBG(f_, ...) \
+do { \
+ if (verbosity >= MBOX_LOG_DEBUG) { \
+ mbox_log(LOG_DEBUG, f_, ##__VA_ARGS__); \
+ } \
+} while(0)
extern void (*mbox_vlog)(int p, const char *fmt, va_list args);
OpenPOWER on IntegriCloud