diff --git a/capinfos.c b/capinfos.c index 0f21f369e4..626353ec72 100644 --- a/capinfos.c +++ b/capinfos.c @@ -42,6 +42,7 @@ #include +#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN #include #include @@ -1611,6 +1612,8 @@ main(int argc, char *argv[]) /* Early logging command-line initialization. */ ws_log_parse_args(&argc, argv, vcmdarg_err, INVALID_OPTION); + ws_noisy("Finished log init and parsing command line log arguments"); + /* Get the decimal point. */ decimal_point = g_strdup(localeconv()->decimal_point); diff --git a/captype.c b/captype.c index b04326bd43..e3c2a92978 100644 --- a/captype.c +++ b/captype.c @@ -12,6 +12,7 @@ */ #include +#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN #include #include @@ -121,6 +122,8 @@ main(int argc, char *argv[]) /* Early logging command-line initialization. */ ws_log_parse_args(&argc, argv, vcmdarg_err, 1); + ws_noisy("Finished log init and parsing command line log arguments"); + /* Initialize the version information. */ ws_init_version_info("Captype", NULL, NULL); diff --git a/dftest.c b/dftest.c index 868e5b572a..ff0459d146 100644 --- a/dftest.c +++ b/dftest.c @@ -9,6 +9,7 @@ */ #include +#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN #include #include @@ -84,6 +85,8 @@ main(int argc, char **argv) /* Early logging command-line initialization. */ ws_log_parse_args(&argc, argv, vcmdarg_err, 1); + ws_noisy("Finished log init and parsing command line log arguments"); + /* * Get credential information for later use. */ diff --git a/dumpcap.c b/dumpcap.c index 5a1ca6e80e..5ac209015e 100644 --- a/dumpcap.c +++ b/dumpcap.c @@ -4910,6 +4910,8 @@ main(int argc, char *argv[]) /* Early logging command-line initialization. */ ws_log_parse_args(&argc, argv, vcmdarg_err, 1); + ws_noisy("Finished log init and parsing command line log arguments"); + #ifdef _WIN32 create_app_running_mutex(); diff --git a/editcap.c b/editcap.c index fb123bc521..e57e43d905 100644 --- a/editcap.c +++ b/editcap.c @@ -16,6 +16,7 @@ */ #include +#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN #include #include @@ -1187,6 +1188,8 @@ main(int argc, char *argv[]) /* Early logging command-line initialization. */ ws_log_parse_args(&argc, argv, vcmdarg_err, INVALID_OPTION); + ws_noisy("Finished log init and parsing command line log arguments"); + #ifdef _WIN32 create_app_running_mutex(); #endif /* _WIN32 */ diff --git a/extcap/extcap-base.c b/extcap/extcap-base.c index bb4615d47b..75ea64068e 100644 --- a/extcap/extcap-base.c +++ b/extcap/extcap-base.c @@ -169,6 +169,7 @@ 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); + ws_noisy("Extcap log initialization finished"); } uint8_t extcap_base_parse_options(extcap_parameters * extcap, int result, char * optargument) diff --git a/fuzz/fuzzshark.c b/fuzz/fuzzshark.c index e31ff8cd73..d793b559f1 100644 --- a/fuzz/fuzzshark.c +++ b/fuzz/fuzzshark.c @@ -10,6 +10,7 @@ */ #include +#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN #include #include @@ -244,6 +245,8 @@ fuzz_init(int argc _U_, char **argv) /* Early logging command-line initialization. */ ws_log_parse_args(&argc, argv, vcmdarg_err, LOG_ARGS_NOEXIT); + ws_noisy("Finished log init and parsing command line log arguments"); + /* * Get credential information for later use, and drop privileges * before doing anything else. diff --git a/mergecap.c b/mergecap.c index 5d56ce60a7..1720868dee 100644 --- a/mergecap.c +++ b/mergecap.c @@ -12,6 +12,7 @@ */ #include +#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN #include #include @@ -225,6 +226,8 @@ main(int argc, char *argv[]) /* Early logging command-line initialization. */ ws_log_parse_args(&argc, argv, vcmdarg_err, 1); + ws_noisy("Finished log init and parsing command line log arguments"); + #ifdef _WIN32 create_app_running_mutex(); #endif /* _WIN32 */ diff --git a/randpkt.c b/randpkt.c index e255e13c17..5647de4b3e 100644 --- a/randpkt.c +++ b/randpkt.c @@ -10,6 +10,7 @@ */ #include +#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN #include @@ -135,6 +136,8 @@ main(int argc, char *argv[]) /* Early logging command-line initialization. */ ws_log_parse_args(&argc, argv, vcmdarg_err, INVALID_OPTION); + ws_noisy("Finished log init and parsing command line log arguments"); + /* * Get credential information for later use. */ diff --git a/rawshark.c b/rawshark.c index ceee3998a2..99ca32c556 100644 --- a/rawshark.c +++ b/rawshark.c @@ -21,6 +21,7 @@ */ #include +#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN #include #include @@ -450,6 +451,8 @@ main(int argc, char *argv[]) /* Early logging command-line initialization. */ ws_log_parse_args(&argc, argv, vcmdarg_err, INVALID_OPTION); + ws_noisy("Finished log init and parsing command line log arguments"); + /* Initialize the version information. */ ws_init_version_info("Rawshark", epan_gather_compile_info, diff --git a/reordercap.c b/reordercap.c index 92c641e738..074a645b48 100644 --- a/reordercap.c +++ b/reordercap.c @@ -9,6 +9,7 @@ */ #include +#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN #include #include @@ -206,6 +207,8 @@ main(int argc, char *argv[]) /* Early logging command-line initialization. */ ws_log_parse_args(&argc, argv, vcmdarg_err, INVALID_OPTION); + ws_noisy("Finished log init and parsing command line log arguments"); + /* Initialize the version information. */ ws_init_version_info("Reordercap", NULL, NULL); diff --git a/sharkd.c b/sharkd.c index f354e973a3..209638dd66 100644 --- a/sharkd.c +++ b/sharkd.c @@ -10,6 +10,7 @@ */ #include +#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN #include #include @@ -124,6 +125,8 @@ main(int argc, char *argv[]) /* Early logging command-line initialization. */ ws_log_parse_args(&argc, argv, vcmdarg_err, INIT_FAILED); + ws_noisy("Finished log init and parsing command line log arguments"); + /* * Get credential information for later use, and drop privileges * before doing anything else. diff --git a/text2pcap.c b/text2pcap.c index 578439cea3..b01867ee8f 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -65,6 +65,7 @@ */ #include +#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN #include #include @@ -1010,6 +1011,8 @@ main(int argc, char *argv[]) /* Early logging command-line initialization. */ ws_log_parse_args(&argc, argv, vcmdarg_err, INVALID_OPTION); + ws_noisy("Finished log init and parsing command line log arguments"); + #ifdef _WIN32 create_app_running_mutex(); #endif /* _WIN32 */ diff --git a/tfshark.c b/tfshark.c index 6d78904646..52278f30e4 100644 --- a/tfshark.c +++ b/tfshark.c @@ -341,6 +341,8 @@ main(int argc, char *argv[]) /* Early logging command-line initialization. */ ws_log_parse_args(&argc, argv, vcmdarg_err, INVALID_OPTION); + ws_noisy("Finished log init and parsing command line log arguments"); + #ifdef _WIN32 create_app_running_mutex(); #endif /* _WIN32 */ diff --git a/tshark.c b/tshark.c index e77bcefad6..066491fb50 100644 --- a/tshark.c +++ b/tshark.c @@ -866,6 +866,7 @@ main(int argc, char *argv[]) /* Early logging command-line initialization. */ ws_log_parse_args(&argc, argv, vcmdarg_err, INVALID_OPTION); + ws_noisy("Finished log init and parsing command line log arguments"); ws_debug("tshark started with %d args", argc); #ifdef _WIN32 diff --git a/ui/logray/logray_main.cpp b/ui/logray/logray_main.cpp index cda2152e9a..110fe70642 100644 --- a/ui/logray/logray_main.cpp +++ b/ui/logray/logray_main.cpp @@ -8,6 +8,7 @@ */ #include +#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN #include @@ -486,6 +487,7 @@ int main(int argc, char *qt_argv[]) ws_log_init_with_writer("logray", console_log_writer, vcmdarg_err); /* For backward compatibility with GLib logging and Wireshark 3.4. */ ws_log_console_writer_set_use_stdout(TRUE); + ws_noisy("Finished log init and parsing command line log arguments"); qInstallMessageHandler(qt_log_message_handler); diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index 87c02a95ac..8281b54eed 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -8,6 +8,7 @@ */ #include +#define WS_LOG_DOMAIN LOG_DOMAIN_MAIN #include @@ -488,6 +489,7 @@ int main(int argc, char *qt_argv[]) 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); + ws_noisy("Finished log init and parsing command line log arguments"); qInstallMessageHandler(qt_log_message_handler); diff --git a/wsutil/wslog.c b/wsutil/wslog.c index f118f93157..a62d443e74 100644 --- a/wsutil/wslog.c +++ b/wsutil/wslog.c @@ -37,6 +37,12 @@ #include "strtoi.h" +#ifndef WS_DISABLE_ASSERT +#define ASSERT(expr) assert(expr) +#else +#define ASSERT(expr) (void)(expr); +#endif + /* Runtime log level. */ #define ENV_VAR_LEVEL "WIRESHARK_LOG_LEVEL" @@ -118,9 +124,7 @@ static FILE *custom_log = NULL; static enum ws_log_level fatal_log_level = LOG_LEVEL_ERROR; -#ifndef WS_DISABLE_DEBUG static bool init_complete = false; -#endif static void print_err(void (*vcmdarg_err)(const char *, va_list ap), @@ -371,7 +375,7 @@ parse_console_compat_option(char *argv[], uint32_t mask; enum ws_log_level level; - assert(argv != NULL); + ASSERT(argv != NULL); if (argv[0] == NULL) return; @@ -440,8 +444,8 @@ parse_console_compat_option(char *argv[], /* Match "arg_name=value" or "arg_name value" to opt_name. */ static bool optequal(const char *arg, const char *opt) { - ws_assert(arg); - ws_assert(opt); + ASSERT(arg); + ASSERT(opt); #define ARGEND(arg) (*(arg) == '\0' || *(arg) == ' ' || *(arg) == '=') while (!ARGEND(arg) && *opt != '\0') { @@ -471,6 +475,9 @@ int ws_log_parse_args(int *argc_ptr, char *argv[], if (argc_ptr == NULL || argv == NULL) return -1; + /* Assert ws_log_init() was called before ws_log_parse_args(). */ + ASSERT(init_complete); + /* Configure from command line. */ while (*ptr != NULL) { @@ -636,8 +643,8 @@ static void tokenize_filter_str(log_filter_t **filter_ptr, bool negated = false; log_filter_t *filter; - assert(filter_ptr); - assert(*filter_ptr == NULL); + ASSERT(filter_ptr); + ASSERT(*filter_ptr == NULL); if (str_filter == NULL) return; @@ -846,9 +853,7 @@ void ws_log_init(const char *progname, if (env != NULL) ws_log_set_noisy_filter(env); -#ifndef WS_DISABLE_DEBUG init_complete = true; -#endif } @@ -925,10 +930,8 @@ static void log_write_do_work(FILE *fp, bool use_color, const char *file, long line, const char *func, const char *user_format, va_list user_ap) { -#ifndef WS_DISABLE_DEBUG if (!init_complete) fputs(" ** (noinit)", fp); -#endif /* Process */ fprintf(fp, " ** (%s:%ld) ", registered_progname, (long)getpid());