summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 760cef6)
raw | patch | inline | side by side (parent: 760cef6)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 1 Feb 2015 09:36:18 +0000 (10:36 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 1 Feb 2015 14:00:36 +0000 (15:00 +0100) |
src/include/utils/error.h | patch | blob | history | |
src/utils/error.c | patch | blob | history |
index 49034eb2544381061583c33d4174e9fb9089e80e..ae653af2ce6250ea75a039def23b3fac1d6b7ddd 100644 (file)
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
diff --git a/src/utils/error.c b/src/utils/error.c
index f940be6d232b05eb5eceff1b08f6aa13d62642ac..2bc99013ebe719199b7f53b2665f5e43dd7a95ae 100644 (file)
--- a/src/utils/error.c
+++ b/src/utils/error.c
return ctx->prio;
} /* sdb_error_get_prio */
+int
+sdb_error_parse_priority(char *prio)
+{
+ if (! strcasecmp(prio, "EMERG"))
+ return SDB_LOG_EMERG;
+ else if (! strcasecmp(prio, "ERROR"))
+ return SDB_LOG_ERR;
+ else if (! strcasecmp(prio, "WARNING"))
+ return SDB_LOG_WARNING;
+ else if (! strcasecmp(prio, "NOTICE"))
+ return SDB_LOG_NOTICE;
+ else if (! strcasecmp(prio, "INFO"))
+ return SDB_LOG_INFO;
+ else if (! strcasecmp(prio, "DEBUG"))
+ return SDB_LOG_DEBUG;
+ return -1;
+} /* sdb_error_parse_priority */
+
char *
sdb_strerror(int errnum, char *strerrbuf, size_t buflen)
{