From c588513154f287bb5ce3766c39696a9c4a16f149 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 17 Dec 2014 23:07:42 -0500 Subject: do away with configuring the log level --- man/nslcd.8.xml.in | 17 ----------------- man/nslcd.conf.5.xml.in | 18 ------------------ nslcd/cfg.c | 40 ---------------------------------------- nslcd/log.c | 46 +++++++++------------------------------------- nslcd/log.h | 6 ------ nslcd/nslcd.c | 8 -------- 6 files changed, 9 insertions(+), 126 deletions(-) diff --git a/man/nslcd.8.xml.in b/man/nslcd.8.xml.in index 4e4e521..c31a0d9 100644 --- a/man/nslcd.8.xml.in +++ b/man/nslcd.8.xml.in @@ -75,23 +75,6 @@ nslcd accepts the following options: - - - , - - - - Enable debugging mode. - nslcd will not put itself in the background and sends - verbose debugging info to stderr. - nslcd will handle connections as usual. - This option is for debugging purposes only. - Specify this option multiple times to also include more detailed logging - from the LDAP library. - - - - diff --git a/man/nslcd.conf.5.xml.in b/man/nslcd.conf.5.xml.in index 42b6cfb..8149fd7 100644 --- a/man/nslcd.conf.5.xml.in +++ b/man/nslcd.conf.5.xml.in @@ -85,24 +85,6 @@ - - LEVEL - - - This option controls the way logging is done. - The LEVEL argument specifies - the log level. - The log level may be one of: crit, - error, warning, - notice, info or - debug. The default log level is info. - All messages with the specified loglevel or higher are logged. - This option can be supplied multiple times. - If this option is omitted info is assumed. - - - - diff --git a/nslcd/cfg.c b/nslcd/cfg.c index dc31c6b..c9a691f 100644 --- a/nslcd/cfg.c +++ b/nslcd/cfg.c @@ -194,41 +194,6 @@ static const char *print_boolean(bool val) else return "no"; } -static int parse_loglevel(const char *filename, int lnr, const char *value) -{ - if (strcasecmp(value, "crit") == 0) - return LOG_CRIT; - else if ((strcasecmp(value, "error") == 0) || (strcasecmp(value, "err") == 0)) - return LOG_ERR; - else if (strcasecmp(value, "warning")==0) - return LOG_WARNING; - else if (strcasecmp(value, "notice")==0) - return LOG_NOTICE; - else if (strcasecmp(value, "info")==0) - return LOG_INFO; - else if (strcasecmp(value, "debug")==0) - return LOG_DEBUG; - else - { - log_log(LOG_ERR, "%s:%d: not a log level '%s'", - filename, lnr, value); - exit(EXIT_FAILURE); - } -} - -static void handle_log(const char *filename, int lnr, - const char *keyword, char *line) -{ - int level = LOG_INFO; - char loglevel[32]; - check_argumentcount(filename, lnr, keyword, - get_token(&line, loglevel, sizeof(loglevel)) != NULL); - if (get_token(&line, loglevel, sizeof(loglevel)) != NULL) - level = parse_loglevel(filename, lnr, loglevel); - get_eol(filename, lnr, keyword, &line); - log_setdefaultloglevel(level); -} - static enum nss_map_selector parse_map(const char *value) { if ((strcasecmp(value, "alias") == 0) || (strcasecmp(value, "aliases") == 0)) @@ -515,10 +480,6 @@ static void cfg_read(const char *filename, struct nslcd_config *cfg) cfg->threads = get_int(filename, lnr, keyword, &line); get_eol(filename, lnr, keyword, &line); } - else if (strcasecmp(keyword, "log") == 0) - { - handle_log(filename, lnr, keyword, line); - } /* general connection options */ else if (strcasecmp(keyword, "yamldir") == 0) { @@ -577,7 +538,6 @@ static void cfg_dump(void) const char **strp; char buffer[1024]; log_log(LOG_DEBUG, "CFG: threads %d", nslcd_cfg->threads); - log_log_config(); if (nslcd_cfg->nss_initgroups_ignoreusers != NULL) { diff --git a/nslcd/log.c b/nslcd/log.c index f24abd5..56b5936 100644 --- a/nslcd/log.c +++ b/nslcd/log.c @@ -36,8 +36,6 @@ #include "log.h" -static int loglevel = LOG_DEBUG; - #define MAX_REQUESTID_LENGTH 40 #ifdef TLS @@ -62,12 +60,6 @@ static void tls_init_keys(void) #endif /* no TLS, use pthreads */ -/* set loglevel when no logging is configured */ -void log_setdefaultloglevel(int pri) -{ - loglevel = pri; -} - static char *loglevel2sd(int pri) { switch(pri) { case LOG_EMERG: return SD_EMERG; @@ -176,36 +168,16 @@ void log_log(int pri, const char *format, ...) fprintf(stderr, SD_ERR "vasprintf() in logger failed"); } va_end(ap); - /* do the logging */ - - if (pri <= loglevel) - { - if ((requestid != NULL) && (requestid[0] != '\0')) - fprintf(stderr, "%s[sess:%s] %s\n", loglevel2sd(pri), sessionid, requestid, msg); - else if ((sessionid != NULL) && (sessionid[0] != '\0')) - fprintf(stderr, "%s[sess:%s] %s\n", loglevel2sd(pri), sessionid, msg); - else - fprintf(stderr, "%s%s\n", loglevel2sd(pri), msg); - fflush(stderr); } - free(msg); -} - -static const char *loglevel2str(int loglevel) -{ - switch (loglevel) - { - case LOG_CRIT: return "crit"; - case LOG_ERR: return "error"; - case LOG_WARNING: return "warning"; - case LOG_NOTICE: return "notice"; - case LOG_INFO: return "info"; - case LOG_DEBUG: return "debug"; - default: return "???"; - } -} + /* do the logging */ + if ((requestid != NULL) && (requestid[0] != '\0')) + fprintf(stderr, "%s[sess:%s] %s\n", loglevel2sd(pri), sessionid, requestid, msg); + else if ((sessionid != NULL) && (sessionid[0] != '\0')) + fprintf(stderr, "%s[sess:%s] %s\n", loglevel2sd(pri), sessionid, msg); + else + fprintf(stderr, "%s%s\n", loglevel2sd(pri), msg); + fflush(stderr); -void log_log_config(void) { - log_log(LOG_DEBUG, "CFG: log %s", loglevel2str(loglevel)); + free(msg); } diff --git a/nslcd/log.h b/nslcd/log.h index d86ef8c..8614077 100644 --- a/nslcd/log.h +++ b/nslcd/log.h @@ -34,9 +34,6 @@ #define LOG_INFO 6 #define LOG_DEBUG 7 -/* set loglevel when no logging is configured */ -void log_setdefaultloglevel(int loglevel); - /* indicate that a session id should be included in the output and set it to a new value */ void log_newsession(void); @@ -54,7 +51,4 @@ void log_setrequest(const char *format, ...) void log_log(int pri, const char *format, ...) LIKE_PRINTF(2, 3); -/* log the logger config at the LOG_DEBUG level */ -void log_log_config(void); - #endif /* not NSLCD__LOG_H */ diff --git a/nslcd/nslcd.c b/nslcd/nslcd.c index 1b2ecf7..c0cf90e 100644 --- a/nslcd/nslcd.c +++ b/nslcd/nslcd.c @@ -79,9 +79,6 @@ #define WRITEBUFFER_MINSIZE 1024 #define WRITEBUFFER_MAXSIZE 1 * 1024 * 1024 -/* flag to indicate if we are in debugging mode */ -static int nslcd_debugging = 0; - /* the flag to indicate that a signal was received */ static volatile int nslcd_receivedsignal = 0; @@ -106,7 +103,6 @@ static void display_usage(FILE *fp, const char *program_name) { fprintf(fp, "Usage: %s [OPTION]...\n", program_name); fprintf(fp, "Name Service LDAP connection daemon.\n"); - fprintf(fp, " -d, --debug print debugging to stderr\n"); fprintf(fp, " --help display this help and exit\n"); fprintf(fp, " --version output version information and exit\n"); fprintf(fp, "\n" "Report bugs to <%s>.\n", PACKAGE_BUGREPORT); @@ -129,10 +125,6 @@ static void parse_cmdline(int argc, char *argv[]) { switch (optc) { - case 'd': /* -d, --debug print debugging to stderr */ - nslcd_debugging++; - log_setdefaultloglevel(LOG_DEBUG); - break; case 'h': /* --help display this help and exit */ display_usage(stdout, argv[0]); exit(EXIT_SUCCESS); -- cgit v1.2.3