From a55d09bb2d74944b7ea5a7e81b7d3e86bc04cd42 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Fri, 19 Jan 2024 18:26:34 +0100 Subject: common: Logging rework Use common logging macros for a consistent output. A logging domain needs to be set in a Makefile first (the _LOG_DOMAIN define). Heavy debugging output is guarded by the __DEBUG_INTERNAL define and omitted by default. Logging severity is controlled by the TUXCMD_DEBUG env. var, typically set by the tuxcmd process itself. --- common/strutils.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'common/strutils.c') diff --git a/common/strutils.c b/common/strutils.c index 3b0a1db..a877c2e 100644 --- a/common/strutils.c +++ b/common/strutils.c @@ -18,10 +18,11 @@ */ #include +#include #include #include "strutils.h" - +#include "logutils.h" char * @@ -85,9 +86,9 @@ resolve_relative (const char *source, const char *point_to) return g_strdup (point_to); rel = g_build_filename (source, point_to, NULL); - log ("resolve_relative: rel = '%s'\n", rel); + log_debug ("resolve_relative: rel = '%s'", rel); canon = canonicalize_filename (rel); - log ("resolve_relative: canon = '%s'\n", canon); + log_debug ("resolve_relative: canon = '%s'", canon); g_free (rel); return canon; @@ -214,7 +215,7 @@ wide_to_utf8 (const wchar_t *src) if (ch < 0x80) /* 0x00-0x7f: 1 byte */ { if (!len--) { - log ("wide_to_utf8: error converting input string, overflow.\n"); + log_debug ("wide_to_utf8: error converting input string, overflow."); break; /* overflow */ } *dst++ = ch; @@ -224,7 +225,7 @@ wide_to_utf8 (const wchar_t *src) if (ch < 0x800) /* 0x80-0x7ff: 2 bytes */ { if ((len -= 2) < 0) { - log ("wide_to_utf8: error converting input string, overflow.\n"); + log_debug ("wide_to_utf8: error converting input string, overflow."); break; /* overflow */ } dst[1] = 0x80 | (ch & 0x3f); @@ -236,7 +237,7 @@ wide_to_utf8 (const wchar_t *src) /* 0x800-0xffff: 3 bytes */ if ((len -= 3) < 0) { - log ("wide_to_utf8: error converting input string, overflow.\n"); + log_debug ("wide_to_utf8: error converting input string, overflow."); break; /* overflow */ } dst[2] = 0x80 | (ch & 0x3f); -- cgit v1.2.3