common: adding [E]/[L] markers to errors/logs (#1365)

common: adding [E]/[L] markers to errors/logs

@Issue: https://github.com/thorvg/thorvg/issues/1351
This commit is contained in:
Mira Grudzinska 2023-04-14 02:38:01 +02:00 committed by GitHub
parent 0a3718f923
commit 4f3b718c3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,11 +66,13 @@ enum class FileType { Tvg = 0, Svg, Raw, Png, Jpg, Unknown };
#ifdef THORVG_LOG_ENABLED #ifdef THORVG_LOG_ENABLED
constexpr auto ErrorColor = "\033[31m"; //red constexpr auto ErrorColor = "\033[31m"; //red
constexpr auto ErrorBgColor = "\033[41m";//bg red
constexpr auto LogColor = "\033[32m"; //green constexpr auto LogColor = "\033[32m"; //green
constexpr auto LogBgColor = "\033[42m"; //bg green
constexpr auto GreyColor = "\033[90m"; //grey constexpr auto GreyColor = "\033[90m"; //grey
constexpr auto ResetColor = "\033[0m"; //default constexpr auto ResetColors = "\033[0m"; //default
#define TVGERR(tag, fmt, ...) fprintf(stderr, "%s" tag "%s (%s l.%d): %s" fmt "\n", ErrorColor, GreyColor, __FILE__, __LINE__, ResetColor, ##__VA_ARGS__) #define TVGERR(tag, fmt, ...) fprintf(stderr, "%s[E]%s %s" tag "%s (%s l.%d): %s" fmt "\n", ErrorBgColor, ResetColors, ErrorColor, GreyColor, __FILE__, __LINE__, ResetColors, ##__VA_ARGS__)
#define TVGLOG(tag, fmt, ...) fprintf(stderr, "%s" tag "%s (%s l.%d): %s" fmt "\n", LogColor, GreyColor, __FILE__, __LINE__, ResetColor, ##__VA_ARGS__) #define TVGLOG(tag, fmt, ...) fprintf(stderr, "%s[L]%s %s" tag "%s (%s l.%d): %s" fmt "\n", LogBgColor, ResetColors, LogColor, GreyColor, __FILE__, __LINE__, ResetColors, ##__VA_ARGS__)
#else #else
#define TVGERR(...) #define TVGERR(...)
#define TVGLOG(...) #define TVGLOG(...)