aboutsummaryrefslogtreecommitdiffstats
path: root/capture
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
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')
-rw-r--r--capture/capture-pcap-util.c43
-rw-r--r--capture/capture_ifinfo.c18
-rw-r--r--capture/capture_sync.c90
-rw-r--r--capture/capture_win_ifnames.c2
4 files changed, 61 insertions, 92 deletions
diff --git a/capture/capture-pcap-util.c b/capture/capture-pcap-util.c
index 3dc6c9d181..f9dda3cf9a 100644
--- a/capture/capture-pcap-util.c
+++ b/capture/capture-pcap-util.c
@@ -9,6 +9,7 @@
*/
#include "config.h"
+#define WS_LOG_DOMAIN LOG_DOMAIN_CAPCHILD
#ifdef HAVE_LIBPCAP
@@ -68,10 +69,9 @@
#include "capture/capture-pcap-util.h"
#include "capture/capture-pcap-util-int.h"
-#include "log.h"
-
#include <wsutil/file_util.h>
#include <wsutil/please_report_bug.h>
+#include <wsutil/wslog.h>
#ifndef _WIN32
#include <netinet/in.h>
@@ -1275,23 +1275,19 @@ open_capture_device_pcap_create(
pcap_t *pcap_h;
int status;
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
- "Calling pcap_create() using %s.", interface_opts->name);
+ ws_debug("Calling pcap_create() using %s.", interface_opts->name);
pcap_h = pcap_create(interface_opts->name, *open_err_str);
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
- "pcap_create() returned %p.", (void *)pcap_h);
+ ws_debug("pcap_create() returned %p.", (void *)pcap_h);
if (pcap_h == NULL) {
*open_err = CAP_DEVICE_OPEN_ERR_NOT_PERMISSIONS;
return NULL;
}
if (interface_opts->has_snaplen) {
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
- "Calling pcap_set_snaplen() with snaplen %d.",
+ ws_debug("Calling pcap_set_snaplen() with snaplen %d.",
interface_opts->snaplen);
pcap_set_snaplen(pcap_h, interface_opts->snaplen);
}
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
- "Calling pcap_set_promisc() with promisc_mode %d.",
+ ws_debug("Calling pcap_set_promisc() with promisc_mode %d.",
interface_opts->promisc_mode);
pcap_set_promisc(pcap_h, interface_opts->promisc_mode);
pcap_set_timeout(pcap_h, timeout);
@@ -1337,18 +1333,15 @@ open_capture_device_pcap_create(
}
#endif /* HAVE_PCAP_SET_TSTAMP_PRECISION */
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
- "buffersize %d.", interface_opts->buffer_size);
+ ws_debug("buffersize %d.", interface_opts->buffer_size);
if (interface_opts->buffer_size != 0)
pcap_set_buffer_size(pcap_h,
interface_opts->buffer_size * 1024 * 1024);
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
- "monitor_mode %d.", interface_opts->monitor_mode);
+ ws_debug("monitor_mode %d.", interface_opts->monitor_mode);
if (interface_opts->monitor_mode)
pcap_set_rfmon(pcap_h, 1);
status = pcap_activate(pcap_h);
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
- "pcap_activate() returned %d.", status);
+ ws_debug("pcap_activate() returned %d.", status);
if (status < 0) {
/* Failed to activate, set to NULL */
if (status == PCAP_ERROR) {
@@ -1424,13 +1417,11 @@ open_capture_device_pcap_open_live(interface_options *interface_opts,
*/
snaplen = 256*1024;
}
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
- "pcap_open_live() calling using name %s, snaplen %d, promisc_mode %d.",
+ ws_debug("pcap_open_live() calling using name %s, snaplen %d, promisc_mode %d.",
interface_opts->name, snaplen, interface_opts->promisc_mode);
pcap_h = pcap_open_live(interface_opts->name, snaplen,
interface_opts->promisc_mode, timeout, *open_err_str);
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
- "pcap_open_live() returned %p.", (void *)pcap_h);
+ ws_debug("pcap_open_live() returned %p.", (void *)pcap_h);
if (pcap_h == NULL) {
*open_err = CAP_DEVICE_OPEN_ERR_GENERIC;
return NULL;
@@ -1538,7 +1529,7 @@ open_capture_device(capture_options *capture_opts,
Some versions of libpcap may put warnings into the error buffer
if they succeed; to tell if that's happened, we have to clear
the error buffer, and check if it's still a null string. */
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Entering open_capture_device().");
+ ws_debug("Entering open_capture_device().");
*open_err = CAP_DEVICE_OPEN_NO_ERR;
(*open_err_str)[0] = '\0';
#if defined(HAVE_PCAP_OPEN) && defined(HAVE_PCAP_REMOTE)
@@ -1563,8 +1554,7 @@ open_capture_device(capture_options *capture_opts,
*/
snaplen = 256*1024;
}
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
- "Calling pcap_open() using name %s, snaplen %d, promisc_mode %d, datatx_udp %d, nocap_rpcap %d.",
+ ws_debug("Calling pcap_open() using name %s, snaplen %d, promisc_mode %d, datatx_udp %d, nocap_rpcap %d.",
interface_opts->name, snaplen,
interface_opts->promisc_mode, interface_opts->datatx_udp,
interface_opts->nocap_rpcap);
@@ -1597,16 +1587,15 @@ open_capture_device(capture_options *capture_opts,
sizeof *open_err_str);
}
}
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
- "pcap_open() returned %p.", (void *)pcap_h);
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "open_capture_device %s : %s", pcap_h ? "SUCCESS" : "FAILURE", interface_opts->name);
+ ws_debug("pcap_open() returned %p.", (void *)pcap_h);
+ ws_debug("open_capture_device %s : %s", pcap_h ? "SUCCESS" : "FAILURE", interface_opts->name);
return pcap_h;
}
#endif
pcap_h = open_capture_device_local(capture_opts, interface_opts,
timeout, open_err, open_err_str);
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "open_capture_device %s : %s", pcap_h ? "SUCCESS" : "FAILURE", interface_opts->name);
+ ws_debug("open_capture_device %s : %s", pcap_h ? "SUCCESS" : "FAILURE", interface_opts->name);
return pcap_h;
}
diff --git a/capture/capture_ifinfo.c b/capture/capture_ifinfo.c
index 396d0733cf..40e0f03944 100644
--- a/capture/capture_ifinfo.c
+++ b/capture/capture_ifinfo.c
@@ -9,6 +9,7 @@
*/
#include "config.h"
+#define WS_LOG_DOMAIN LOG_DOMAIN_CAPTURE
#ifdef HAVE_LIBPCAP
@@ -23,7 +24,6 @@
#include "capture/capture_session.h"
#include "capture/capture_sync.h"
#include "extcap.h"
-#include "log.h"
#include <capture/capture_ifinfo.h>
#include <wsutil/inet_addr.h>
@@ -90,8 +90,6 @@ capture_interface_list(int *err, char **err_str, void (*update_cb)(void))
if_info_t *if_info;
if_addr_t *if_addr;
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface List ...");
-
*err = 0;
if (err_str) {
*err_str = NULL;
@@ -101,12 +99,12 @@ capture_interface_list(int *err, char **err_str, void (*update_cb)(void))
ret = sync_interface_list_open(&data, &primary_msg, &secondary_msg, update_cb);
if (ret != 0) {
/* Add the extcap interfaces that can exist, even if no native interfaces have been found */
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Loading External Capture Interface List ...");
+ ws_message("Loading External Capture Interface List ...");
if_list = append_extcap_interface_list(if_list, err_str);
/* err_str is ignored, as the error for the interface loading list will take precedence */
if ( g_list_length(if_list) == 0 ) {
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface List failed. Error %d, %s (%s)",
+ ws_message("Capture Interface List failed. Error %d, %s (%s)",
*err, primary_msg ? primary_msg : "no message",
secondary_msg ? secondary_msg : "no secondary message");
if (err_str) {
@@ -185,7 +183,7 @@ capture_interface_list(int *err, char **err_str, void (*update_cb)(void))
#endif
/* Add the extcap interfaces after the native and remote interfaces */
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Loading External Capture Interface List ...");
+ ws_message("Loading External Capture Interface List ...");
if_list = append_extcap_interface_list(if_list, err_str);
return if_list;
@@ -205,8 +203,6 @@ capture_get_if_capabilities(const gchar *ifname, gboolean monitor_mode,
gchar *data, *primary_msg, *secondary_msg;
gchar **raw_list;
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface Capabilities ...");
-
/* see if the interface is from extcap */
caps = extcap_get_if_dlts(ifname, err_primary_msg);
if (caps != NULL)
@@ -220,7 +216,7 @@ capture_get_if_capabilities(const gchar *ifname, gboolean monitor_mode,
err = sync_if_capabilities_open(ifname, monitor_mode, auth_string, &data,
&primary_msg, &secondary_msg, update_cb);
if (err != 0) {
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface Capabilities failed. Error %d, %s",
+ ws_message("Capture Interface Capabilities failed. Error %d, %s",
err, primary_msg ? primary_msg : "no message");
if (err_primary_msg)
*err_primary_msg = primary_msg;
@@ -245,7 +241,7 @@ capture_get_if_capabilities(const gchar *ifname, gboolean monitor_mode,
* First line is 0 if monitor mode isn't supported, 1 if it is.
*/
if (raw_list[0] == NULL || *raw_list[0] == '\0') {
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface Capabilities returned no information.");
+ ws_message("Capture Interface Capabilities returned no information.");
if (err_primary_msg) {
*err_primary_msg = g_strdup("Dumpcap returned no interface capability information");
}
@@ -268,7 +264,7 @@ capture_get_if_capabilities(const gchar *ifname, gboolean monitor_mode,
break;
default:
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface Capabilities returned bad information.");
+ ws_message("Capture Interface Capabilities returned bad information.");
if (err_primary_msg) {
*err_primary_msg = g_strdup_printf("Dumpcap returned \"%s\" for monitor-mode capability",
raw_list[0]);
diff --git a/capture/capture_sync.c b/capture/capture_sync.c
index afd9f47778..88af85b9e6 100644
--- a/capture/capture_sync.c
+++ b/capture/capture_sync.c
@@ -9,6 +9,7 @@
*/
#include "config.h"
+#define WS_LOG_DOMAIN LOG_DOMAIN_CAPTURE
#ifdef HAVE_LIBPCAP
@@ -20,6 +21,7 @@
#include <signal.h>
#include <wsutil/strtoi.h>
+#include <wsutil/wslog.h>
#ifdef _WIN32
#include <wsutil/unicode-utils.h>
@@ -81,7 +83,6 @@
#include <wsutil/file_util.h>
#include <wsutil/report_message.h>
#include "extcap.h"
-#include "log.h"
#ifdef _WIN32
#include <process.h> /* For spawning child process */
@@ -230,8 +231,8 @@ sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, inf
if (capture_opts->ifaces->len > 1)
capture_opts->use_pcapng = TRUE;
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_start");
- capture_opts_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, capture_opts);
+ ws_debug("sync_pipe_start");
+ capture_opts_log(LOG_DOMAIN_CAPTURE, LOG_LEVEL_DEBUG, capture_opts);
cap_session->fork_child = WS_INVALID_PID;
@@ -447,7 +448,7 @@ sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, inf
argv = sync_pipe_add_arg(argv, &argc, capture_opts->save_file);
}
for (i = 0; i < argc; i++) {
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "argv[%d]: %s", i, argv[i]);
+ ws_debug("argv[%d]: %s", i, argv[i]);
}
if (capture_opts->compress_type) {
argv = sync_pipe_add_arg(argv, &argc, "--compress-type");
@@ -682,7 +683,7 @@ sync_pipe_open_command(char* const argv[], int *data_read_fd,
*fork_child = WS_INVALID_PID;
*data_read_fd = -1;
*message_read_fd = -1;
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_open_command");
+ ws_debug("sync_pipe_open_command");
if (!msg) {
/* We can't return anything */
@@ -1096,21 +1097,21 @@ sync_pipe_run_command(char* const argv[], gchar **data, gchar **primary_msg,
int logging_enabled;
/* check if logging is actually enabled, otherwise don't expend the CPU generating logging */
- logging_enabled=( (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO) & G_LOG_LEVEL_MASK & prefs.console_log_level);
- if(logging_enabled){
+ logging_enabled = ws_log_level_is_active(LOG_LEVEL_INFO);
+ if (logging_enabled) {
start_time = g_get_monotonic_time();
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "sync_pipe_run_command() starts");
- for(i=0; argv[i] != 0; i++) {
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, " argv[%d]: %s", i, argv[i]);
+ ws_info("sync_pipe_run_command() starts");
+ for (i=0; argv[i] != 0; i++) {
+ ws_debug(" argv[%d]: %s", i, argv[i]);
}
}
/* do the actual sync pipe run command */
- ret=sync_pipe_run_command_actual(argv, data, primary_msg, secondary_msg, update_cb);
+ ret = sync_pipe_run_command_actual(argv, data, primary_msg, secondary_msg, update_cb);
- if(logging_enabled){
+ if (logging_enabled) {
elapsed = (g_get_monotonic_time() - start_time) / 1e6;
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "sync_pipe_run_command() ends, taking %.3fs, result=%d", elapsed, ret);
+ ws_info("sync_pipe_run_command() ends, taking %.3fs, result=%d", elapsed, ret);
}
return ret;
@@ -1191,7 +1192,7 @@ sync_interface_list_open(gchar **data, gchar **primary_msg,
char **argv;
int ret;
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_interface_list_open");
+ ws_debug("sync_interface_list_open");
argv = init_pipe_args(&argc);
@@ -1236,7 +1237,7 @@ sync_if_capabilities_open(const gchar *ifname, gboolean monitor_mode, const gcha
char **argv;
int ret;
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_if_capabilities_open");
+ ws_debug("sync_if_capabilities_open");
argv = init_pipe_args(&argc);
@@ -1291,7 +1292,7 @@ sync_interface_stats_open(int *data_read_fd, ws_process_id *fork_child, gchar **
/*char *secondary_msg_text;*/
char *combined_msg;
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_interface_stats_open");
+ ws_debug("sync_interface_stats_open");
argv = init_pipe_args(&argc);
@@ -1456,17 +1457,14 @@ pipe_read_bytes(int pipe_fd, char *bytes, int required, char **msg)
newly = ws_read(pipe_fd, &bytes[offset], required);
if (newly == 0) {
/* EOF */
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
- "read from pipe %d: EOF (capture closed?)", pipe_fd);
+ ws_debug("read from pipe %d: EOF (capture closed?)", pipe_fd);
*msg = 0;
return offset;
}
if (newly < 0) {
/* error */
error = errno;
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
- "read from pipe %d: error(%u): %s", pipe_fd, error,
- g_strerror(error));
+ ws_debug("read from pipe %d: error(%u): %s", pipe_fd, error, g_strerror(error));
*msg = g_strdup_printf("Error reading from sync pipe: %s",
g_strerror(error));
return newly;
@@ -1501,8 +1499,7 @@ sync_pipe_gets_nonblock(int pipe_fd, char *bytes, int max) {
break;
} else if (newly == -1) {
/* error */
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
- "read from pipe %d: error(%u): %s", pipe_fd, errno, g_strerror(errno));
+ ws_debug("read from pipe %d: error(%u): %s", pipe_fd, errno, g_strerror(errno));
return -1;
} else if (bytes[offset] == '\n') {
break;
@@ -1547,12 +1544,10 @@ pipe_read_block(int pipe_fd, char *indicator, int len, char *msg,
* is an "I'm done" indication, so don't report it as an
* error.
*/
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
- "read %d got an EOF", pipe_fd);
+ ws_debug("read %d got an EOF", pipe_fd);
return 0;
}
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
- "read %d failed to read header: %lu", pipe_fd, (long)newly);
+ ws_debug("read %d failed to read header: %lu", pipe_fd, (long)newly);
if (newly != -1) {
/*
* Short read, but not an immediate EOF.
@@ -1568,15 +1563,13 @@ pipe_read_block(int pipe_fd, char *indicator, int len, char *msg,
/* only indicator with no value? */
if(required == 0) {
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
- "read %d indicator: %c empty value", pipe_fd, *indicator);
+ ws_debug("read %d indicator: %c empty value", pipe_fd, *indicator);
return 4;
}
/* does the data fit into the given buffer? */
if(required > len) {
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
- "read %d length error, required %d > len %d, header: 0x%02x 0x%02x 0x%02x 0x%02x",
+ ws_debug("read %d length error, required %d > len %d, header: 0x%02x 0x%02x 0x%02x 0x%02x",
pipe_fd, required, len,
header[0], header[1], header[2], header[3]);
@@ -1584,8 +1577,7 @@ pipe_read_block(int pipe_fd, char *indicator, int len, char *msg,
memcpy(msg, header, sizeof(header));
newly = ws_read(pipe_fd, &msg[sizeof(header)], len-sizeof(header));
if (newly < 0) { /* error */
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
- "read from pipe %d: error(%u): %s", pipe_fd, errno, g_strerror(errno));
+ ws_debug("read from pipe %d: error(%u): %s", pipe_fd, errno, g_strerror(errno));
}
*err_msg = g_strdup_printf("Unknown message from dumpcap reading header, try to show it as a string: %s",
msg);
@@ -1604,9 +1596,7 @@ pipe_read_block(int pipe_fd, char *indicator, int len, char *msg,
}
/* XXX If message is "2part", the msg probably won't be sent to debug log correctly */
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
- "read %d ok indicator: %c len: %u msg: %s", pipe_fd, *indicator,
- len, msg);
+ ws_debug("read %d ok indicator: %c len: %u msg: %s", pipe_fd, *indicator, len, msg);
*err_msg = NULL;
return newly + 4;
}
@@ -1672,7 +1662,7 @@ sync_pipe_input_cb(gint source, gpointer user_data)
#ifdef _WIN32
ws_close(cap_session->signal_pipe_write_fd);
#endif
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_input_cb: cleaning extcap pipe");
+ ws_debug("cleaning extcap pipe");
extcap_if_cleanup(cap_session->capture_opts, &primary_msg);
cap_session->closed(cap_session, primary_msg);
g_free(primary_msg);
@@ -1683,7 +1673,7 @@ sync_pipe_input_cb(gint source, gpointer user_data)
switch(indicator) {
case SP_FILE:
if(!cap_session->new_file(cap_session, buffer)) {
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_input_cb: file failed, closing capture");
+ ws_debug("file failed, closing capture");
/* We weren't able to open the new capture file; user has been
alerted. Close the sync pipe. */
@@ -1708,9 +1698,9 @@ sync_pipe_input_cb(gint source, gpointer user_data)
break;
case SP_PACKET_COUNT:
if (!ws_strtou32(buffer, NULL, &npackets)) {
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_WARNING, "Invalid packets number: %s", buffer);
+ ws_warning("Invalid packets number: %s", buffer);
}
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_input_cb: new packets %u", npackets);
+ ws_debug("new packets %u", npackets);
cap_session->count += npackets;
cap_session->new_packets(cap_session, npackets);
break;
@@ -1781,7 +1771,7 @@ sync_pipe_wait_for_child(ws_process_id fork_child, gchar **msgp)
start_time = g_get_monotonic_time();
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_wait_for_child: wait till child closed");
+ ws_debug("wait till child closed");
g_assert(fork_child != WS_INVALID_PID);
*msgp = NULL; /* assume no error */
@@ -1849,7 +1839,7 @@ sync_pipe_wait_for_child(ws_process_id fork_child, gchar **msgp)
* kills dumpcap, so we should eventually see that and
* clean up and terminate.
*/
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_WARNING, "sync_pipe_wait_for_child: waitpid returned EINTR. retrying.");
+ ws_warning("waitpid returned EINTR. retrying.");
continue;
} else if (errno == ECHILD) {
/*
@@ -1870,7 +1860,7 @@ sync_pipe_wait_for_child(ws_process_id fork_child, gchar **msgp)
#endif
elapsed = (g_get_monotonic_time() - start_time) / 1e6;
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_wait_for_child: capture child closed after %.3fs", elapsed);
+ ws_debug("capture child closed after %.3fs", elapsed);
return ret;
}
@@ -1997,15 +1987,14 @@ signal_pipe_capquit_to_child(capture_session *cap_session)
const char quit_msg[] = "QUIT";
int ret;
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "signal_pipe_capquit_to_child");
+ ws_debug("signal_pipe_capquit_to_child");
/* it doesn't matter *what* we send here, the first byte will stop the capture */
/* simply sending a "QUIT" string */
/*pipe_write_block(cap_session->signal_pipe_write_fd, SP_QUIT, quit_msg);*/
ret = ws_write(cap_session->signal_pipe_write_fd, quit_msg, sizeof quit_msg);
if(ret == -1) {
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_WARNING,
- "signal_pipe_capquit_to_child: %d header: error %s", cap_session->signal_pipe_write_fd, g_strerror(errno));
+ ws_warning("%d header: error %s", cap_session->signal_pipe_write_fd, g_strerror(errno));
}
}
#endif
@@ -2025,8 +2014,7 @@ sync_pipe_stop(capture_session *cap_session)
/* send the SIGINT signal to close the capture child gracefully. */
int sts = kill(cap_session->fork_child, SIGINT);
if (sts != 0) {
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_WARNING,
- "Sending SIGINT to child failed: %s\n", g_strerror(errno));
+ ws_warning("Sending SIGINT to child failed: %s\n", g_strerror(errno));
}
#else
#define STOP_SLEEP_TIME 500 /* ms */
@@ -2048,8 +2036,7 @@ sync_pipe_stop(capture_session *cap_session)
/* Force the issue. */
if (terminate) {
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_WARNING,
- "sync_pipe_stop: forcing child to exit");
+ ws_warning("sync_pipe_stop: forcing child to exit");
sync_pipe_kill(cap_session->fork_child);
}
#endif
@@ -2065,8 +2052,7 @@ sync_pipe_kill(ws_process_id fork_child)
#ifndef _WIN32
int sts = kill(fork_child, SIGTERM); /* SIGTERM so it can clean up if necessary */
if (sts != 0) {
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_WARNING,
- "Sending SIGTERM to child failed: %s\n", g_strerror(errno));
+ ws_warning("Sending SIGTERM to child failed: %s\n", g_strerror(errno));
}
#else
/* Remark: This is not the preferred method of closing a process!
diff --git a/capture/capture_win_ifnames.c b/capture/capture_win_ifnames.c
index 90cc1cbffd..f13c4d2699 100644
--- a/capture/capture_win_ifnames.c
+++ b/capture/capture_win_ifnames.c
@@ -31,8 +31,6 @@
#define NETIO_STATUS DWORD
#endif
-#include "log.h"
-
#include "capture/capture_ifinfo.h"
#include "capture/capture_win_ifnames.h"