aboutsummaryrefslogtreecommitdiffstats
path: root/randpkt.c
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2021-06-19 19:44:58 +0100
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2021-06-21 16:03:29 +0000
commit759bb234d0eb4d36947213fca2bc14e386c1cc8f (patch)
treeec9ba564273b0d0db43bd1d9691feee79d4a41d1 /randpkt.c
parentc216bb85e75e3db7050f937d6925ba85fb3e6803 (diff)
wslog: Check if we are initialized and add missing inits
Instead of receiving the program name from GLib, pass it explicitly to ws_log_init() instead and use that to initialize the GLib program name. ws_log_parse_args() will now exit the program when it encounters an argument error if exit_failure >= 0.
Diffstat (limited to 'randpkt.c')
-rw-r--r--randpkt.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/randpkt.c b/randpkt.c
index 8a85717bc5..700303ee65 100644
--- a/randpkt.c
+++ b/randpkt.c
@@ -29,6 +29,7 @@
#endif
#include <wsutil/report_message.h>
+#include <wsutil/wslog.h>
/*
* If we have getopt_long() in the system library, include <getopt.h>.
@@ -137,6 +138,14 @@ main(int argc, char *argv[])
{0, 0, 0, 0 }
};
+ /* Initialize log handler early so we can have proper logging during startup. */
+ ws_log_init("randpkt", NULL);
+
+ cmdarg_err_init(randpkt_cmdarg_err, randpkt_cmdarg_err_cont);
+
+ /* Early logging command-line initialization. */
+ ws_log_parse_args(&argc, argv, vcmdarg_err, INVALID_OPTION);
+
/*
* Get credential information for later use.
*/
@@ -158,8 +167,6 @@ main(int argc, char *argv[])
wtap_init(TRUE);
- cmdarg_err_init(randpkt_cmdarg_err, randpkt_cmdarg_err_cont);
-
#ifdef _WIN32
create_app_running_mutex();
#endif /* _WIN32 */