index 73b48baacf2c1cdf9f5df66118166fc90c6df408..e170a7d5e85109406a15af21d4247daa27cd0083 100644 (file)
* will use its own memory region to store information about the last reported
* error.
* Once the error message has been passed to SysDB, it will log the entire
- * message at once. XXX: currently, SysDB only supports printing the error to
- * the standard error channel; support for other logging backends will be
- * added later in a modular fashion.
+ * message at once. The message will be sent to all registered log functions.
*/
#ifndef SDB_UTILS_ERROR_H
#define SDB_UTILS_ERROR_H 1
+#include <stddef.h>
+
#ifdef __cplusplus
extern "C" {
#endif
: ((prio) == SDB_LOG_INFO) ? "INFO" \
: ((prio) == SDB_LOG_DEBUG) ? "DEBUG" : "UNKNOWN")
+/*
+ * sdb_error_set_logger:
+ * Set the logging callback to be used for logging messages. By default (or
+ * when explicitely setting the logger to NULL), logs will be written to the
+ * stderr channel.
+ */
+void
+sdb_error_set_logger(int (*f)(int, const char *));
+
/*
* sdb_log:
* Log the specified message. The string will be formatted in printf-style
int
sdb_error_append(const char *fmt, ...);
+/*
+ * sdb_error_chomp:
+ * Remove all consecutive newline characters at the end of the error message.
+ */
+int
+sdb_error_chomp(void);
+
/*
* sdb_error_log:
* Log the current error message with the specified priority. See sdb_log for
int
sdb_error_get_prio(void);
+/*
+ * sdb_strerror:
+ * This is a wrapper around the system's strerror function which ensures that
+ * a pointer to the formatted error message is returned.
+ */
+char *
+sdb_strerror(int errnum, char *strerrbuf, size_t buflen);
+
#ifdef __cplusplus
} /* extern "C" */
#endif