aboutsummaryrefslogtreecommitdiffstats
path: root/capture_opts.h
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2021-06-08 02:46:52 +0100
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2021-06-11 09:40:28 +0000
commitdc7f0b88bba0c703d9c802b153e145dc6b3dc549 (patch)
tree73dbaea334bb87e991332eeef828f85a8120b4d0 /capture_opts.h
parentc0f8812c31f5e9e0f86eb8a627034211dfb7431f (diff)
Refactor our logging and extend the wslog API
Experience has shown that: 1. The current logging methods are not very reliable or practical. A logging bitmask makes little sense as the user-facing interface (who would want debug but not crtical messages for example?); it's computer-friendly and user-unfriendly. More importantly the console log level preference is initialized too late in the startup process to be used for the logging subsystem and that fact raises a number of annoying and hard-to-fix usability issues. 2. Coding around G_MESSAGES_DEBUG to comply with our log level mask and not clobber the user's settings or not create unexpected log misses is unworkable and generally follows the principle of most surprise. The fact that G_MESSAGES_DEBUG="all" can leak to other programs using GLib is also annoying. 3. The non-structured GLib logging API is very opinionated and lacks configurability beyond replacing the log handler. 4. Windows GUI has some special code to attach to a console, but it would be nice to abstract away the rest under a single interface. 5. Using this logger seems to be noticeably faster. Deprecate the console log level preference and extend our API to implement a log handler in wsutil/wslog.h to provide easy-to-use, flexible and dependable logging during all execution phases. Log levels have a hierarchy, from most verbose to least verbose (debug to error). When a given level is set everything above that is also enabled. The log level can be set with an environment variable or a command line option (parsed as soon as possible but still later than the environment). The default log level is "message". Dissector logging is not included because it is not clear what log domain they should use. An explosion to thousands of domains is not desirable and putting everything in a single domain is probably too coarse and noisy. For now I think it makes sense to let them do their own thing using g_log_default_handler() and continue using the G_MESSAGES_DEBUG mechanism with specific domains for each individual dissector. In the future a mechanism may be added to selectively enable these domains at runtime while trying to avoid the problems introduced by G_MESSAGES_DEBUG.
Diffstat (limited to 'capture_opts.h')
-rw-r--r--capture_opts.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/capture_opts.h b/capture_opts.h
index c815c53586..2c6fffc8a3 100644
--- a/capture_opts.h
+++ b/capture_opts.h
@@ -22,6 +22,7 @@
#include <capture/capture_ifinfo.h>
#include "ringbuffer.h"
+#include <wsutil/wslog.h>
#ifdef _WIN32
#include <windows.h>
@@ -338,7 +339,7 @@ capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg)
/* log content of capture_opts */
extern void
-capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_options *capture_opts);
+capture_opts_log(enum ws_log_domain domain, enum ws_log_level level, capture_options *capture_opts);
enum caps_query {
CAPS_QUERY_LINK_TYPES = 0x1,