From 25d424b716c5b20bb05d239cc2017de19ca23185 Mon Sep 17 00:00:00 2001 From: Martin/Geno Date: Tue, 17 Jul 2018 22:15:24 +0200 Subject: [PATCH] improve log (show debug only if verbose active) --- wireless/wifictld/Makefile | 3 +-- wireless/wifictld/src/log.c | 2 ++ wireless/wifictld/src/main.c | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/wireless/wifictld/Makefile b/wireless/wifictld/Makefile index 03ab0c9..0ef41e2 100644 --- a/wireless/wifictld/Makefile +++ b/wireless/wifictld/Makefile @@ -9,8 +9,6 @@ PKG_LICENSE:=APGL include $(INCLUDE_DIR)/package.mk -#TARGET_CFLAGS += -DDEBUG - define Package/wifictld/Default SECTION:=net CATEGORY:=Network @@ -23,6 +21,7 @@ define Package/wifictld $(call Package/wifictld/Default) TITLE+= (full) VARIANT:=full + TARGET_CFLAGS += -DDEBUG -ggdb3 endef define Package/wifictld-mini diff --git a/wireless/wifictld/src/log.c b/wireless/wifictld/src/log.c index 5243fc9..cc1469b 100644 --- a/wireless/wifictld/src/log.c +++ b/wireless/wifictld/src/log.c @@ -6,6 +6,8 @@ int verbose = 0; #ifdef DEBUG void log_debug(const char *format, ...) { + if (!verbose) + return; va_list args; va_start(args, format); vprintf(format, args); diff --git a/wireless/wifictld/src/main.c b/wireless/wifictld/src/main.c index a2bb680..0caddc4 100644 --- a/wireless/wifictld/src/main.c +++ b/wireless/wifictld/src/main.c @@ -17,7 +17,7 @@ int main(int argc, char *argv[]) log_info("start wifictld (full)\n"); #endif - int c; + int c = 0; while ((c = getopt(argc, argv, "v")) != -1) { switch (c) { case 'v': @@ -37,6 +37,7 @@ int main(int argc, char *argv[]) ret = wifi_clients_init(); if (ret) { + log_error("exit with error on client init\n"); return ret; } // bind to loop @@ -44,6 +45,7 @@ int main(int argc, char *argv[]) if (ret) { wifi_clients_close(); + log_error("exit with error on ubus init\n"); return ret; } uloop_run(); @@ -53,5 +55,7 @@ int main(int argc, char *argv[]) wifictld_ubus_close(); wifi_clients_close(); + log_info("safe exit\n"); + return 0; }