diff --git a/debian/libwsutil0.symbols b/debian/libwsutil0.symbols index 9c1166cece..600487064e 100644 --- a/debian/libwsutil0.symbols +++ b/debian/libwsutil0.symbols @@ -235,6 +235,7 @@ libwsutil.so.0 libwsutil0 #MINVER# ws_log_level_is_active@Base 3.5.0 ws_log_level_to_string@Base 3.5.0 ws_log_parse_args@Base 3.5.0 + ws_log_print_usage@Base 3.5.0 ws_log_set_debug_filter@Base 3.5.0 ws_log_set_domain_filter@Base 3.5.0 ws_log_set_noisy_filter@Base 3.5.0 diff --git a/doc/tshark.pod b/doc/tshark.pod index 410db5db98..c49523c7c0 100644 --- a/doc/tshark.pod +++ b/doc/tshark.pod @@ -2073,6 +2073,25 @@ it will, on some OSes, assuming your environment is configured correctly, generate a core dump file. This can be useful to developers attempting to troubleshoot a problem with a protocol dissector. +=item WIRESHARK_LOG_LEVEL + +This environment variable controls the verbosity of diagnostic messages to +the console. From less verbose to most verbose levels can be C, +C, C, C or C. Levels above the current level +are also active. Levels C and C are always active. + +=item WIRESHARK_LOG_DOMAINS + +This environment variable selects with log domains are active. The filter is +given as a case-insensitive comma separated list. If set only the included +domains will be enabled. The default domain is always considered to be enabled. +Domain filter lists can be preceded by '!' to invert the sense of the match. + +=item WIRESHARK_LOG_DEBUG + +List of domains with C log level. This sets the level of the listed +log domains and takes precedence over the active domains filter. + =back =head1 SEE ALSO diff --git a/doc/wireshark.pod.template b/doc/wireshark.pod.template index d097f4cf6d..ad098b5c5e 100644 --- a/doc/wireshark.pod.template +++ b/doc/wireshark.pod.template @@ -2931,6 +2931,25 @@ that. You must also specify an autostop condition, e.g. B<-c> or B<-a duration:...>. This means that you will not be able to see the results of the capture after it stops; it's primarily useful for testing. +=item WIRESHARK_LOG_LEVEL + +This environment variable controls the verbosity of diagnostic messages to +the console. From less verbose to most verbose levels can be C, +C, C, C or C. Levels above the current level +are also active. Levels C and C are always active. + +=item WIRESHARK_LOG_DOMAINS + +This environment variable selects with log domains are active. The filter is +given as a case-insensitive comma separated list. If set only the included +domains will be enabled. The default domain is always considered to be enabled. +Domain filter lists can be preceded by '!' to invert the sense of the match. + +=item WIRESHARK_LOG_DEBUG + +List of domains with C log level. This sets the level of the listed +log domains and takes precedence over the active domains filter. + =back =head1 SEE ALSO diff --git a/docbook/wsdg_src/WSDG_chapter_sources.adoc b/docbook/wsdg_src/WSDG_chapter_sources.adoc index 779e46af40..bad8cb8638 100644 --- a/docbook/wsdg_src/WSDG_chapter_sources.adoc +++ b/docbook/wsdg_src/WSDG_chapter_sources.adoc @@ -296,11 +296,12 @@ You can debug using command-line debuggers such as gdb, dbx, or lldb. If you prefer a graphic debugger, you can use an IDE or debugging frontend such as Qt Creator, CLion, or Eclipse. -Additional traps can be set on GLib by setting the `G_DEBUG` environment variable: +Additional traps can be set on Wireshark by setting the `WIRESHARK_LOG_FATAL` +environment variable: [source,sh] ---- -$ G_DEBUG=fatal_criticals gdb wireshark +$ WIRESHARK_LOG_FATAL=critical gdb wireshark ---- If you're encountering memory safety bugs, you might want to build with diff --git a/dumpcap.c b/dumpcap.c index 815a0d8a94..f0c6a6b996 100644 --- a/dumpcap.c +++ b/dumpcap.c @@ -443,6 +443,9 @@ print_usage(FILE *output) fprintf(output, " add a capture comment to the output file\n"); fprintf(output, " (only for pcapng)\n"); fprintf(output, "\n"); + + ws_log_print_usage(output); + fprintf(output, "Miscellaneous:\n"); fprintf(output, " -N maximum number of packets buffered within dumpcap\n"); fprintf(output, " -C maximum number of bytes used for buffering packets\n"); diff --git a/rawshark.c b/rawshark.c index c39809af73..471a89375c 100644 --- a/rawshark.c +++ b/rawshark.c @@ -201,6 +201,8 @@ print_usage(FILE *output) fprintf(output, " (%%D - name, %%S - stringval, %%N numval)\n"); fprintf(output, " -t ad|a|r|d|dd|e output format of time stamps (def: r: rel. to first)\n"); + ws_log_print_usage(output); + fprintf(output, "\n"); fprintf(output, "Miscellaneous:\n"); fprintf(output, " -h display this help and exit\n"); diff --git a/tfshark.c b/tfshark.c index a6b595691e..f0bb001da5 100644 --- a/tfshark.c +++ b/tfshark.c @@ -212,6 +212,8 @@ print_usage(FILE *output) fprintf(output, " -X : eXtension options, see the man page for details\n"); fprintf(output, " -z various statistics, see the man page for details\n"); + ws_log_print_usage(output); + fprintf(output, "\n"); fprintf(output, "Miscellaneous:\n"); fprintf(output, " -h display this help and exit\n"); diff --git a/tshark.c b/tshark.c index 3fed589a8e..73572b4c55 100644 --- a/tshark.c +++ b/tshark.c @@ -479,6 +479,8 @@ print_usage(FILE *output) fprintf(output, " --elastic-mapping-filter If -G elastic-mapping is specified, put only the\n"); fprintf(output, " specified protocols within the mapping file\n"); + ws_log_print_usage(output); + fprintf(output, "\n"); fprintf(output, "Miscellaneous:\n"); fprintf(output, " -h, --help display this help and exit\n"); diff --git a/ui/commandline.c b/ui/commandline.c index e4b9d4f74d..3972711231 100644 --- a/ui/commandline.c +++ b/ui/commandline.c @@ -175,6 +175,8 @@ commandline_print_usage(gboolean for_help_option) { fprintf(output, " --capture-comment \n"); fprintf(output, " set the capture file comment, if supported\n"); + ws_log_print_usage(output); + fprintf(output, "\n"); fprintf(output, "Miscellaneous:\n"); fprintf(output, " -h, --help display this help and exit\n"); diff --git a/wsutil/wslog.c b/wsutil/wslog.c index 98baeb6992..6bc49b4843 100644 --- a/wsutil/wslog.c +++ b/wsutil/wslog.c @@ -682,3 +682,15 @@ void ws_log_add_custom_file(FILE *fp) } custom_log = fp; } + + +void ws_log_print_usage(FILE *fp) +{ + fprintf(fp, "Diagnostic output:\n"); + fprintf(fp, " --log-level one of \"critical\", \"warning\", \"message\"," + "\"info\", \"debug\" or \"noisy\"\n"); + fprintf(fp, " --log-domains comma separated list of the active log domains\n"); + fprintf(fp, " --log-file path of file to output messages to (in addition to stderr)\n"); + fprintf(fp, " --log-debug comma separated list of domains with \"debug\" level\n"); + fprintf(fp, " --log-noisy comma separated list of domains with \"noisy\" level\n"); +} diff --git a/wsutil/wslog.h b/wsutil/wslog.h index d8980414e6..b013547d3e 100644 --- a/wsutil/wslog.h +++ b/wsutil/wslog.h @@ -16,6 +16,7 @@ #include #ifndef WS_LOG_DOMAIN +/* Should this be an error instead? */ #define WS_LOG_DOMAIN LOG_DOMAIN_DEFAULT #endif @@ -264,6 +265,10 @@ void ws_logv_full(const char *domain, enum ws_log_level level, WS_DLL_PUBLIC void ws_log_add_custom_file(FILE *fp); + +WS_DLL_PUBLIC +void ws_log_print_usage(FILE *fp); + #ifdef __cplusplus } #endif /* __cplusplus */