diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2010-07-06 11:44:05 -0300 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-07-06 11:44:05 -0300 |
commit | 1f1a7db27c9e42f28d9f777f9a905778842f8404 (patch) | |
tree | 755d318049cfe2735ab59160a20017b33408bced | |
parent | ffeecc715ad86e4f8a9c914c1fd4d86cd3e31263 (diff) | |
download | obexd-1f1a7db27c9e42f28d9f777f9a905778842f8404.tar.gz |
More cleanup for the logging code
-rw-r--r-- | client/main.c | 8 | ||||
-rw-r--r-- | src/log.c | 17 | ||||
-rw-r--r-- | src/log.h | 7 | ||||
-rw-r--r-- | src/main.c | 10 |
4 files changed, 20 insertions, 22 deletions
diff --git a/client/main.c b/client/main.c index 3bde09e..29fbab1 100644 --- a/client/main.c +++ b/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; } @@ -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(); @@ -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; @@ -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; } |