Message ID | 20141204222842.CCE36E01E1@pstew.mtv.corp.google.com |
---|---|
State | Accepted |
Headers | show |
On Thu, Dec 04, 2014 at 02:23:35PM -0800, Paul Stewart wrote: > If hostapd will use stdout for debugging, set stdout to be line > buffered in case its output is redirected to a file. This allows > incremental output to be viewed immediately instead of at the file > buffering interval. Is there a specific reason why stdout would be redirected to a file instead of using the existing -f command line argument to configure the log entries to be written to a file? That -f option is already using line buffered mode.
I did notice that. In one of our test flows we wanted to make sure both stdout (really the output of wpa_printf) and stderr (incidental errors printed by modules not directly within ownership of hostapd) were directed to the same file and did not fight with each other about file position. On Sun, Dec 14, 2014 at 7:50 AM, Jouni Malinen <j@w1.fi> wrote: > > On Thu, Dec 04, 2014 at 02:23:35PM -0800, Paul Stewart wrote: > > If hostapd will use stdout for debugging, set stdout to be line > > buffered in case its output is redirected to a file. This allows > > incremental output to be viewed immediately instead of at the file > > buffering interval. > > Is there a specific reason why stdout would be redirected to a file > instead of using the existing -f command line argument to configure the > log entries to be written to a file? That -f option is already using > line buffered mode. > > -- > Jouni Malinen PGP id EFC895FA > _______________________________________________ > HostAP mailing list > HostAP@lists.shmoo.com > http://lists.shmoo.com/mailman/listinfo/hostap >
On Mon, Dec 15, 2014 at 07:51:01AM -0800, Paul Stewart wrote: > I did notice that. In one of our test flows we wanted to make sure both > stdout (really the output of wpa_printf) and stderr (incidental errors > printed by modules not directly within ownership of hostapd) were directed > to the same file and did not fight with each other about file position. OK, applied.
diff --git a/hostapd/main.c b/hostapd/main.c index 900bba9..6a90d58 100644 --- a/hostapd/main.c +++ b/hostapd/main.c @@ -638,6 +638,8 @@ int main(int argc, char *argv[]) if (log_file) wpa_debug_open_file(log_file); + else + wpa_debug_setup_stdout(); #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 bf0833a..8ba82b1 100644 --- a/src/utils/wpa_debug.c +++ b/src/utils/wpa_debug.c @@ -574,6 +574,13 @@ void wpa_debug_close_file(void) #endif /* CONFIG_DEBUG_FILE */ } +void wpa_debug_setup_stdout(void) +{ +#ifndef _WIN32 + setvbuf(stdout, NULL, _IOLBF, 0); +#endif /* _WIN32 */ +} + #endif /* CONFIG_NO_STDOUT_DEBUG */ diff --git a/src/utils/wpa_debug.h b/src/utils/wpa_debug.h index 391f197..400bea9 100644 --- a/src/utils/wpa_debug.h +++ b/src/utils/wpa_debug.h @@ -34,6 +34,7 @@ enum { #define wpa_hexdump_ascii_key(l,t,b,le) do { } while (0) #define wpa_debug_open_file(p) do { } while (0) #define wpa_debug_close_file() do { } while (0) +#define wpa_debug_setup_stdout() do { } while (0) #define wpa_dbg(args...) do { } while (0) static inline int wpa_debug_reopen_file(void) @@ -46,6 +47,7 @@ static inline int wpa_debug_reopen_file(void) int wpa_debug_open_file(const char *path); int wpa_debug_reopen_file(void); void wpa_debug_close_file(void); +void wpa_debug_setup_stdout(void); /** * wpa_debug_printf_timestamp - Print timestamp for debug output