From 7ec71020e73e486d5070864b5c9ecaa580a68b99 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Thu, 30 Mar 2023 19:36:14 +0000 Subject: test,mmsmspdu: fix verbose logging support --- test/mmsmspdu.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/mmsmspdu.c b/test/mmsmspdu.c index 3a56ffc5..2c53704b 100644 --- a/test/mmsmspdu.c +++ b/test/mmsmspdu.c @@ -26,7 +26,8 @@ #include #define _LIBMM_INSIDE_MM #include -#include "mm-log-test.h" + +#include "mm-log.h" #include "mm-sms-part-3gpp.h" #define PROGRAM_NAME "mmsmspdu" @@ -176,6 +177,45 @@ print_version_and_exit (void) exit (EXIT_SUCCESS); } +void +_mm_log (gpointer obj, + const gchar *module, + const gchar *loc, + const gchar *func, + guint32 level, + const gchar *fmt, + ...) +{ + va_list args; + g_autofree gchar *msg = NULL; + const gchar *level_str = NULL; + + if (!verbose_flag) + return; + + switch (level) { + case MM_LOG_LEVEL_DEBUG: + level_str = "debug"; + break; + case MM_LOG_LEVEL_WARN: + level_str = "warning"; + break; + case MM_LOG_LEVEL_INFO: + level_str = "info"; + break; + case MM_LOG_LEVEL_ERR: + level_str = "error"; + break; + default: + break; + } + + va_start (args, fmt); + msg = g_strdup_vprintf (fmt, args); + va_end (args); + g_print ("[%s] %s\n", level_str ? level_str : "unknown", msg); +} + int main (int argc, char **argv) { GOptionContext *context; -- cgit v1.2.3-70-g09d2