X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Finclude%2Futils%2Ferror.h;h=d00ee8c0f980b5abf8590b99f073a3344d0cdb1b;hb=HEAD;hp=2c3df32ff48a98c2fe7f26e03fe1593c55acbb82;hpb=f78d30d42f9fe3b58f1c2132cafe4c8687b8bd46;p=sysdb.git diff --git a/src/include/utils/error.h b/src/include/utils/error.h index 2c3df32..d00ee8c 100644 --- a/src/include/utils/error.h +++ b/src/include/utils/error.h @@ -37,6 +37,7 @@ #ifndef SDB_UTILS_ERROR_H #define SDB_UTILS_ERROR_H 1 +#include #include #ifdef __cplusplus @@ -61,6 +62,10 @@ enum { : ((prio) == SDB_LOG_INFO) ? "INFO" \ : ((prio) == SDB_LOG_DEBUG) ? "DEBUG" : "UNKNOWN") +#ifndef SDB_DEFAULT_LOGLEVEL +# define SDB_DEFAULT_LOGLEVEL SDB_LOG_INFO +#endif + /* * sdb_error_set_logger: * Set the logging callback to be used for logging messages. By default (or @@ -71,7 +76,7 @@ void sdb_error_set_logger(int (*f)(int, const char *)); /* - * sdb_log: + * sdb_log, sdb_vlog: * Log the specified message. The string will be formatted in printf-style * using the specified format and arguments and logged with the specified * priority. In addition, the error message will be stored as the current @@ -82,6 +87,8 @@ sdb_error_set_logger(int (*f)(int, const char *)); int sdb_log(int prio, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +int +sdb_vlog(int prio, const char *fmt, va_list ap); /* * sdb_error_set, sdb_error_append: @@ -128,6 +135,17 @@ sdb_error_get(void); int sdb_error_get_prio(void); +/* + * sdb_error_parse_priority: + * Parse the name of a log priority. + * + * Returns: + * - the numeric log priority on success + * - a negative value else + */ +int +sdb_error_parse_priority(char *prio); + /* * sdb_strerror: * This is a wrapper around the system's strerror function which ensures that