From f61c2a86b669132c3d58baf4d80fee7be6bd5ce0 Mon Sep 17 00:00:00 2001 From: Fritz Stracke <fritz.stracke@rwth-aachen.de> Date: Thu, 4 May 2023 12:30:37 +0200 Subject: [PATCH] Add colors to gpu/log.c Signed-off-by: Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de> --- gpu/src/log.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gpu/src/log.c b/gpu/src/log.c index e104890..81ab6dc 100644 --- a/gpu/src/log.c +++ b/gpu/src/log.c @@ -59,7 +59,12 @@ void now_time(char* buf) const char* to_string(log_level level) { +#ifdef NOCOLORS static const char* const buffer[] = {"ERROR", "WARNING", "INFO", "DEBUG"}; +#else + static const char* const buffer[] = {"\033[1m\033[31mERROR\033[0m", "\033[33mWARNING\033[0m", "\033[34mINFO\033[0m", "\033[32mDEBUG\033[0m"}; +#endif //NOCOLORS + if(level > LOG_DEBUG){ return buffer[LOG_DEBUG]; } @@ -90,5 +95,10 @@ void loggfe(log_level level, int line, const char* file, const char* formatstr, char stripped[64]; strcpy(stripped, file); str_strip(stripped, get_log_data()->project_offset); - printf("\tin %s(%d)\n", stripped, line); +#ifdef NOCOLORS + printf("\tin %s:%d\n", stripped, line); +#else + printf("\tin \033[4m%s:%d\033[0m\n", stripped, line); +#endif //NOCOLORS + } -- GitLab