diff options
Diffstat (limited to 'test/mmtty.c')
-rw-r--r-- | test/mmtty.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/test/mmtty.c b/test/mmtty.c index 7bffd3c0..398eb22b 100644 --- a/test/mmtty.c +++ b/test/mmtty.c @@ -23,7 +23,7 @@ #include <glib.h> #include <gio/gio.h> -#include <mm-log-test.h> +#include <mm-log.h> #include <mm-port-serial.h> #include <mm-port-serial-at.h> #include <mm-serial-parsers.h> @@ -242,6 +242,45 @@ start_cb (void) return G_SOURCE_REMOVE; } +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; |