[xiph-commits] r14397 - icecast/trunk/ices0/src

ivo at svn.xiph.org ivo at svn.xiph.org
Mon Jan 14 04:32:09 PST 2008


Author: ivo
Date: 2008-01-14 04:32:08 -0800 (Mon, 14 Jan 2008)
New Revision: 14397

Modified:
   icecast/trunk/ices0/src/log.c
Log:
Support for log timestamping.  Closes #1277

Modified: icecast/trunk/ices0/src/log.c
===================================================================
--- icecast/trunk/ices0/src/log.c	2008-01-14 05:38:28 UTC (rev 14396)
+++ icecast/trunk/ices0/src/log.c	2008-01-14 12:32:08 UTC (rev 14397)
@@ -1,6 +1,6 @@
 /* log.c
  * - Functions for logging in ices
- * Copyright (c) 2000 Alexander Haväng
+ * Copyright (c) 2000 Alexander Hav�ng
  * Copyright (c) 2001 Brendan Cully
  *
  * This program is free software; you can redistribute it and/or
@@ -19,6 +19,7 @@
  *
  */
 
+#include <time.h>
 #include "definitions.h"
 
 extern ices_config_t ices_config;
@@ -144,8 +145,21 @@
 static void
 ices_log_string (char *format, char *string)
 {
+        char *buff;
+        struct tm *logtime;
+        time_t nowtime;
+
+        buff = (char *) malloc ((sizeof (char) * 20) + sizeof (format) + 1);
+        memset (buff, 0x00, sizeof (buff));
+
+        nowtime = time (NULL);
+        logtime = localtime (&nowtime);
+        sprintf (buff, "%4d-%2d-%2d %2d:%2d:%2d %s", logtime->tm_year + 1900,
+          logtime->tm_mon + 1, logtime->tm_mday, logtime->tm_hour,
+          logtime->tm_min, logtime->tm_sec, format);
+
 	if (ices_config.logfile) {
-		fprintf (ices_config.logfile, format, string);
+		fprintf (ices_config.logfile, buff, string);
 #ifndef HAVE_SETLINEBUF
 		fflush (ices_config.logfile);
 #endif
@@ -153,8 +167,10 @@
 	
 	/* Don't log to console when daemonized */
 	if (!ices_config.daemon) {
-		fprintf (stdout, format, string);
+		fprintf (stdout, buff, string);
 	}
+
+        free (buff);
 }
 
 /* Open the ices logfile, create it if needed */



More information about the commits mailing list