From 0a3718f923b88824dba252fc799e31c1d3f38605 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Wed, 12 Apr 2023 16:51:55 +0200 Subject: [PATCH] common: enhancement++ of the logging method Logging tags are marked with the corresponding log type color, the file and the line information in gray, and the message content in the default color. @Issue: https://github.com/thorvg/thorvg/issues/1351 --- src/lib/tvgCommon.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/tvgCommon.h b/src/lib/tvgCommon.h index e78a87f5..06cd3a59 100644 --- a/src/lib/tvgCommon.h +++ b/src/lib/tvgCommon.h @@ -67,9 +67,10 @@ enum class FileType { Tvg = 0, Svg, Raw, Png, Jpg, Unknown }; #ifdef THORVG_LOG_ENABLED constexpr auto ErrorColor = "\033[31m"; //red constexpr auto LogColor = "\033[32m"; //green + constexpr auto GreyColor = "\033[90m"; //grey constexpr auto ResetColor = "\033[0m"; //default - #define TVGERR(tag, fmt, ...) fprintf(stderr, "%s" tag " (%s l.%d): " fmt "%s\n", ErrorColor, __FILE__, __LINE__, ##__VA_ARGS__, ResetColor) - #define TVGLOG(tag, fmt, ...) fprintf(stderr, "%s" tag " (%s l.%d): " fmt "%s\n", LogColor, __FILE__, __LINE__, ##__VA_ARGS__, ResetColor) + #define TVGERR(tag, fmt, ...) fprintf(stderr, "%s" tag "%s (%s l.%d): %s" fmt "\n", ErrorColor, GreyColor, __FILE__, __LINE__, ResetColor, ##__VA_ARGS__) + #define TVGLOG(tag, fmt, ...) fprintf(stderr, "%s" tag "%s (%s l.%d): %s" fmt "\n", LogColor, GreyColor, __FILE__, __LINE__, ResetColor, ##__VA_ARGS__) #else #define TVGERR(...) #define TVGLOG(...)