We can only send module specific messages to syslog and not debug messages printed with wpa_printf. Add an extra command line parameter '-s' to allow it. The feature is enabled with compile flag CONFIG_DEBUG_SYSLOG as for wpa_supplicant. Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@xxxxxxxxxxx> --- hostapd/Makefile | 4 ++++ hostapd/defconfig | 3 +++ hostapd/main.c | 18 +++++++++++++++++- src/utils/wpa_debug.c | 2 +- src/utils/wpa_debug.h | 3 +++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/hostapd/Makefile b/hostapd/Makefile index 52c72dc..ba193f2 100644 --- a/hostapd/Makefile +++ b/hostapd/Makefile @@ -124,6 +124,10 @@ LIBS_h += -lbfd -ldl -liberty -lz endif endif +ifdef CONFIG_DEBUG_SYSLOG +CFLAGS += -DCONFIG_DEBUG_SYSLOG +endif + ifndef CONFIG_ELOOP CONFIG_ELOOP=eloop endif diff --git a/hostapd/defconfig b/hostapd/defconfig index e25ec32..d522368 100644 --- a/hostapd/defconfig +++ b/hostapd/defconfig @@ -172,6 +172,9 @@ CONFIG_IPV6=y # same file, e.g., using trace-cmd. #CONFIG_DEBUG_LINUX_TRACING=y +# Send debug messages to syslog instead of stdout +#CONFIG_DEBUG_SYSLOG=y + # Remove support for RADIUS accounting #CONFIG_NO_ACCOUNTING=y diff --git a/hostapd/main.c b/hostapd/main.c index 6911232..d9e9ce8 100644 --- a/hostapd/main.c +++ b/hostapd/main.c @@ -108,6 +108,10 @@ static void hostapd_logger_cb(void *ctx, const u8 *addr, unsigned int module, module_str ? module_str : "", module_str ? ": " : "", txt); +#ifdef CONFIG_DEBUG_SYSLOG + if (wpa_debug_syslog) + conf_stdout = 0; +#endif /* CONFIG_DEBUG_SYSLOG */ if ((conf_stdout & module) && level >= conf_stdout_level) { wpa_debug_print_timestamp(); wpa_printf(MSG_INFO, "%s", format); @@ -485,6 +489,9 @@ static void usage(void) #endif /* CONFIG_DEBUG_LINUX_TRACING */ " -i list of interface names to use\n" " -S start all the interfaces synchronously\n" +#ifdef CONFIG_DEBUG_SYSLOG + " -s log messages to syslog\n" +#endif /* CONFIG_DEBUG_SYSLOG */ " -t include timestamps in some debug messages\n" " -v show hostapd version\n"); @@ -661,7 +668,7 @@ int main(int argc, char *argv[]) dl_list_init(&interfaces.global_ctrl_dst); for (;;) { - c = getopt(argc, argv, "b:Bde:f:hi:KP:STtu:vg:G:"); + c = getopt(argc, argv, "b:Bde:f:hi:KP:sSTtu:vg:G:"); if (c < 0) break; switch (c) { @@ -718,6 +725,11 @@ int main(int argc, char *argv[]) bss_config = tmp_bss; bss_config[num_bss_configs++] = optarg; break; +#ifdef CONFIG_DEBUG_SYSLOG + case 's': + wpa_debug_syslog = 1; + break; +#endif /* CONFIG_DEBUG_SYSLOG */ case 'S': start_ifaces_in_sync = 1; break; @@ -746,6 +758,10 @@ int main(int argc, char *argv[]) wpa_debug_open_file(log_file); else wpa_debug_setup_stdout(); +#ifdef CONFIG_DEBUG_SYSLOG + if (wpa_debug_syslog) + wpa_debug_open_syslog(); +#endif /* CONFIG_DEBUG_SYSLOG */ #ifdef CONFIG_DEBUG_LINUX_TRACING if (enable_trace_dbg) { int tret = wpa_debug_open_linux_tracing(); diff --git a/src/utils/wpa_debug.c b/src/utils/wpa_debug.c index f7acf6b..62758d8 100644 --- a/src/utils/wpa_debug.c +++ b/src/utils/wpa_debug.c @@ -13,7 +13,7 @@ #ifdef CONFIG_DEBUG_SYSLOG #include <syslog.h> -static int wpa_debug_syslog = 0; +int wpa_debug_syslog = 0; #endif /* CONFIG_DEBUG_SYSLOG */ #ifdef CONFIG_DEBUG_LINUX_TRACING diff --git a/src/utils/wpa_debug.h b/src/utils/wpa_debug.h index 17d8f96..1fe0b7d 100644 --- a/src/utils/wpa_debug.h +++ b/src/utils/wpa_debug.h @@ -14,6 +14,9 @@ extern int wpa_debug_level; extern int wpa_debug_show_keys; extern int wpa_debug_timestamp; +#ifdef CONFIG_DEBUG_SYSLOG +extern int wpa_debug_syslog; +#endif /* CONFIG_DEBUG_SYSLOG */ /* Debugging function - conditional printf and hex dump. Driver wrappers can * use these for debugging purposes. */ -- 2.7.4 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap