aboutsummaryrefslogtreecommitdiff
path: root/libwmc/src/errors.h
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2011-09-27 15:31:45 -0500
committerDan Williams <dcbw@redhat.com>2011-09-27 15:33:53 -0500
commit368b80886912cf9f03ed535bba1c426466461195 (patch)
tree3939408c918e0fde931cd348178075c3382854bf /libwmc/src/errors.h
parent8710820156f51d1861b329e6fc12e706304ddda9 (diff)
libwmc: simpler logging and error handling
Diffstat (limited to 'libwmc/src/errors.h')
-rw-r--r--libwmc/src/errors.h53
1 files changed, 25 insertions, 28 deletions
diff --git a/libwmc/src/errors.h b/libwmc/src/errors.h
index aebe40f2..f9346df9 100644
--- a/libwmc/src/errors.h
+++ b/libwmc/src/errors.h
@@ -23,35 +23,18 @@
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
-#include <stdio.h>
-
-typedef u_int8_t wbool;
-#ifndef TRUE
-#define TRUE (u_int8_t) 1
-#endif
-#ifndef FALSE
-#define FALSE (u_int8_t) 0
-#endif
-
-typedef struct {
- u_int32_t domain;
- u_int32_t code;
- char *message;
-} WmcError;
-
-WmcError *wmc_error_new (u_int32_t domain,
- u_int32_t code,
- const char *format,
- ...) __attribute__((__format__ (__printf__, 3, 4)));
-void wmc_error_set (WmcError **error,
- u_int32_t domain,
- u_int32_t code,
- const char *format,
- ...) __attribute__((__format__ (__printf__, 4, 5)));
+enum {
+ LOGL_ERR = 0x00000001,
+ LOGL_WARN = 0x00000002,
+ LOGL_INFO = 0x00000004,
+ LOGL_DEBUG = 0x00000008
+};
-void wmc_clear_error (WmcError **error);
-void wmc_free_error (WmcError *error);
+enum {
+ WMC_SUCCESS = 0,
+ WMC_ERROR_SERIAL_CONFIG_FAILED = 1,
+};
#define wmc_assert assert
@@ -71,4 +54,18 @@ void wmc_free_error (WmcError *error);
} \
}
-#endif /* LIBWMC_COM_H */
+void _wmc_log (const char *file,
+ int line,
+ const char *func,
+ int domain,
+ int level,
+ const char *format,
+ ...) __attribute__((__format__ (__printf__, 6, 7)));
+
+#define wmc_dbg(domain, ...) \
+ _wmc_log (__FILE__, __LINE__, __func__, domain, LOGL_DEBUG, ## __VA_ARGS__ )
+
+#define wmc_err(domain, ...) \
+ _wmc_log (__FILE__, __LINE__, __func__, domain, LOGL_ERR, ## __VA_ARGS__ )
+
+#endif /* LIBWMC_ERRORS_H */