summaryrefslogtreecommitdiff
path: root/src/log.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-06-12 02:06:16 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-06-12 02:06:16 +0000
commit43b355734cf192129f2906789185301a61f4cd8a (patch)
tree35a3a56a085fc590b1864347d49660d421157305 /src/log.c
parent43255a7f63af65d88bbead4c0d6429ef2008ada8 (diff)
Add WARNING log method. it's the same as ERROR, except that when mpd starts,
warnings are buffered until the error log is opened, and then flushed to the error log. git-svn-id: https://svn.musicpd.org/mpd/trunk@1442 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/log.c')
-rw-r--r--src/log.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/log.c b/src/log.c
index bdc7cf935..835fa9e00 100644
--- a/src/log.c
+++ b/src/log.c
@@ -20,10 +20,16 @@
#include "conf.h"
#include "myfprintf.h"
+#include "utils.h"
+#include <stdlib.h>
#include <string.h>
+#include <stdarg.h>
int logLevel = LOG_LEVEL_LOW;
+short warningFlushed = 0;
+
+static char * warningBuffer = NULL;
void initLog() {
if(strcmp(getConf()[CONF_LOG_LEVEL],"default")==0) {
@@ -37,4 +43,37 @@ void initLog() {
}
else ERROR("unknown log level \"%s\"\n",getConf()[CONF_LOG_LEVEL]);
}
-/* vim:set shiftwidth=4 tabstop=8 expandtab: */
+
+#define BUFFER_LENGTH 4096
+
+void bufferWarning(char * format, ... ) {
+ va_list arglist;
+ char temp[BUFFER_LENGTH+1];
+
+ memset(temp, 0, BUFFER_LENGTH+1);
+
+ va_start(arglist, format);
+
+ vsnprintf(temp, BUFFER_LENGTH, format, arglist);
+
+ warningBuffer = appendToString(warningBuffer, temp);
+
+ va_end(arglist);
+}
+void flushWarningLog() {
+ char * s;
+
+ if(warningBuffer == NULL) return;
+
+ s = strtok(warningBuffer, "\n");
+ while ( s != NULL ) {
+ myfprintf(stderr, "%s\n", s);
+
+ s = strtok(NULL, "\n");
+ }
+
+ free(warningBuffer);
+ warningBuffer = NULL;
+
+ warningFlushed = 1;
+}