summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-02-22 08:42:19 +0100
committerMarcel Holtmann <marcel@holtmann.org>2008-02-22 08:42:19 +0100
commitdafd72419a43e2b5a0243d4b61372ca83747883f (patch)
tree387ba3c7de75ba30e85e7d6903751c063fb53e83 /src/main.c
parent84deb674a0c3511dd4eee17d47ca07a4f51ba396 (diff)
downloadconnman-dafd72419a43e2b5a0243d4b61372ca83747883f.tar.gz
connman-dafd72419a43e2b5a0243d4b61372ca83747883f.tar.bz2
connman-dafd72419a43e2b5a0243d4b61372ca83747883f.zip
Add logging infrastructure
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/main.c b/src/main.c
index 0fcf614d..a4962b2a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -27,7 +27,6 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
-#include <syslog.h>
#include <signal.h>
#include <getopt.h>
#include <sys/stat.h>
@@ -61,6 +60,7 @@ static void usage(void)
static struct option options[] = {
{ "nodaemon", 0, 0, 'n' },
{ "compat", 0, 0, 'c' },
+ { "debug", 0, 0, 'd' },
{ "help", 0, 0, 'h' },
{ }
};
@@ -70,17 +70,19 @@ int main(int argc, char *argv[])
DBusConnection *conn;
DBusError err;
struct sigaction sa;
- int log_option = LOG_NDELAY | LOG_PID;
- int opt, detach = 1, compat = 0;
+ int opt, detach = 1, compat = 0, debug = 0;
- while ((opt = getopt_long(argc, argv, "+nch", options, NULL)) != EOF) {
- switch(opt) {
+ while ((opt = getopt_long(argc, argv, "+ncdh", options, NULL)) != EOF) {
+ switch (opt) {
case 'n':
detach = 0;
break;
case 'c':
compat = 1;
break;
+ case 'd':
+ debug = 1;
+ break;
case 'h':
default:
usage();
@@ -97,10 +99,7 @@ int main(int argc, char *argv[])
perror("Can't start daemon");
exit(1);
}
- } else
- log_option |= LOG_PERROR;
-
- openlog("connmand", log_option, LOG_DAEMON);
+ }
mkdir(STATEDIR, S_IRUSR | S_IWUSR | S_IXUSR |
S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
@@ -127,6 +126,8 @@ int main(int argc, char *argv[])
compat = 0;
}
+ __connman_log_init(detach, debug);
+
__connman_agent_init(conn);
__connman_manager_init(conn, compat);
@@ -154,6 +155,8 @@ int main(int argc, char *argv[])
__connman_agent_cleanup();
+ __connman_log_cleanup();
+
g_dbus_cleanup_connection(conn);
g_main_loop_unref(main_loop);
@@ -162,7 +165,5 @@ int main(int argc, char *argv[])
rmdir(STATEDIR);
- closelog();
-
return 0;
}