From 092c73b4a553c419cad58268ec1411e31e5ca300 Mon Sep 17 00:00:00 2001 From: Karl Heyes Date: Tue, 16 Aug 2005 16:56:24 +0000 Subject: [PATCH] log xml/xslt parsing failure messages via error log. This applies to both the xsl files and the icecast xml file when re-read. At icecast startup, the logs are not open so these parsing messages still go to stderr. svn path=/icecast/trunk/icecast/; revision=9758 --- src/event.c | 1 + src/logging.c | 14 ++++++++++++++ src/logging.h | 1 + src/xslt.c | 3 +++ 4 files changed, 19 insertions(+) diff --git a/src/event.c b/src/event.c index 9174272f..f69287e8 100644 --- a/src/event.c +++ b/src/event.c @@ -35,6 +35,7 @@ void event_config_read(void *arg) config = config_grab_config(); /* Both to get the lock, and to be able to find out the config filename */ + xmlSetGenericErrorFunc ("config", log_parse_failure); ret = config_parse_file(config->config_filename, &new_config); if(ret < 0) { ERROR0("Error parsing config, not replacing existing config"); diff --git a/src/logging.c b/src/logging.c index aea92b23..0ab09051 100644 --- a/src/logging.c +++ b/src/logging.c @@ -188,6 +188,20 @@ void logging_playlist(const char *mount, const char *metadata, long listeners) } +void log_parse_failure (void *ctx, const char *fmt, ...) +{ + char line [200]; + va_list ap; + char *eol; + + va_start (ap, fmt); + vsnprintf (line, sizeof (line), fmt, ap); + eol = strrchr (line, '\n'); + if (eol) *eol='\0'; + va_end (ap); + log_write (errorlog, 2, (char*)ctx, "", "%s", line); +} + void restart_logging (ice_config_t *config) { diff --git a/src/logging.h b/src/logging.h index fcf6b856..4a8df6c0 100644 --- a/src/logging.h +++ b/src/logging.h @@ -95,6 +95,7 @@ extern int playlistlog; void logging_access(client_t *client); void logging_playlist(const char *mount, const char *metadata, long listeners); void restart_logging (ice_config_t *config); +void log_parse_failure (void *ctx, const char *fmt, ...); #endif /* __LOGGING_H__ */ diff --git a/src/xslt.c b/src/xslt.c index c763a97e..4dcfecb7 100644 --- a/src/xslt.c +++ b/src/xslt.c @@ -190,6 +190,9 @@ void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client) xmlChar *string; int len, problem = 0; + xmlSetGenericErrorFunc ("", log_parse_failure); + xsltSetGenericErrorFunc ("", log_parse_failure); + thread_mutex_lock(&xsltlock); cur = xslt_get_stylesheet(xslfilename);