This patch addes logfile support to mp3blaster. Add -L /path/to/logfile to the
commandline and all songs played will be logged there. Files will be truncated

diff -ur mp3blaster-3.2.0/src/main.cc mp3blaster-3.2.0-logfile/src/main.cc
--- mp3blaster-3.2.0/src/main.cc	2003-09-09 22:22:55.000000000 +0100
+++ mp3blaster-3.2.0-logfile/src/main.cc	2005-06-02 22:27:05.000000000 +0100
@@ -40,6 +40,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/time.h>
 #include <dirent.h>
 #include <time.h>
 #include <sys/time.h>
@@ -331,6 +332,7 @@
 #ifdef INCLUDE_LIRC
 	command_t lirc_cmd = CMD_NONE;
 #endif
+static FILE *log_file;
 int
 main(int argc, char *argv[], char *envp[])
 {
@@ -410,6 +412,7 @@
 			{ "status-file", 1, 0, 'f'},
 			{ "threads", 1, 0, 't'},
 			{ "version", 0, 0, 'v'},
+			{ "logfile", 1, 0, 'L'},
 			{ 0, 0, 0, 0}
 		};
 		
@@ -453,6 +456,15 @@
 		case 'h': /* help */
 			usage();
 			break;
+		case 'L':
+			log_file = fopen(optarg, "a");
+			if ( log_file == NULL ) {
+				perror("fopen");
+				fprintf(stderr, "%s: could not open logfile\n",
+					optarg);
+				exit(1);
+			}
+			break;
 		case 'l': /* load playlist */
 			options |= OPT_LOADLIST;
 			if (init_playlist)
@@ -837,6 +849,8 @@
 		"\t--threads/-t=<amount>: Numbers of threads to use for buffering\n"\
 		"\t\t(only works if mp3blaster was compiled with threads). Range is \n"\
 		"\t\t0..500 in increments of 50 only.\n"\
+		"\t--logfile/-L=<filename>: Logs times of all files played\n"\
+		"\t\tto the specified file\n"\
 		"\t--version,v: Display version number.\n"\
 		"");
 
@@ -2599,6 +2613,19 @@
 		stop_list();
 }
 
+static void write_log_file(const char *fn)
+{
+	struct timeval tv;
+
+	if ( log_file == NULL )
+		return;
+
+	/* can't fail (other than EFAULT) */
+	gettimeofday(&tv, NULL);
+
+	fprintf(log_file, "%lu.%.6lu %s\n", tv.tv_sec, tv.tv_usec, fn);
+}
+
 /* TODO: Implement history
  * PRE: This function can only be called from the playing thread, otherwise
  *    : we'll enter a deadlock.
@@ -2683,6 +2710,8 @@
 
 	void *init_args = NULL;
 
+	write_log_file(song);
+
 	if (is_wav(song))
 		playopts.player = new Wavefileplayer();
 #ifdef HAVE_SIDPLAYER
