log: Use separate function for enable logging
authorMarcel Holtmann <marcel@holtmann.org>
Mon, 15 Aug 2011 23:07:28 +0000 (16:07 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Mon, 15 Aug 2011 23:07:28 +0000 (16:07 -0700)
src/connman.h
src/log.c

index 2fc0e92..6e68c99 100644 (file)
@@ -98,6 +98,8 @@ int __connman_agent_report_error(struct connman_service *service,
 
 int __connman_log_init(const char *debug, connman_bool_t detach);
 void __connman_log_cleanup(void);
+void __connman_log_enable(struct connman_debug_desc *start,
+                                       struct connman_debug_desc *stop);
 
 void __connman_debug_list_available(DBusMessageIter *iter, void *user_data);
 void __connman_debug_list_enabled(DBusMessageIter *iter, void *user_data);
index eb480b4..2301cdc 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -195,16 +195,16 @@ static connman_bool_t is_enabled(struct connman_debug_desc *desc)
        return FALSE;
 }
 
-int __connman_log_init(const char *debug, connman_bool_t detach)
+void __connman_log_enable(struct connman_debug_desc *start,
+                                       struct connman_debug_desc *stop)
 {
-       int option = LOG_NDELAY | LOG_PID;
        struct connman_debug_desc *desc;
        const char *name = NULL, *file = NULL;
 
-       if (debug != NULL)
-               enabled = g_strsplit_set(debug, ":, ", 0);
+       if (start == NULL || stop == NULL)
+               return;
 
-       for (desc = __start___debug; desc < __stop___debug; desc++) {
+       for (desc = start; desc < stop; desc++) {
                if (desc->flags & CONNMAN_DEBUG_FLAG_ALIAS) {
                        file = desc->file;
                        name = desc->name;
@@ -222,6 +222,16 @@ int __connman_log_init(const char *debug, connman_bool_t detach)
                if (is_enabled(desc) == TRUE)
                        desc->flags |= CONNMAN_DEBUG_FLAG_PRINT;
        }
+}
+
+int __connman_log_init(const char *debug, connman_bool_t detach)
+{
+       int option = LOG_NDELAY | LOG_PID;
+
+       if (debug != NULL)
+               enabled = g_strsplit_set(debug, ":, ", 0);
+
+       __connman_log_enable(__start___debug, __stop___debug);
 
        if (detach == FALSE)
                option |= LOG_PERROR;