Diff between 8f04e6a2c4a645bcfa5fc828b6b957c5bc88a14c and cf7c506246335002da737cbb43147ad088c75566

Changed Files

File Additions Deletions Status
obexd/client/main.c +3 -5 modified
obexd/src/log.c +9 -8 modified
obexd/src/log.h +4 -3 modified
obexd/src/main.c +4 -6 modified

Full Patch

diff --git a/obexd/client/main.c b/obexd/client/main.c
index 3bde09e..29fbab1 100644
--- a/obexd/client/main.c
+++ b/obexd/client/main.c
@@ -579,7 +579,6 @@ int main(int argc, char *argv[])
 	DBusConnection *conn;
 	DBusError derr;
 	GError *gerr = NULL;
-	int log_option = 0;
 
 	context = g_option_context_new(NULL);
 	g_option_context_add_main_entries(context, options, NULL);
@@ -610,12 +609,9 @@ int main(int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
-	if (option_stderr == TRUE)
-		log_option |= LOG_PERROR;
-
 	event_loop = g_main_loop_new(NULL, FALSE);
 
-	log_init("obex-client", option_debug, log_option);
+	__obex_log_init(option_debug, option_stderr);
 
 	DBG("Entering main loop");
 
@@ -632,5 +628,7 @@ int main(int argc, char *argv[])
 
 	g_main_loop_unref(event_loop);
 
+	__obex_log_cleanup();
+
 	return 0;
 }
diff --git a/obexd/src/log.c b/obexd/src/log.c
index 8c5d769..39489a2 100644
--- a/obexd/src/log.c
+++ b/obexd/src/log.c
@@ -73,8 +73,6 @@ extern struct obex_debug_desc __stop___debug[];
 
 static gchar **enabled = NULL;
 
-int debug_enabled = FALSE;
-
 static gboolean is_enabled(struct obex_debug_desc *desc)
 {
 	int i;
@@ -94,7 +92,7 @@ static gboolean is_enabled(struct obex_debug_desc *desc)
 	return 0;
 }
 
-void log_enable_debug()
+void __obex_log_enable_debug()
 {
 	struct obex_debug_desc *desc;
 
@@ -102,9 +100,9 @@ void log_enable_debug()
 		desc->flags |= OBEX_DEBUG_FLAG_PRINT;
 }
 
-void log_init(const char *ident, const char *debug, int log_option)
+void __obex_log_init(const char *debug, int detach)
 {
-	int option = log_option | LOG_NDELAY | LOG_PID;
+	int option = LOG_NDELAY | LOG_PID;
 	struct obex_debug_desc *desc;
 	const char *name = NULL, *file = NULL;
 
@@ -124,12 +122,15 @@ void log_init(const char *ident, const char *debug, int log_option)
 			desc->flags |= OBEX_DEBUG_FLAG_PRINT;
 	}
 
-	openlog(ident, option, LOG_DAEMON);
+	if (!detach)
+		option |= LOG_PERROR;
+
+	openlog("obexd", option, LOG_DAEMON);
 
-	syslog(LOG_INFO, "%s version %s", ident, VERSION);
+	syslog(LOG_INFO, "OBEX daemon %s", VERSION);
 }
 
-void log_cleanup(void)
+void __obex_log_cleanup(void)
 {
 	closelog();
 
diff --git a/obexd/src/log.h b/obexd/src/log.h
index 93d8dde..1bf1b05 100644
--- a/obexd/src/log.h
+++ b/obexd/src/log.h
@@ -23,11 +23,12 @@
 
 void info(const char *format, ...) __attribute__((format(printf, 1, 2)));
 void error(const char *format, ...) __attribute__((format(printf, 1, 2)));
+
 void obex_debug(const char *format, ...) __attribute__((format(printf, 1, 2)));
 
-void log_init(const char *ident, const char *debug, int log_option);
-void log_cleanup(void);
-void log_enable_debug(void);
+void __obex_log_init(const char *debug, int detach);
+void __obex_log_cleanup(void);
+void __obex_log_enable_debug(void);
 
 struct obex_debug_desc {
 	const char *name;
diff --git a/obexd/src/main.c b/obexd/src/main.c
index b4c0508..649acf9 100644
--- a/obexd/src/main.c
+++ b/obexd/src/main.c
@@ -66,7 +66,7 @@ static void sig_term(int sig)
 
 static void sig_debug(int sig)
 {
-	log_enable_debug();
+	__obex_log_enable_debug();
 }
 
 static gboolean option_detach = TRUE;
@@ -179,7 +179,6 @@ int main(int argc, char *argv[])
 	GOptionContext *context;
 	GError *err = NULL;
 	struct sigaction sa;
-	int log_option = 0;
 
 #ifdef NEED_THREADS
 	if (g_thread_supported() == FALSE)
@@ -205,8 +204,7 @@ int main(int argc, char *argv[])
 			perror("Can't start daemon");
 			exit(1);
 		}
-	} else
-		log_option |= LOG_PERROR;
+	}
 
 	if (option_opp == FALSE && option_ftp == FALSE &&
 				option_pbap == FALSE &&
@@ -216,7 +214,7 @@ int main(int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
-	log_init("obexd", option_debug, log_option);
+	__obex_log_init(option_debug, option_detach);
 
 	DBG("Entering main loop");
 
@@ -298,7 +296,7 @@ int main(int argc, char *argv[])
 	g_free(option_capability);
 	g_free(option_root);
 
-	closelog();
+	__obex_log_cleanup();
 
 	return 0;
 }