diff --git a/debian/libwsutil0.symbols b/debian/libwsutil0.symbols index 3b78598c57..951712dcce 100644 --- a/debian/libwsutil0.symbols +++ b/debian/libwsutil0.symbols @@ -382,7 +382,7 @@ libwsutil.so.0 libwsutil0 #MINVER# ws_log_add_custom_file@Base 3.5.0 ws_log_buffer_full@Base 3.5.1 ws_log_console_writer@Base 3.7.0 - ws_log_console_writer_set_use_stderr@Base 3.7.0 + ws_log_console_writer_set_use_stdout@Base 3.7.0 ws_log_file_writer@Base 3.7.0 ws_log_full@Base 3.5.0 ws_log_get_level@Base 3.5.0 diff --git a/extcap/extcap-base.c b/extcap/extcap-base.c index c4111405c2..c44981eed2 100644 --- a/extcap/extcap-base.c +++ b/extcap/extcap-base.c @@ -112,6 +112,8 @@ void extcap_base_set_running_with(extcap_parameters * extcap, const char *fmt, . void extcap_log_init(const char *progname) { ws_log_init(progname, NULL); + /* extcaps cannot write debug information to parent on stderr. */ + ws_log_console_writer_set_use_stdout(TRUE); } uint8_t extcap_base_parse_options(extcap_parameters * extcap, int result, char * optargument) diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index edfb715914..f145f839a6 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -520,6 +520,8 @@ int main(int argc, char *qt_argv[]) /* Initialize log handler early so we can have proper logging during startup. */ ws_log_init_with_writer("wireshark", console_log_writer, vcmdarg_err); + /* For backward compatibility with GLib logging and Wireshark 3.4. */ + ws_log_console_writer_set_use_stdout(TRUE); qInstallMessageHandler(qt_log_message_handler); diff --git a/wsutil/wslog.c b/wsutil/wslog.c index 47d6227d7d..9f53ce519c 100644 --- a/wsutil/wslog.c +++ b/wsutil/wslog.c @@ -84,8 +84,9 @@ static gboolean stdout_color_enabled = FALSE; static gboolean stderr_color_enabled = FALSE; -/* Use stderr for levels "info" and below. */ -static gboolean stderr_debug_enabled = FALSE; +/* Use stdout for levels "info" and below, for backward compatibility + * with GLib. */ +static gboolean stdout_logging_enabled = FALSE; static const char *registered_progname = DEFAULT_PROGNAME; @@ -929,7 +930,7 @@ static inline struct tm *get_localtime(time_t unix_time, struct tm **cookie) static inline FILE *console_file(enum ws_log_level level) { - if (level <= LOG_LEVEL_INFO && !stderr_debug_enabled) + if (level <= LOG_LEVEL_INFO && stdout_logging_enabled) return stdout; return stderr; } @@ -937,7 +938,7 @@ static inline FILE *console_file(enum ws_log_level level) static inline bool console_color_enabled(enum ws_log_level level) { - if (level <= LOG_LEVEL_INFO && !stderr_debug_enabled) + if (level <= LOG_LEVEL_INFO && stdout_logging_enabled) return stdout_color_enabled; return stderr_color_enabled; } @@ -1098,9 +1099,9 @@ void ws_log_console_writer(const char *domain, enum ws_log_level level, WS_DLL_PUBLIC -void ws_log_console_writer_set_use_stderr(bool use_stderr) +void ws_log_console_writer_set_use_stdout(bool use_stdout) { - stderr_debug_enabled = use_stderr; + stdout_logging_enabled = use_stdout; } diff --git a/wsutil/wslog.h b/wsutil/wslog.h index 437f12e163..943f2b017a 100644 --- a/wsutil/wslog.h +++ b/wsutil/wslog.h @@ -68,14 +68,14 @@ void ws_log_console_writer(const char *domain, enum ws_log_level level, const char *user_format, va_list user_ap); -/** Configure all log output to use stderr. +/** Configure log levels "info" and below to use stdout. * - * Normally log levels "info", "debug" and "noisy" are written to stdout. - * Calling this function with true configures these levels to be written - * to stderr as well. + * Normally all log messages are written to stderr. For backward compatibility + * with GLib calling this function with TRUE configures log levels "info", + * "debug" and "noisy" to be written to stdout. */ WS_DLL_PUBLIC -void ws_log_console_writer_set_use_stderr(bool use_stderr); +void ws_log_console_writer_set_use_stdout(bool use_stdout); /** Convert a numerical level to its string representation. */