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
#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

View File

@ -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);

View File

@ -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;
}