[debug] add new 'logging level' command to set loglevel more user friendly
diff --git a/openbsc/src/debug.c b/openbsc/src/debug.c
index 1aad133..acfcba3 100644
--- a/openbsc/src/debug.c
+++ b/openbsc/src/debug.c
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <strings.h>
 #include <time.h>
+#include <errno.h>
 
 #include <openbsc/debug.h>
 #include <openbsc/talloc.h>
@@ -99,6 +100,33 @@
 	DEBUG_CATEGORY(DDB, "DREF", "", "")
 };
 
+static const struct value_string loglevel_strs[] = {
+	{ 0,	"EVERYTHING" },
+	{ 1,	"DEBUG" },
+	{ 3,	"INFO" },
+	{ 5,	"NOTICE" },
+	{ 7,	"ERROR" },
+	{ 8,	"FATAL" },
+	{ 0, NULL },
+};
+
+int debug_parse_level(const char *lvl)
+{
+	return get_string_value(loglevel_strs, lvl);
+}
+
+int debug_parse_category(const char *category)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(debug_info); ++i) {
+		if (!strcasecmp(debug_info[i].name+1, category))
+			return debug_info[i].number;
+	}
+
+	return -EINVAL;
+}
+
 /*
  * Parse the category mask.
  * The format can be this: category1:category2:category3