Commit fce9ecb9 authored by Michael Smith's avatar Michael Smith

Allow setting the log level (for the error log, not the access log) from the

config file.

svn path=/trunk/icecast/; revision=3774
parent 8d75eb0b
......@@ -38,6 +38,7 @@
<logging>
<accesslog>access.log</accesslog>
<errorlog>error.log</errorlog>
<loglevel>4</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
</logging>
<security>
......
......@@ -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));
}
......
......@@ -43,6 +43,7 @@ typedef struct ice_config_tag
char *access_log;
char *error_log;
int loglevel;
int chroot;
int chuid;
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment