mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
common: enhancement of the logging method
Introducing colors for various log types. For error messages, the file name and line number are now included. @Issue: https://github.com/thorvg/thorvg/issues/1351
This commit is contained in:
parent
b866ee9cac
commit
54cfd45165
1 changed files with 5 additions and 2 deletions
|
@ -65,8 +65,11 @@ using namespace tvg;
|
||||||
enum class FileType { Tvg = 0, Svg, Raw, Png, Jpg, Unknown };
|
enum class FileType { Tvg = 0, Svg, Raw, Png, Jpg, Unknown };
|
||||||
|
|
||||||
#ifdef THORVG_LOG_ENABLED
|
#ifdef THORVG_LOG_ENABLED
|
||||||
#define TVGLOG(tag, fmt, ...) fprintf(stdout, tag ": " fmt "\n", ##__VA_ARGS__) //Log Message for notifying user some useful info
|
constexpr auto ErrorColor = "\033[31m"; //red
|
||||||
#define TVGERR(tag, fmt, ...) fprintf(stderr, tag ": " fmt "\n", ##__VA_ARGS__) //Error Message for us to fix it
|
constexpr auto LogColor = "\033[32m"; //green
|
||||||
|
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)
|
||||||
#else
|
#else
|
||||||
#define TVGERR(...)
|
#define TVGERR(...)
|
||||||
#define TVGLOG(...)
|
#define TVGLOG(...)
|
||||||
|
|
Loading…
Add table
Reference in a new issue