From fce9ecb95298cbcb10290f16e9be3d23fbad68b9 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Fri, 9 Aug 2002 08:11:37 +0000 Subject: [PATCH] Allow setting the log level (for the error log, not the access log) from the config file. svn path=/trunk/icecast/; revision=3774 --- conf/icecast.xml | 1 + src/config.c | 8 +++++++- src/config.h | 1 + src/main.c | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/conf/icecast.xml b/conf/icecast.xml index dcdc963c..b5d4b067 100644 --- a/conf/icecast.xml +++ b/conf/icecast.xml @@ -38,6 +38,7 @@ access.log error.log + 4 diff --git a/src/config.c b/src/config.c index ff659be0..48f18127 100644 --- a/src/config.c +++ b/src/config.c @@ -19,6 +19,7 @@ #define CONFIG_DEFAULT_PORT 8888 #define CONFIG_DEFAULT_ACCESS_LOG "access.log" #define CONFIG_DEFAULT_ERROR_LOG "error.log" +#define CONFIG_DEFAULT_LOG_LEVEL 4 #define CONFIG_DEFAULT_CHROOT 0 #define CONFIG_DEFAULT_CHUID 0 #define CONFIG_DEFAULT_USER NULL @@ -151,6 +152,7 @@ static void _set_defaults(void) _configuration.log_dir = (char *)strdup(CONFIG_DEFAULT_LOG_DIR); _configuration.access_log = (char *)strdup(CONFIG_DEFAULT_ACCESS_LOG); _configuration.error_log = (char *)strdup(CONFIG_DEFAULT_ERROR_LOG); + _configuration.loglevel = CONFIG_DEFAULT_LOG_LEVEL; _configuration.chroot = CONFIG_DEFAULT_CHROOT; _configuration.chuid = CONFIG_DEFAULT_CHUID; _configuration.user = CONFIG_DEFAULT_USER; @@ -299,7 +301,11 @@ static void _parse_logging(xmlDocPtr doc, xmlNodePtr node) } else if (strcmp(node->name, "errorlog") == 0) { if (_configuration.error_log) free(_configuration.error_log); _configuration.error_log = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); - } + } else if (strcmp(node->name, "loglevel") == 0) { + char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); + _configuration.loglevel = atoi(tmp); + if (tmp) free(tmp); + } } while ((node = node->next)); } diff --git a/src/config.h b/src/config.h index 4534d1a7..97101edf 100644 --- a/src/config.h +++ b/src/config.h @@ -43,6 +43,7 @@ typedef struct ice_config_tag char *access_log; char *error_log; + int loglevel; int chroot; int chuid; diff --git a/src/main.c b/src/main.c index 0eb4a61d..a2badf42 100644 --- a/src/main.c +++ b/src/main.c @@ -107,7 +107,7 @@ static int _start_logging(void) accesslog = log_open_file(stderr); } - log_set_level(errorlog, 4); + log_set_level(errorlog, config->loglevel); log_set_level(accesslog, 4); if (errorlog < 0)