tracker r1203 - in trunk: . src/libtracker-common src/trackerd



Author: mr
Date: Thu Mar  6 13:08:53 2008
New Revision: 1203
URL: http://svn.gnome.org/viewvc/tracker?rev=1203&view=rev

Log:
	* src/libtracker-common/Makefile.am:
	* src/libtracker-common/tracker-config.[ch]:
	* src/libtracker-common/tracker-language.[ch]: Moved these files
	here from src/trackerd so the API can be shared by all components. 

	* src/libtracker-common/tracker-log.[ch]: Created by taking these
	functions from the src/trackerd/tracker-utils.c log functions.
	This is based on a patch from Ivan Frade.

	* src/trackerd/Makefile.am:
	* src/trackerd/tracker-apps.c:
	* src/trackerd/tracker-cache.c:
	* src/trackerd/tracker-db-email.c:
	* src/trackerd/tracker-db-sqlite.c:
	* src/trackerd/tracker-db.c:
	* src/trackerd/tracker-dbus-files.c:
	* src/trackerd/tracker-dbus-keywords.c:
	* src/trackerd/tracker-dbus-metadata.c:
	* src/trackerd/tracker-dbus-methods.c:
	* src/trackerd/tracker-dbus-search.c:
	* src/trackerd/tracker-dbus.c:
	* src/trackerd/tracker-email-evolution.c:
	* src/trackerd/tracker-email-kmail.c:
	* src/trackerd/tracker-email-thunderbird.c:
	* src/trackerd/tracker-email-utils.c:
	* src/trackerd/tracker-email.c:
	* src/trackerd/tracker-indexer.c:
	* src/trackerd/tracker-inotify.c:
	* src/trackerd/tracker-ioprio.c:
	* src/trackerd/tracker-metadata.c:
	* src/trackerd/tracker-parser.c:
	* src/trackerd/tracker-rdf-query.c:
	* src/trackerd/tracker-utils.c: 
	* src/trackerd/trackerd.c: Update the include statments in most of
	these files to use libtracker-common's config/log headers.


Added:
   trunk/src/libtracker-common/tracker-config.c
      - copied, changed from r1202, /trunk/src/trackerd/tracker-config.c
   trunk/src/libtracker-common/tracker-config.h
      - copied unchanged from r1202, /trunk/src/trackerd/tracker-config.h
   trunk/src/libtracker-common/tracker-language.c
      - copied, changed from r1202, /trunk/src/trackerd/tracker-language.c
   trunk/src/libtracker-common/tracker-language.h
      - copied unchanged from r1202, /trunk/src/trackerd/tracker-language.h
   trunk/src/libtracker-common/tracker-log.c
   trunk/src/libtracker-common/tracker-log.h
Removed:
   trunk/src/trackerd/tracker-config.c
   trunk/src/trackerd/tracker-config.h
   trunk/src/trackerd/tracker-language.c
   trunk/src/trackerd/tracker-language.h
Modified:
   trunk/ChangeLog
   trunk/src/libtracker-common/Makefile.am
   trunk/src/trackerd/Makefile.am
   trunk/src/trackerd/tracker-apps.c
   trunk/src/trackerd/tracker-cache.c
   trunk/src/trackerd/tracker-db-email.c
   trunk/src/trackerd/tracker-db-sqlite.c
   trunk/src/trackerd/tracker-db.c
   trunk/src/trackerd/tracker-dbus-files.c
   trunk/src/trackerd/tracker-dbus-keywords.c
   trunk/src/trackerd/tracker-dbus-metadata.c
   trunk/src/trackerd/tracker-dbus-methods.c
   trunk/src/trackerd/tracker-dbus-search.c
   trunk/src/trackerd/tracker-dbus.c
   trunk/src/trackerd/tracker-email-evolution.c
   trunk/src/trackerd/tracker-email-kmail.c
   trunk/src/trackerd/tracker-email-thunderbird.c
   trunk/src/trackerd/tracker-email-utils.c
   trunk/src/trackerd/tracker-email.c
   trunk/src/trackerd/tracker-indexer.c
   trunk/src/trackerd/tracker-inotify.c
   trunk/src/trackerd/tracker-ioprio.c
   trunk/src/trackerd/tracker-metadata.c
   trunk/src/trackerd/tracker-parser.c
   trunk/src/trackerd/tracker-rdf-query.c
   trunk/src/trackerd/tracker-utils.c
   trunk/src/trackerd/trackerd.c

Modified: trunk/src/libtracker-common/Makefile.am
==============================================================================
--- trunk/src/libtracker-common/Makefile.am	(original)
+++ trunk/src/libtracker-common/Makefile.am	Thu Mar  6 13:08:53 2008
@@ -1,9 +1,24 @@
-INCLUDES = $(GLIB2_CFLAGS)
+INCLUDES =				\
+	$(GLIB2_CFLAGS)			\
+	-DSHAREDIR=\""$(datadir)"\"
 
 noinst_LTLIBRARIES = libtracker-common.la
 
-libtracker_common_la_SOURCES = tracker-configuration.c
+libtracker_common_la_SOURCES = 		\
+	tracker-configuration.c 	\
+	tracker-configuration.h 	\
+	tracker-config.c 		\
+	tracker-config.h		\
+	tracker-language.c		\
+	tracker-language.h		\
+	tracker-log.c	 		\
+	tracker-log.h
+
 libtracker_common_la_LDFLAGS = -version-info 0:0:0
 libtracker_common_la_LIBADD = $(GLIB2_LIBS)
 
-noinst_HEADERS = tracker-configuration.h
+noinst_HEADERS = 			\
+	tracker-configuration.h		\
+	tracker-config.h		\
+	tracker-language.h		\
+	tracker-log.h

Copied: trunk/src/libtracker-common/tracker-config.c (from r1202, /trunk/src/trackerd/tracker-config.c)
==============================================================================
--- /trunk/src/trackerd/tracker-config.c	(original)
+++ trunk/src/libtracker-common/tracker-config.c	Thu Mar  6 13:08:53 2008
@@ -27,7 +27,6 @@
 
 #include <glib.h>
 
-#include "tracker-utils.h"
 #include "tracker-language.h"
 #include "tracker-config.h"
 

Copied: trunk/src/libtracker-common/tracker-language.c (from r1202, /trunk/src/trackerd/tracker-language.c)
==============================================================================
--- /trunk/src/trackerd/tracker-language.c	(original)
+++ trunk/src/libtracker-common/tracker-language.c	Thu Mar  6 13:08:53 2008
@@ -26,7 +26,7 @@
 
 #include "../libstemmer/include/libstemmer.h"
 
-#include "tracker-utils.h"
+#include "tracker-log.h" 
 #include "tracker-language.h"
 
 typedef struct _Languages Languages;
@@ -68,7 +68,7 @@
 	gchar *filename;
 
 	str = g_strconcat (".", language_code, NULL);
-	filename = g_build_filename (TRACKER_DATADIR,
+	filename = g_build_filename (SHAREDIR,
 				     "tracker",
 				     "languages",
 				     "stopwords",

Added: trunk/src/libtracker-common/tracker-log.c
==============================================================================
--- (empty file)
+++ trunk/src/libtracker-common/tracker-log.c	Thu Mar  6 13:08:53 2008
@@ -0,0 +1,233 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h> 
+#include <glib/gstdio.h> 
+
+#ifdef OS_WIN32
+#include <conio.h>
+#include "mingw-compat.h"
+#else
+#include <sys/resource.h>
+#endif
+
+#include "tracker-log.h"
+
+typedef struct {
+	TrackerConfig *config;
+
+	gchar         *filename;
+
+	GMutex        *mutex;
+	gboolean       abort_on_error;
+} TrackerLog;
+
+static TrackerLog *log = NULL;
+
+static inline void
+log_output (const char *message)
+{
+	FILE		*fd;
+	time_t	  	 now;
+	gchar	 	 time_str[64];
+	gchar            usec_str[20];
+	gchar		*output;
+	struct tm	*local_time;
+	GTimeVal	 current_time;
+	static size_t    size = 0;
+
+	g_return_if_fail (log != NULL);
+	g_return_if_fail (message != NULL && message[0] != '\0');
+
+	g_print ("%s\n", message);
+
+	/* Ensure file logging is thread safe */
+	g_mutex_lock (log->mutex);
+
+	fd = g_fopen (log->filename, "a");
+	if (!fd) {
+		g_warning ("Could not open log: '%s'", log->filename);
+		g_mutex_unlock (log->mutex);
+		return;
+	}
+
+	/* Check log size, 10MiB limit */
+	if (size > (10 << 20)) {
+		rewind (fd);
+		ftruncate (fileno (fd), 0);
+		size = 0;
+	}
+
+	g_get_current_time (&current_time);
+
+	now = time ((time_t *) NULL);
+	local_time = localtime (&now);
+	strftime (time_str, 64, "%d %b %Y, %H:%M:%S:", local_time);
+	g_sprintf (usec_str, "%03ld", current_time.tv_usec / 1000); 
+
+	output = g_strdup_printf ("%s%s - %s", 
+				  time_str, 
+				  usec_str, 
+				  message);
+
+	size += g_fprintf (fd, "%s\n", output);
+	g_free (output);
+
+	fclose (fd);
+
+	g_mutex_unlock (log->mutex);
+}
+
+void
+tracker_log_init (TrackerConfig *config,
+		  const gchar   *filename, 
+                  gboolean       abort_on_error) 
+{
+	g_return_if_fail (TRACKER_IS_CONFIG (config));
+	g_return_if_fail (filename != NULL);
+	
+	log = g_new0 (TrackerLog, 1);
+
+	log->config = g_object_ref (config);
+
+	log->filename = g_strdup (filename);
+
+	log->mutex = g_mutex_new ();
+	log->abort_on_error = abort_on_error;
+}
+
+void
+tracker_log_term (void) 
+{
+	g_return_if_fail (log != NULL);
+
+	g_mutex_free (log->mutex);
+	g_free (log->filename);
+
+	g_object_unref (log->config);
+
+	g_free (log);
+}
+
+void 
+tracker_log_set_abort_on_error (gboolean abort) 
+{
+	g_return_if_fail (log != NULL);
+
+	log->abort_on_error = abort;
+}
+
+gboolean
+tracker_log_get_abort_on_error (void) 
+{
+	g_return_val_if_fail (log != NULL, FALSE);
+
+	return log->abort_on_error;
+}
+
+void
+tracker_log (const char *message, ...)
+{
+	va_list  args;
+	gchar	*str;
+
+	g_return_if_fail (log != NULL);
+
+	if (tracker_config_get_verbosity (log->config) < 1) {
+		return;
+	}
+
+	va_start (args, message);
+	str = g_strdup_vprintf (message, args);
+	va_end (args);
+
+	log_output (str);
+	g_free (str);
+}
+
+void
+tracker_info (const char *message, ...)
+{
+	va_list  args;
+	gchar	*str;
+
+	g_return_if_fail (log != NULL);
+
+	if (tracker_config_get_verbosity (log->config) < 2) {
+		return;
+	}
+
+	va_start (args, message);
+	str = g_strdup_vprintf (message, args);
+	va_end (args);
+
+	log_output (str);
+	g_free (str);
+}
+
+void
+tracker_debug (const char *message, ...)
+{
+	va_list  args;
+	gchar	*str;
+
+	g_return_if_fail (log != NULL);
+
+	if (tracker_config_get_verbosity (log->config) < 3) {
+		return;
+	}
+
+	va_start (args, message);
+	str = g_strdup_vprintf (message, args);
+	va_end (args);
+
+	log_output (str);
+	g_free (str);
+}
+
+void
+tracker_error (const char *message, ...)
+{
+	va_list  args;
+	gchar	*str;
+
+	g_return_if_fail (log != NULL);
+
+	va_start (args, message);
+	str = g_strdup_vprintf (message, args);
+	va_end (args);
+
+	log_output (str);
+	g_free (str);
+
+	if (log->abort_on_error) {
+		g_assert (FALSE);
+	}
+}

Added: trunk/src/libtracker-common/tracker-log.h
==============================================================================
--- (empty file)
+++ trunk/src/libtracker-common/tracker-log.h	Thu Mar  6 13:08:53 2008
@@ -0,0 +1,48 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+#ifndef __TRACKER_LOG_H__
+#define __TRACKER_LOG_H__
+
+#include <glib.h>
+
+#include "tracker-config.h"
+
+G_BEGIN_DECLS
+
+void     tracker_log_init               (TrackerConfig *config,
+                                         const char    *filename,
+                                         gboolean       abort_on_error);
+void     tracker_log_term               (void);
+void     tracker_log_set_abort_on_error (gboolean       abort);
+gboolean tracker_log_get_abort_on_error (void);
+void     tracker_log                    (const char    *message,
+                                         ...);
+void     tracker_info                   (const char    *message,
+                                         ...);
+void     tracker_debug                  (const char    *message,
+                                         ...);
+void     tracker_error                  (const char    *message,
+                                         ...);
+
+G_END_DECLS
+
+#endif /* __TRACKER_LOG_H__ */

Modified: trunk/src/trackerd/Makefile.am
==============================================================================
--- trunk/src/trackerd/Makefile.am	(original)
+++ trunk/src/trackerd/Makefile.am	Thu Mar  6 13:08:53 2008
@@ -1,25 +1,25 @@
-INCLUDES =				\
-	-DTRACKER_DATADIR=\""$(datadir)"\"	\
-	-DLIBDIR=\""$(libdir)"\"	\
-	-DTRACKER_LOCALEDIR=\""$(localedir)"\" \
-	$(GLIB2_CFLAGS)			\
-	$(PANGO_CFLAGS)			\
-	$(GMIME_CFLAGS)			\
-	$(HAL_CFLAGS)			\
-	$(FAM_CFLAGS)			\
-	$(DBUS_CFLAGS)			\
-	$(SQLITE3_CFLAGS)		\
-	$(QDBM_CFLAGS)			\
-	$(UNAC_CFLAGS)		
-
+INCLUDES =								\
+	-DSHAREDIR=\""$(datadir)"\"					\
+	-DLIBDIR=\""$(libdir)"\"					\
+	-DLOCALEDIR=\""$(localedir)"\" 					\
+	$(GLIB2_CFLAGS)							\
+	$(PANGO_CFLAGS)							\
+	$(GMIME_CFLAGS)							\
+	$(HAL_CFLAGS)							\
+	$(FAM_CFLAGS)							\
+	$(DBUS_CFLAGS)							\
+	$(SQLITE3_CFLAGS)						\
+	$(QDBM_CFLAGS)							\
+	$(UNAC_CFLAGS)							\
+	-I$(top_builddir)/src
 
 if HAVE_INOTIFY
-watch_sources =				\
-	linux-inotify-syscalls.h	\
+watch_sources =								\
+	linux-inotify-syscalls.h					\
 	tracker-inotify.c
 else
 if HAVE_FAM
-watch_sources =tracker-fam.c
+watch_sources = tracker-fam.c
 else
 if OS_WIN32
 watch_sources = tracker-win-fs-changes.c
@@ -35,85 +35,82 @@
 unix_sources = tracker-os-dependant-unix.c
 endif
 
-db_sources =				\
-	tracker-indexer.c		\
-	tracker-indexer.h		\
-	tracker-cache.c			\
-	tracker-cache.h			\
-	tracker-parser.c		\
-	tracker-parser.h		\
-	tracker-db-sqlite.c		\
-	tracker-db-sqlite.h		\
-	tracker-db-email.c		\
+db_sources =								\
+	tracker-indexer.c						\
+	tracker-indexer.h						\
+	tracker-cache.c							\
+	tracker-cache.h							\
+	tracker-parser.c						\
+	tracker-parser.h						\
+	tracker-db-sqlite.c						\
+	tracker-db-sqlite.h						\
+	tracker-db-email.c						\
 	tracker-db-email.h
 
 
 bin_PROGRAMS = trackerd
 
-trackerd_SOURCES =			\
-	trackerd.c			\
-	$(watch_sources)		\
-	$(win_sources)			\
-	$(unix_sources)			\
-	$(db_sources)			\
-	tracker-apps.c			\
-	tracker-apps.h			\
-	tracker-config.c		\
-	tracker-config.h		\
-	tracker-db.c			\
-	tracker-db.h			\
-	tracker-dbus.c			\
-	tracker-dbus.h			\
-	tracker-dbus-files.c		\
-	tracker-dbus-files.h		\
-	tracker-dbus-methods.c		\
-	tracker-dbus-methods.h		\
-	tracker-dbus-metadata.c		\
-	tracker-dbus-metadata.h		\
-	tracker-dbus-keywords.c		\
-	tracker-dbus-keywords.h		\
-	tracker-dbus-search.c		\
-	tracker-dbus-search.h		\
-	tracker-email.c			\
-	tracker-email.h			\
-	tracker-email-utils.c		\
-	tracker-email-utils.h		\
-	tracker-email-evolution.c	\
-	tracker-email-evolution.h	\
-	tracker-email-thunderbird.c	\
-	tracker-email-thunderbird.h	\
-	tracker-email-kmail.c		\
-	tracker-email-kmail.h		\
-	tracker-language.c		\
-	tracker-language.h		\
-	tracker-metadata.c		\
-	tracker-metadata.h		\
-	tracker-rdf-query.c		\
-	tracker-rdf-query.h		\
-	tracker-utils.c			\
-	tracker-utils.h			\
-	tracker-ioprio.c		\
-	tracker-ioprio.h		\
-	tracker-os-dependant.h		\
+trackerd_SOURCES =							\
+	trackerd.c							\
+	$(watch_sources)						\
+	$(win_sources)							\
+	$(unix_sources)							\
+	$(db_sources)							\
+	tracker-apps.c							\
+	tracker-apps.h							\
+	tracker-db.c							\
+	tracker-db.h							\
+	tracker-dbus.c							\
+	tracker-dbus.h							\
+	tracker-dbus-files.c						\
+	tracker-dbus-files.h						\
+	tracker-dbus-methods.c						\
+	tracker-dbus-methods.h						\
+	tracker-dbus-metadata.c						\
+	tracker-dbus-metadata.h						\
+	tracker-dbus-keywords.c						\
+	tracker-dbus-keywords.h						\
+	tracker-dbus-search.c						\
+	tracker-dbus-search.h						\
+	tracker-email.c							\
+	tracker-email.h							\
+	tracker-email-utils.c						\
+	tracker-email-utils.h						\
+	tracker-email-evolution.c					\
+	tracker-email-evolution.h					\
+	tracker-email-thunderbird.c					\
+	tracker-email-thunderbird.h					\
+	tracker-email-kmail.c						\
+	tracker-email-kmail.h						\
+	tracker-metadata.c						\
+	tracker-metadata.h						\
+	tracker-rdf-query.c						\
+	tracker-rdf-query.h						\
+	tracker-utils.c							\
+	tracker-utils.h							\
+	tracker-ioprio.c						\
+	tracker-ioprio.h						\
+	tracker-os-dependant.h						\
 	tracker-watch.h
 
 if OS_WIN32
 trackerd_win_libs = -lws2_32 -lkernel32
 endif
 
-trackerd_LDADD =			\
-	$(GLIB2_LIBS)			\
-	$(FAM_LIBS)			\
-	$(DBUS_LIBS)			\
-	$(PANGO_LIBS)			\
-	$(GMIME_LIBS)			\
-	$(HAL_LIBS)			\
-	$(SQLITE3_LIBS)			\
-	$(QDBM_LIBS)			\
-	$(UNAC_LIBS)			\
-	$(GTHREAD_LIBS)			\
-	-lz				\
-	-lm				\
-	$(top_builddir)/src/libstemmer/libstemmer-private.la \
-	$(top_builddir)/src/xdgmime/libxdgmime.la \
+trackerd_LDADD =							\
+	$(GLIB2_LIBS)							\
+	$(FAM_LIBS)							\
+	$(DBUS_LIBS)							\
+	$(PANGO_LIBS)							\
+	$(GMIME_LIBS)							\
+	$(HAL_LIBS)							\
+	$(SQLITE3_LIBS)							\
+	$(QDBM_LIBS)							\
+	$(UNAC_LIBS)							\
+	$(GTHREAD_LIBS)							\
+	-lz								\
+	-lm								\
+	$(top_builddir)/src/libtracker-common/libtracker-common.la 	\
+	$(top_builddir)/src/libstemmer/libstemmer-private.la 		\
+	$(top_builddir)/src/xdgmime/libxdgmime.la 			\
 	$(trackerd_win_libs)

Modified: trunk/src/trackerd/tracker-apps.c
==============================================================================
--- trunk/src/trackerd/tracker-apps.c	(original)
+++ trunk/src/trackerd/tracker-apps.c	Thu Mar  6 13:08:53 2008
@@ -21,10 +21,11 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <libtracker-common/tracker-log.h>
+
 #include "tracker-apps.h"
 #include "tracker-db.h"
 
-
 void
 tracker_applications_add_service_directories (void)
 {

Modified: trunk/src/trackerd/tracker-cache.c
==============================================================================
--- trunk/src/trackerd/tracker-cache.c	(original)
+++ trunk/src/trackerd/tracker-cache.c	Thu Mar  6 13:08:53 2008
@@ -19,12 +19,15 @@
 
 #include <sqlite3.h>
 #include <unistd.h>
+
 #include <glib.h>
 #include <glib/gstdio.h>
+
+#include <libtracker-common/tracker-config.h>
+
 #include "tracker-utils.h"
 #include "tracker-dbus.h"
 #include "tracker-cache.h"
-#include "tracker-config.h"
 
 #define USE_SLICE
 

Modified: trunk/src/trackerd/tracker-db-email.c
==============================================================================
--- trunk/src/trackerd/tracker-db-email.c	(original)
+++ trunk/src/trackerd/tracker-db-email.c	Thu Mar  6 13:08:53 2008
@@ -21,10 +21,12 @@
 
 #include <stdlib.h>
 #include <string.h>
+
 #include <glib/gstdio.h>
 
-#include "tracker-db-email.h"
+#include <libtracker-common/tracker-log.h>
 
+#include "tracker-db-email.h"
 
 #define MAX_ADDRESSES 255
 

Modified: trunk/src/trackerd/tracker-db-sqlite.c
==============================================================================
--- trunk/src/trackerd/tracker-db-sqlite.c	(original)
+++ trunk/src/trackerd/tracker-db-sqlite.c	Thu Mar  6 13:08:53 2008
@@ -21,6 +21,8 @@
 #define _GNU_SOURCE
 #endif
 
+#include "config.h"
+
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
@@ -31,24 +33,24 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <time.h>
-#include <glib.h>
-#include <glib/gstdio.h>
 #include <regex.h>
 #include <zlib.h>
 
+#ifdef OS_WIN32
+#include "mingw-compat.h"
+#endif
+
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#include <libtracker-common/tracker-config.h>
+
 #include "tracker-db-sqlite.h"
 #include "tracker-indexer.h"
 #include "tracker-cache.h"
 #include "tracker-metadata.h"
 #include "tracker-utils.h"
 #include "tracker-watch.h"
-#include "tracker-config.h"
-
-#include "config.h"
-
-#ifdef OS_WIN32
-#include "mingw-compat.h"
-#endif
 
 #define MAX_TEXT_BUFFER 65567
 #define MAX_COMPRESS_BUFFER 65565
@@ -245,7 +247,7 @@
 {
 	char *filename, *query;
 	
-	filename = g_build_filename (TRACKER_DATADIR, "/tracker/", sql_file, NULL);
+	filename = g_build_filename (SHAREDIR, "tracker", sql_file, NULL);
 
 	if (!g_file_get_contents (filename, &query, NULL, NULL)) {
 		tracker_error ("ERROR: Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file);
@@ -272,7 +274,7 @@
 {
 	char *filename, *query;
 	
-	filename = g_build_filename (TRACKER_DATADIR, "/tracker/", sql_file, NULL);
+	filename = g_build_filename (SHAREDIR, "tracker", sql_file, NULL);
 
 	if (!g_file_get_contents (filename, &query, NULL, NULL)) {
 		tracker_error ("ERROR: Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file);
@@ -472,7 +474,7 @@
 
 	tracker_log ("Loading prepared queries...");
 
-	sql_file = g_strdup (TRACKER_DATADIR "/tracker/sqlite-stored-procs.sql");
+	sql_file = g_build_filename (SHAREDIR, "tracker", "sqlite-stored-procs.sql", NULL);
 
 	if (!g_file_test (sql_file, G_FILE_TEST_EXISTS)) {
 		tracker_error ("ERROR: Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file);

Modified: trunk/src/trackerd/tracker-db.c
==============================================================================
--- trunk/src/trackerd/tracker-db.c	(original)
+++ trunk/src/trackerd/tracker-db.c	Thu Mar  6 13:08:53 2008
@@ -22,13 +22,15 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+
 #include <glib/gstdio.h>
 
+#include <libtracker-common/tracker-config.h>
+
 #include "tracker-db.h"
 #include "tracker-email.h"
 #include "tracker-metadata.h"
 #include "tracker-os-dependant.h"
-#include "tracker-config.h"
 
 extern Tracker *tracker;
 

Modified: trunk/src/trackerd/tracker-dbus-files.c
==============================================================================
--- trunk/src/trackerd/tracker-dbus-files.c	(original)
+++ trunk/src/trackerd/tracker-dbus-files.c	Thu Mar  6 13:08:53 2008
@@ -19,11 +19,12 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <libtracker-common/tracker-log.h>
+
 #include "tracker-dbus-methods.h"
 #include "tracker-metadata.h"
 #include "tracker-dbus-files.h"
 
-
 void
 tracker_dbus_method_files_exists (DBusRec *rec)
 {

Modified: trunk/src/trackerd/tracker-dbus-keywords.c
==============================================================================
--- trunk/src/trackerd/tracker-dbus-keywords.c	(original)
+++ trunk/src/trackerd/tracker-dbus-keywords.c	Thu Mar  6 13:08:53 2008
@@ -19,10 +19,11 @@
 
 #include <string.h>
 
+#include <libtracker-common/tracker-log.h>
+
 #include "tracker-dbus-methods.h"
 #include "tracker-dbus-keywords.h"
 
-
 extern Tracker *tracker;
 
 /*

Modified: trunk/src/trackerd/tracker-dbus-metadata.c
==============================================================================
--- trunk/src/trackerd/tracker-dbus-metadata.c	(original)
+++ trunk/src/trackerd/tracker-dbus-metadata.c	Thu Mar  6 13:08:53 2008
@@ -20,10 +20,11 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <libtracker-common/tracker-log.h>
+
 #include "tracker-dbus-methods.h"
 #include "tracker-dbus-metadata.h"
 
-
 void
 tracker_dbus_method_metadata_set (DBusRec *rec)
 {

Modified: trunk/src/trackerd/tracker-dbus-methods.c
==============================================================================
--- trunk/src/trackerd/tracker-dbus-methods.c	(original)
+++ trunk/src/trackerd/tracker-dbus-methods.c	Thu Mar  6 13:08:53 2008
@@ -17,20 +17,21 @@
  * Boston, MA  02110-1301, USA.
  */
 
-#include <string.h>
-#include <glib/gstdio.h>
-
-#include "tracker-dbus-methods.h"
-#include "tracker-metadata.h"
-#include "tracker-rdf-query.h"
-#include "tracker-config.h"
-
 #include "config.h"
 
+#include <string.h>
+
 #ifdef OS_WIN32
 #include "mingw-compat.h"
 #endif
 
+#include <glib/gstdio.h>
+
+#include <libtracker-common/tracker-config.h>
+
+#include "tracker-dbus-methods.h"
+#include "tracker-metadata.h"
+#include "tracker-rdf-query.h"
 
 extern Tracker *tracker;
 

Modified: trunk/src/trackerd/tracker-dbus-search.c
==============================================================================
--- trunk/src/trackerd/tracker-dbus-search.c	(original)
+++ trunk/src/trackerd/tracker-dbus-search.c	Thu Mar  6 13:08:53 2008
@@ -19,10 +19,11 @@
 
 #include <string.h>
 
+#include <libtracker-common/tracker-config.h>
+
 #include "tracker-dbus-methods.h"
 #include "tracker-rdf-query.h"
 #include "tracker-indexer.h"
-#include "tracker-config.h"
 
 extern Tracker *tracker;
 

Modified: trunk/src/trackerd/tracker-dbus.c
==============================================================================
--- trunk/src/trackerd/tracker-dbus.c	(original)
+++ trunk/src/trackerd/tracker-dbus.c	Thu Mar  6 13:08:53 2008
@@ -19,10 +19,12 @@
 
 #include <string.h>
 #include <stdlib.h>
+
+#include <libtracker-common/tracker-config.h>
+
 #include "tracker-dbus.h"
 #include "tracker-utils.h"
 #include "tracker-watch.h"
-#include "tracker-config.h"
 
 extern Tracker *tracker;
 

Modified: trunk/src/trackerd/tracker-email-evolution.c
==============================================================================
--- trunk/src/trackerd/tracker-email-evolution.c	(original)
+++ trunk/src/trackerd/tracker-email-evolution.c	Thu Mar  6 13:08:53 2008
@@ -28,15 +28,17 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+
 #include <glib/gstdio.h>
 
+#include <libtracker-common/tracker-config.h>
+
 #include "tracker-email-evolution.h"
 #include "tracker-email-utils.h"
 #include "tracker-db-email.h"
 #include "tracker-cache.h"
 #include "tracker-dbus.h"
 #include "tracker-watch.h"
-#include "tracker-config.h"
 
 #define EVOLUTION_MAIL_DIR_S ".evolution/mail"
 

Modified: trunk/src/trackerd/tracker-email-kmail.c
==============================================================================
--- trunk/src/trackerd/tracker-email-kmail.c	(original)
+++ trunk/src/trackerd/tracker-email-kmail.c	Thu Mar  6 13:08:53 2008
@@ -22,14 +22,16 @@
 #include <stdio.h>
 #include <string.h>
 #include <time.h>
+
 #include <glib/gstdio.h>
 
+#include <libtracker-common/tracker-log.h>
+
 #include "tracker-email-kmail.h"
 #include "tracker-email-utils.h"
 #include "tracker-db-email.h"
 #include "tracker-watch.h"
 
-
 typedef struct {
         gchar            *imap_path;
         gchar            *file;

Modified: trunk/src/trackerd/tracker-email-thunderbird.c
==============================================================================
--- trunk/src/trackerd/tracker-email-thunderbird.c	(original)
+++ trunk/src/trackerd/tracker-email-thunderbird.c	Thu Mar  6 13:08:53 2008
@@ -20,14 +20,15 @@
  */
 
 #include <string.h>
-#include <glib/gstdio.h>
 #include <stdlib.h>
 
+#include <glib/gstdio.h>
+
+#include <libtracker-common/tracker-config.h>
+
 #include "tracker-email-thunderbird.h"
 #include "tracker-db-email.h"
 #include "tracker-watch.h"
-#include "tracker-config.h"
-
 
 typedef enum
 {

Modified: trunk/src/trackerd/tracker-email-utils.c
==============================================================================
--- trunk/src/trackerd/tracker-email-utils.c	(original)
+++ trunk/src/trackerd/tracker-email-utils.c	Thu Mar  6 13:08:53 2008
@@ -27,8 +27,11 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <time.h>
+
 #include <glib/gstdio.h>
 
+#include <libtracker-common/tracker-config.h>
+
 #include "tracker-cache.h"
 #include "tracker-db-email.h"
 #include "tracker-dbus.h"
@@ -37,8 +40,6 @@
 #include "tracker-email-thunderbird.h"
 #include "tracker-email-kmail.h"
 #include "tracker-watch.h"
-#include "tracker-config.h"
-
 
 extern Tracker *tracker;
 

Modified: trunk/src/trackerd/tracker-email.c
==============================================================================
--- trunk/src/trackerd/tracker-email.c	(original)
+++ trunk/src/trackerd/tracker-email.c	Thu Mar  6 13:08:53 2008
@@ -21,12 +21,13 @@
 #include <glib.h>
 #include <glib/gstdio.h>
 
+#include <libtracker-common/tracker-config.h>
+
 #include "tracker-email.h"
 #include "tracker-email-utils.h"
 #include "tracker-email-evolution.h"
 #include "tracker-email-thunderbird.h"
 #include "tracker-email-kmail.h"
-#include "tracker-config.h"
 
 extern Tracker *tracker;
 

Modified: trunk/src/trackerd/tracker-indexer.c
==============================================================================
--- trunk/src/trackerd/tracker-indexer.c	(original)
+++ trunk/src/trackerd/tracker-indexer.c	Thu Mar  6 13:08:53 2008
@@ -30,13 +30,15 @@
 #include <string.h>
 #include <math.h>
 #include <sqlite3.h>
+
 #include <glib.h>
 #include <glib/gstdio.h>
 
+#include <libtracker-common/tracker-log.h>
+
 #include "tracker-indexer.h"
 #include "tracker-cache.h"
 #include "tracker-dbus.h"
-#include "tracker-config.h"
 
 extern Tracker *tracker;
 

Modified: trunk/src/trackerd/tracker-inotify.c
==============================================================================
--- trunk/src/trackerd/tracker-inotify.c	(original)
+++ trunk/src/trackerd/tracker-inotify.c	Thu Mar  6 13:08:53 2008
@@ -17,16 +17,11 @@
  * Boston, MA  02110-1301, USA.
  */
 
+#include "config.h"
+
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <glib.h>
-#include <glib/gstdio.h>
-
-#include "tracker-watch.h"
-
-#include "config.h"
-
 
 #ifdef HAVE_INOTIFY_LINUX
 #include <linux/inotify.h>
@@ -35,6 +30,13 @@
 #include <sys/inotify.h>
 #endif
 
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#include <libtracker-common/tracker-log.h>
+
+#include "tracker-watch.h"
+
 #define INOTIFY_WATCH_LIMIT "/proc/sys/fs/inotify/max_user_watches"
 
 /* project wide global vars */

Modified: trunk/src/trackerd/tracker-ioprio.c
==============================================================================
--- trunk/src/trackerd/tracker-ioprio.c	(original)
+++ trunk/src/trackerd/tracker-ioprio.c	Thu Mar  6 13:08:53 2008
@@ -31,14 +31,17 @@
 
 #include <stdio.h>
 #include <errno.h>
-#include <glib/gstdio.h>
-#include <tracker-utils.h>
-#include <sys/syscall.h>
-#include <unistd.h>
-
 #ifdef HAVE_LINUX_UNISTD_H
 #include <linux/unistd.h>
 #endif
+#include <sys/syscall.h>
+#include <unistd.h>
+
+#include <glib/gstdio.h>
+
+#include <libtracker-common/tracker-log.h>
+
+#include <tracker-utils.h>
 
 #include "tracker-ioprio.h"
 

Modified: trunk/src/trackerd/tracker-metadata.c
==============================================================================
--- trunk/src/trackerd/tracker-metadata.c	(original)
+++ trunk/src/trackerd/tracker-metadata.c	Thu Mar  6 13:08:53 2008
@@ -17,21 +17,25 @@
  * Boston, MA  02110-1301, USA.
  */
 
+#include "config.h"
+
 #include <unistd.h>
 #include <string.h>
 #include <stdlib.h>
-#include <glib/gstdio.h>
 #include <sys/types.h>
-#include "config.h"
 #ifdef OS_WIN32
 #include <conio.h>
 #else
 #include <sys/resource.h>
 #endif
+
+#include <glib/gstdio.h>
+
+#include <libtracker-common/tracker-log.h>
+
 #include "tracker-metadata.h"
 #include "tracker-utils.h"
 
-
 extern Tracker *tracker;
 
 

Modified: trunk/src/trackerd/tracker-parser.c
==============================================================================
--- trunk/src/trackerd/tracker-parser.c	(original)
+++ trunk/src/trackerd/tracker-parser.c	Thu Mar  6 13:08:53 2008
@@ -17,21 +17,22 @@
  * Boston, MA  02110-1301, USA.
  */
 
-#include <string.h>
-#include <pango/pango.h>
-
-#include "tracker-parser.h"
-#include "tracker-utils.h"
-#include "tracker-config.h"
-#include "tracker-language.h"
-
 #include "config.h"
 
-	
+#include <string.h>
+
 #ifdef HAVE_UNAC
 #include <unac.h>
 #endif
 
+#include <pango/pango.h>
+
+#include <libtracker-common/tracker-config.h>
+#include <libtracker-common/tracker-language.h>
+
+#include "tracker-parser.h"
+#include "tracker-utils.h"
+
 extern Tracker *tracker;
 
 /* need pango for CJK ranges which are : 0x3400 - 0x4DB5, 0x4E00 - 0x9FA5, 0x20000 - <= 0x2A6D6 */

Modified: trunk/src/trackerd/tracker-rdf-query.c
==============================================================================
--- trunk/src/trackerd/tracker-rdf-query.c	(original)
+++ trunk/src/trackerd/tracker-rdf-query.c	Thu Mar  6 13:08:53 2008
@@ -19,6 +19,8 @@
 
 #include <string.h>
 
+#include <libtracker-common/tracker-log.h>
+
 #include "tracker-rdf-query.h"
 
 

Modified: trunk/src/trackerd/tracker-utils.c
==============================================================================
--- trunk/src/trackerd/tracker-utils.c	(original)
+++ trunk/src/trackerd/tracker-utils.c	Thu Mar  6 13:08:53 2008
@@ -24,6 +24,7 @@
 
 
 #include "config.h"
+
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sys/types.h>
@@ -35,18 +36,8 @@
 #include <string.h>
 #include <unistd.h>
 #include <limits.h>
-#include <glib/gprintf.h>
-#include <glib/gstdio.h>
-#include <glib/gpattern.h>
 #include <zlib.h>
 #include <math.h>
-#include "tracker-dbus.h"
-#include "tracker-utils.h"
-#include "tracker-indexer.h"
-#include "tracker-config.h"
-#include "../xdgmime/xdgmime.h"
-
-#include "tracker-os-dependant.h"
 
 #ifdef OS_WIN32
 #include <conio.h>
@@ -55,6 +46,19 @@
 #include <sys/resource.h>
 #endif
 
+#include <glib/gprintf.h>
+#include <glib/gstdio.h>
+#include <glib/gpattern.h>
+
+#include <libtracker-common/tracker-log.h>
+#include "../xdgmime/xdgmime.h"
+
+#include "tracker-dbus.h"
+#include "tracker-utils.h"
+#include "tracker-indexer.h"
+
+#include "tracker-os-dependant.h"
+
 extern Tracker	*tracker;
 
 char *tracker_actions[] = {
@@ -2900,147 +2904,6 @@
 	}
 }
 
-
-
-
-
-
-static inline void
-output_log (const char *message)
-{
-	FILE		*fd;
-	time_t		now;
-	char		buffer1[64], buffer2[20];
-	char		*output;
-	struct tm	*loctime;
-	GTimeVal	start;
-
-	/* logging is thread safe */
-	static size_t   log_size = 0;
-
-	if (!message)
-		return;
-
-	g_print ("%s\n", message);
-
-	if (!tracker->log_file) return;
-
-	/* ensure file logging is thread safe */
-	g_mutex_lock (tracker->log_access_mutex);
-
-	fd = g_fopen (tracker->log_file, "a");
-
-	if (!fd) {
-		g_mutex_unlock (tracker->log_access_mutex);
-		g_warning ("could not open %s", tracker->log_file);
-		return;
-	}
-
-	/* check log size, 10MiB limit */
-	if (log_size > (10 << 20)) {
-		rewind (fd);
-		ftruncate (fileno (fd), 0);
-		log_size = 0;
-	}
-
-	g_get_current_time (&start);
-
-	now = time ((time_t *) NULL);
-
-	loctime = localtime (&now);
-
-	strftime (buffer1, 64, "%d %b %Y, %H:%M:%S:", loctime);
-
-	g_sprintf (buffer2, "%03ld", start.tv_usec / 1000);
-
-	output = g_strconcat (buffer1, buffer2, " - ", message, NULL);
-
-	log_size += g_fprintf (fd, "%s\n", output);
-
-	g_free (output);
-
-	fclose (fd);
-
-	g_mutex_unlock (tracker->log_access_mutex);
-}
-
-
-void
-tracker_error (const char *message, ...)
-{
-	va_list		args;
-	char 		*msg;
-
-  	va_start (args, message);
-  	msg = g_strdup_vprintf (message, args);
-	va_end (args);
-
-	output_log (msg);
-	g_free (msg);
-
-	if (tracker->fatal_errors) {
-		g_assert (FALSE);
-	}
-}
-
-
-void
-tracker_log 	(const char *message, ...)
-{
-	va_list		args;
-	char 		*msg;
-
-	if (tracker_config_get_verbosity (tracker->config) < 1) {
-		return;
-	}
-
-  	va_start (args, message);
-  	msg = g_strdup_vprintf (message, args);
-  	va_end (args);
-
-	output_log (msg);
-	g_free (msg);
-}
-
-
-void
-tracker_info	(const char *message, ...)
-{
-	va_list		args;
-	char 		*msg;
-
-	if (tracker_config_get_verbosity (tracker->config) < 2) {
-		return;
-	}
-
-  	va_start (args, message);
-  	msg = g_strdup_vprintf (message, args);
-  	va_end (args);
-
-	output_log (msg);
-	g_free (msg);
-}
-
-
-void
-tracker_debug 	(const char *message, ...)
-{
-	va_list		args;
-	char 		*msg;
-
-	if (tracker_config_get_verbosity (tracker->config) < 3) {
-		return;
-	}
-
-  	va_start (args, message);
-  	msg = g_strdup_vprintf (message, args);
-  	va_end (args);
-
-	output_log (msg);
-	g_free (msg);
-}
-
-
 gchar *
 tracker_string_replace (const gchar *haystack, gchar *needle, gchar *replacement)
 {

Modified: trunk/src/trackerd/trackerd.c
==============================================================================
--- trunk/src/trackerd/trackerd.c	(original)
+++ trunk/src/trackerd/trackerd.c	Thu Mar  6 13:08:53 2008
@@ -54,6 +54,10 @@
 #define BATTERY_OFF "ac_adapter.present"
 #define AC_ADAPTER "ac_adapter"
 
+#include <libtracker-common/tracker-config.h>
+#include <libtracker-common/tracker-language.h>
+#include <libtracker-common/tracker-log.h>
+
 #include "tracker-dbus-methods.h"
 #include "tracker-dbus-metadata.h"
 #include "tracker-dbus-keywords.h"
@@ -64,8 +68,6 @@
 #include "tracker-cache.h"
 #include "tracker-indexer.h"
 #include "tracker-watch.h"
-#include "tracker-config.h"
-#include "tracker-language.h"
 
 #include "tracker-os-dependant.h"
   
@@ -382,7 +384,7 @@
 {
 	tracker->status = STATUS_SHUTDOWN;
 
-	if (tracker->log_file && sig_msg) {
+	if (sig_msg) {
 		tracker_log ("Received signal '%s' so now shutting down", sig_msg);
 
 		tracker_print_object_allocations ();
@@ -415,9 +417,7 @@
 
 	g_mutex_unlock (tracker->metadata_signal_mutex);
 
-	if (tracker->log_file) {
-		tracker_log ("shutting down threads");
-	}
+	tracker_log ("shutting down threads");
 
 	/* send signals to each thread to wake them up and then stop them */
 
@@ -475,9 +475,9 @@
 		g_mkdir_with_parents (tracker->data_dir, 00755);
 	}
 
-	if (tracker->log_file) {
-		tracker_debug ("shutting down main thread");
-	}
+	tracker_debug ("Shutting down main thread");
+
+	tracker_log_term ();
 
 	/* remove sys tmp directory */
 	if (tracker->sys_tmp_root_dir) {
@@ -718,7 +718,7 @@
 
 
 		default:
-			if (tracker->log_file && g_strsignal (signo)) {
+			if (g_strsignal (signo)) {
 	   			tracker_log ("Received signal %s ", g_strsignal (signo));
 			}
 			break;
@@ -2239,7 +2239,7 @@
 
 	tracker->first_flush = TRUE;
 
-	tracker->services_dir = g_build_filename (TRACKER_DATADIR, "tracker", "services", NULL);
+	tracker->services_dir = g_build_filename (SHAREDIR, "tracker", "services", NULL);
 
 	tracker->root_directory_devices = NULL;
 
@@ -2396,19 +2396,22 @@
 gint
 main (gint argc, gchar *argv[])
 {
-	gint 		lfp;
+	gint               lfp;
 #ifndef OS_WIN32
-  	struct 	sigaction act;
-	sigset_t 	empty_mask;
+  	struct sigaction   act;
+	sigset_t 	   empty_mask;
 #endif
-	gchar 		*lock_file, *str, *lock_str;
-	GOptionContext  *context = NULL;
-	GError          *error = NULL;
-	gchar           *example;
-	gboolean 	need_index, need_data;
-	DBConnection 	*db_con;
-	char **st;
-	GPatternSpec* spec;
+	gchar 		  *lock_file, *str, *lock_str;
+	GOptionContext    *context = NULL;
+	GError            *error = NULL;
+	gchar             *example;
+	gboolean 	   need_index, need_data;
+	DBConnection      *db_con;
+	gchar            **st;
+	GPatternSpec      *spec;
+	gchar             *tmp_dir;
+	gchar             *old_tracker_dir;
+	gchar             *log_filename;
 
         g_type_init ();
         
@@ -2419,7 +2422,7 @@
 
 	setlocale (LC_ALL, "");
 
-	bindtextdomain (GETTEXT_PACKAGE, TRACKER_LOCALEDIR);
+	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
         bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
         textdomain (GETTEXT_PACKAGE);
 
@@ -2474,9 +2477,30 @@
 #endif
 
 	tracker = g_new0 (Tracker, 1);
+
+	/* Set up directories */
+	tracker->pid = (int) getpid ();
+	tmp_dir = g_strdup_printf ("Tracker-%s.%d", g_get_user_name (), tracker->pid);
+	tracker->sys_tmp_root_dir = g_build_filename (g_get_tmp_dir (), tmp_dir, NULL);
+	g_free (tmp_dir);
+
+	tracker->root_dir = g_build_filename (g_get_user_data_dir  (), "tracker", NULL);
+	tracker->data_dir = g_build_filename (g_get_user_cache_dir (), "tracker", NULL);
+	tracker->config_dir = g_strdup (g_get_user_config_dir ());
+	tracker->user_data_dir = g_build_filename (tracker->root_dir, "data", NULL);
 	
+        /* Set up the config */
         tracker->config = tracker_config_new ();
         tracker->language = tracker_language_new (tracker->config);
+
+	/* Set up the log */
+	log_filename = g_build_filename (tracker->root_dir, "tracker.log", NULL);
+	tracker_unlink (log_filename);
+
+	tracker_log_init (tracker->config, log_filename, fatal_errors);
+	tracker_log ("Starting log");
+
+        /* Set up the DBus IPC */
 	tracker->dbus_con = tracker_dbus_init ();
 
 	add_local_dbus_connection_monitoring (tracker->dbus_con);
@@ -2484,22 +2508,6 @@
 	tracker->status = STATUS_INIT;
 
  	tracker->is_running = FALSE;
-
-	/* Make a temporary directory for Tracker into g_get_tmp_dir() directory */
-	gchar *tmp_dir;
-
-	tracker->pid = (int) getpid();
-
-	tmp_dir = g_strdup_printf ("Tracker-%s.%d", g_get_user_name (), tracker->pid);
-
-	tracker->sys_tmp_root_dir = g_build_filename (g_get_tmp_dir (), tmp_dir, NULL);
-	tracker->root_dir = g_build_filename (g_get_user_data_dir  (), "tracker", NULL);
-	tracker->data_dir = g_build_filename (g_get_user_cache_dir (), "tracker", NULL);
-	tracker->config_dir = g_strdup (g_get_user_config_dir ());
-	tracker->user_data_dir = g_build_filename (tracker->root_dir, "data", NULL);
-
-	tracker->log_file = g_build_filename (tracker->root_dir, "tracker.log", NULL);
-
 	tracker->shutdown = FALSE;
 
 	tracker->files_check_mutex = g_mutex_new ();
@@ -2522,33 +2530,23 @@
 	tracker->files_signal_mutex = g_mutex_new ();
 	tracker->request_signal_mutex = g_mutex_new ();
 
-	tracker->log_access_mutex = g_mutex_new ();
 	tracker->scheduler_mutex = g_mutex_new ();
 
-	/* reset log file */
-	tracker_unlink (tracker->log_file);
-
-	tracker_log ("starting log");
-
-	
-
-
-	g_free (tmp_dir);
-
-	/* remove an existing one */
+	/* Remove an existing one */
 	if (g_file_test (tracker->sys_tmp_root_dir, G_FILE_TEST_EXISTS)) {
 		tracker_remove_dirs (tracker->sys_tmp_root_dir);
 	}
 
-	/* remove old tracker dirs */
-	gchar *old = g_build_filename (g_get_home_dir (), ".Tracker", NULL);
+	/* Remove old tracker dirs */
+        old_tracker_dir = g_build_filename (g_get_home_dir (), ".Tracker", NULL);
 
-	if (g_file_test (old ,G_FILE_TEST_EXISTS)) {
-		tracker_remove_dirs (old);
+	if (g_file_test (old_tracker_dir ,G_FILE_TEST_EXISTS)) {
+		tracker_remove_dirs (old_tracker_dir);
 	}
 
-	g_free (old);
+	g_free (old_tracker_dir);
 
+        /* Create other directories we need */
 	if (!g_file_test (tracker->user_data_dir, G_FILE_TEST_EXISTS)) {
 		g_mkdir_with_parents (tracker->user_data_dir, 00755);
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]