[PATCH v5 04/42] log: Give program name and version in log init

Jukka Rissanen jukka.rissanen at linux.intel.com
Mon Nov 12 04:07:20 PST 2012


This allows the correct output when the log functions
are used from separate vpn daemon.
---
 src/connman.h   | 3 ++-
 src/log.c       | 5 +++--
 src/main.c      | 2 +-
 unit/test-nat.c | 2 +-
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index b5fd333..2fccab7 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -114,7 +114,8 @@ int __connman_agent_report_error(struct connman_service *service,
 #include <connman/log.h>
 
 int __connman_log_init(const char *program, const char *debug,
-		connman_bool_t detach, connman_bool_t backtrace);
+		connman_bool_t detach, connman_bool_t backtrace,
+		const char *program_name, const char *program_version);
 void __connman_log_cleanup(connman_bool_t backtrace);
 void __connman_log_enable(struct connman_debug_desc *start,
 					struct connman_debug_desc *stop);
diff --git a/src/log.c b/src/log.c
index 9a68a4b..4e305a9 100644
--- a/src/log.c
+++ b/src/log.c
@@ -292,7 +292,8 @@ void __connman_log_enable(struct connman_debug_desc *start,
 }
 
 int __connman_log_init(const char *program, const char *debug,
-		connman_bool_t detach, connman_bool_t backtrace)
+		connman_bool_t detach, connman_bool_t backtrace,
+		const char *program_name, const char *program_version)
 {
 	static char path[PATH_MAX];
 	int option = LOG_NDELAY | LOG_PID;
@@ -313,7 +314,7 @@ int __connman_log_init(const char *program, const char *debug,
 
 	openlog(basename(program), option, LOG_DAEMON);
 
-	syslog(LOG_INFO, "Connection Manager version %s", VERSION);
+	syslog(LOG_INFO, "%s version %s", program_name, program_version);
 
 	return 0;
 }
diff --git a/src/main.c b/src/main.c
index 187104b..345791b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -547,7 +547,7 @@ int main(int argc, char *argv[])
 	g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL);
 
 	__connman_log_init(argv[0], option_debug, option_detach,
-			option_backtrace);
+			option_backtrace, "Connection Manager", VERSION);
 
 	__connman_dbus_init(conn);
 
diff --git a/unit/test-nat.c b/unit/test-nat.c
index 4a48461..df8a2b5 100644
--- a/unit/test-nat.c
+++ b/unit/test-nat.c
@@ -147,7 +147,7 @@ int main(int argc, char *argv[])
 
 	g_test_init(&argc, &argv, NULL);
 
-	__connman_log_init(argv[0], "*", FALSE, TRUE);
+	__connman_log_init(argv[0], "*", FALSE, TRUE, "test-nat", VERSION);
 	__connman_iptables_init();
 	__connman_nat_init();
 
-- 
1.7.11.4




More information about the connman mailing list