X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=daemon.c;h=3bcb6e019a442ddf7a8709759937a7d2bd603bf6;hp=2f706b01bde62c8821dc76e66ad387a905782d91;hb=ddd7cd853044105f329a2c70cce2d8f1470f559e;hpb=ae657a3b13b4ff76187dad39fede40b98d7cb6d7 diff --git a/daemon.c b/daemon.c index 2f706b01..3bcb6e01 100644 --- a/daemon.c +++ b/daemon.c @@ -58,25 +58,6 @@ void daemon_set_default_log_colors(void) } } -static int get_loglevel_by_name(const char *txt, size_t n) -{ - if (!strncasecmp(txt, "debug", n)) - return LL_DEBUG; - if (!strncasecmp(txt, "info", n)) - return LL_INFO; - if (!strncasecmp(txt, "notice", n)) - return LL_NOTICE; - if (!strncasecmp(txt, "warning", n)) - return LL_WARNING; - if (!strncasecmp(txt, "error", n)) - return LL_ERROR; - if (!strncasecmp(txt, "crit", n)) - return LL_CRIT; - if (!strncasecmp(txt, "emerg", n)) - return LL_EMERG; - return -1; -} - /** * Set the color for one loglevel. * @@ -93,7 +74,7 @@ int daemon_set_log_color(char const *arg) if (!p) goto err; - ret = get_loglevel_by_name(arg, p - arg); + ret = get_loglevel_by_name(arg); if (ret < 0) goto err; ll = ret; @@ -122,13 +103,16 @@ void daemon_set_logfile(char *logfile_name) } /** - * Supress log messages with severity lower than the given loglevel. + * Suppress log messages with severity lower than the given loglevel. * * \param loglevel The smallest level that should be logged. */ -void daemon_set_loglevel(int loglevel) +void daemon_set_loglevel(char *loglevel) { - me->loglevel = loglevel; + int ret = get_loglevel_by_name(loglevel); + + assert(ret >= 0); + me->loglevel = ret; } /** @@ -183,7 +167,6 @@ void daemonize(void) goto err; if (chdir("/") < 0) goto err; - umask(0); null = open("/dev/null", O_RDONLY); if (null < 0) goto err; @@ -234,11 +217,10 @@ void daemon_open_log_or_die(void) /** * Log the startup message containing the paraslash version. */ -void log_welcome(const char *whoami, int loglevel) +void log_welcome(const char *whoami) { PARA_INFO_LOG("welcome to %s " PACKAGE_VERSION " ("BUILD_DATE")\n", whoami); - PARA_DEBUG_LOG("using loglevel %d\n", loglevel); } /** @@ -301,7 +283,7 @@ void drop_privileges_or_die(const char *username, const char *groupname) * set_or_get equal to \p UPTIME_GET return the uptime. * \return Zero if called with \a set_or_get equal to \p UPTIME_SET, the number - * of seconds ellapsed since the last reset otherwise. + * of seconds elapsed since the last reset otherwise. * * \sa time(2), difftime(3). */