X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=daemon.c;h=1fff16beb39ee71a5244ad2b38f3855306270da7;hb=08471ab23c0abdf0ddd7ff836a15bd81fbce7520;hp=04dbc122386274110975bb155a5686ef9520f940;hpb=a0cd2ac59b891751067512dce77cf6223104932f;p=paraslash.git diff --git a/daemon.c b/daemon.c index 04dbc122..1fff16be 100644 --- a/daemon.c +++ b/daemon.c @@ -64,18 +64,24 @@ static void daemon_set_default_log_colors(void) */ void daemon_set_log_color_or_die(const char *arg) { + unsigned ll; + const char * const sev[] = {SEVERITIES}; char *p = strchr(arg, ':'); - int ret, ll; if (!p) goto err; - ret = get_loglevel_by_name(arg); - if (ret < 0) - goto err; - ll = ret; - p++; - color_parse_or_die(p, me->log_colors[ll]); - return; + for (ll = 0; ll < NUM_LOGLEVELS; ll++) { + const char *name = sev[ll]; + /* + * Parse only the first part of the string so that, for + * example, the argument "info:something_else" is recognized. + * Note that the string comparison is performed + * case-insensitively. + */ + if (strncasecmp(arg, name, strlen(name))) + continue; + return color_parse_or_die(p + 1, me->log_colors[ll]); + } err: PARA_EMERG_LOG("%s: invalid color argument\n", arg); exit(EXIT_FAILURE); @@ -146,7 +152,17 @@ void daemon_set_loglevel(int loglevel) assert(loglevel >= 0); assert(loglevel < NUM_LOGLEVELS); me->loglevel = loglevel; +} +/** + * Get the current log level of the daemon. + * + * \return Greater or equal than zero and less than NUM_LOGLEVELS. This + * function never fails. + */ +int daemon_get_loglevel(void) +{ + return me->loglevel; } /**