aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debian/libwsutil0.symbols1
-rw-r--r--wsutil/CMakeLists.txt1
-rw-r--r--wsutil/wslog.c29
-rw-r--r--wsutil/wslog.h12
4 files changed, 42 insertions, 1 deletions
diff --git a/debian/libwsutil0.symbols b/debian/libwsutil0.symbols
index e356c54c9e..d205a40574 100644
--- a/debian/libwsutil0.symbols
+++ b/debian/libwsutil0.symbols
@@ -224,6 +224,7 @@ libwsutil.so.0 libwsutil0 #MINVER#
ws_inet_pton4@Base 2.1.2
ws_inet_pton6@Base 2.1.2
ws_init_sockets@Base 3.1.0
+ ws_log_full@Base 3.5.0
ws_mempbrk_compile@Base 1.99.4
ws_mempbrk_exec@Base 1.99.4
ws_pipe_close@Base 2.6.5
diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt
index 422113c1fe..d08dba497f 100644
--- a/wsutil/CMakeLists.txt
+++ b/wsutil/CMakeLists.txt
@@ -125,6 +125,7 @@ set(WSUTIL_COMMON_FILES
ws_pipe.c
wsgcrypt.c
wsjson.c
+ wslog.c
xtea.c
)
diff --git a/wsutil/wslog.c b/wsutil/wslog.c
new file mode 100644
index 0000000000..1d282ca621
--- /dev/null
+++ b/wsutil/wslog.c
@@ -0,0 +1,29 @@
+/*
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 2021 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "config.h"
+#include "wslog.h"
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#define LOGBUFSIZE 256
+
+void ws_log_full(const char *log_domain, GLogLevelFlags log_level,
+ const char *file, int line, const char *func,
+ const char *format, ...)
+{
+ va_list ap;
+ char log_msg[LOGBUFSIZE];
+
+ va_start(ap, format);
+ vsnprintf(log_msg, sizeof(log_msg), format, ap);
+ va_end(ap);
+
+ g_log(log_domain, log_level, "%s(%d):%s: %s", file, line, func, log_msg);
+}
diff --git a/wsutil/wslog.h b/wsutil/wslog.h
index e6f9949f5a..37409a0e64 100644
--- a/wsutil/wslog.h
+++ b/wsutil/wslog.h
@@ -9,6 +9,14 @@
#ifndef __WSLOG_H__
#define __WSLOG_H__
+#include <ws_symbol_export.h>
+#include <glib.h>
+
+WS_DLL_PUBLIC
+void ws_log_full(const char *log_domain, GLogLevelFlags log_level,
+ const char *file, int line, const char *func,
+ const char *format, ...) G_GNUC_PRINTF(6,7);
+
/*
* To output debug information use the environment variable
* G_MESSAGES_DEBUG="<domain1> <domain2> ..." (separated with spaces)
@@ -19,7 +27,9 @@
* with #if WS_DEBUG.
*/
#if WS_DEBUG
-#define ws_debug(...) g_debug(G_STRLOC ": " __VA_ARGS__)
+#define ws_debug(...) ws_log_full(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
+ __FILE__, __LINE__, G_STRFUNC, \
+ __VA_ARGS__)
#else
#define ws_debug(...) ((void)0)
#endif