improve log (show debug only if verbose active)

This commit is contained in:
Martin/Geno 2018-07-17 22:15:24 +02:00
parent ed8e91f54b
commit 25d424b716
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
3 changed files with 8 additions and 3 deletions

View File

@ -9,8 +9,6 @@ PKG_LICENSE:=APGL
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
#TARGET_CFLAGS += -DDEBUG
define Package/wifictld/Default define Package/wifictld/Default
SECTION:=net SECTION:=net
CATEGORY:=Network CATEGORY:=Network
@ -23,6 +21,7 @@ define Package/wifictld
$(call Package/wifictld/Default) $(call Package/wifictld/Default)
TITLE+= (full) TITLE+= (full)
VARIANT:=full VARIANT:=full
TARGET_CFLAGS += -DDEBUG -ggdb3
endef endef
define Package/wifictld-mini define Package/wifictld-mini

View File

@ -6,6 +6,8 @@ int verbose = 0;
#ifdef DEBUG #ifdef DEBUG
void log_debug(const char *format, ...) { void log_debug(const char *format, ...) {
if (!verbose)
return;
va_list args; va_list args;
va_start(args, format); va_start(args, format);
vprintf(format, args); vprintf(format, args);

View File

@ -17,7 +17,7 @@ int main(int argc, char *argv[])
log_info("start wifictld (full)\n"); log_info("start wifictld (full)\n");
#endif #endif
int c; int c = 0;
while ((c = getopt(argc, argv, "v")) != -1) { while ((c = getopt(argc, argv, "v")) != -1) {
switch (c) { switch (c) {
case 'v': case 'v':
@ -37,6 +37,7 @@ int main(int argc, char *argv[])
ret = wifi_clients_init(); ret = wifi_clients_init();
if (ret) if (ret)
{ {
log_error("exit with error on client init\n");
return ret; return ret;
} }
// bind to loop // bind to loop
@ -44,6 +45,7 @@ int main(int argc, char *argv[])
if (ret) if (ret)
{ {
wifi_clients_close(); wifi_clients_close();
log_error("exit with error on ubus init\n");
return ret; return ret;
} }
uloop_run(); uloop_run();
@ -53,5 +55,7 @@ int main(int argc, char *argv[])
wifictld_ubus_close(); wifictld_ubus_close();
wifi_clients_close(); wifi_clients_close();
log_info("safe exit\n");
return 0; return 0;
} }