From 2323ca6c9ec3c8ee76b9acf13745b80b92952a6a Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 18 Mar 2019 23:47:45 +0100 Subject: Add struct, import caching, binop ops etc --- src/std/log.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/std/log.c') diff --git a/src/std/log.c b/src/std/log.c index 2563bdc..2059445 100644 --- a/src/std/log.c +++ b/src/std/log.c @@ -4,6 +4,8 @@ #include #include +/*#define LOG_DEBUG*/ + static amal_mutex mutex; static bool mutex_initialized = bool_false; @@ -21,6 +23,7 @@ amal_mutex* amal_log_get_mutex() { } void amal_log_debug(const char *fmt, ...) { +#ifdef LOG_DEBUG va_list args; mutex_init(); ignore_result_int(amal_mutex_lock(&mutex, NULL)); @@ -30,13 +33,16 @@ void amal_log_debug(const char *fmt, ...) { va_end(args); fprintf(stderr, "\n"); ignore_result_int(amal_mutex_unlock(&mutex)); +#else + (void)fmt; +#endif } void amal_log_error(const char *fmt, ...) { va_list args; mutex_init(); ignore_result_int(amal_mutex_lock(&mutex, NULL)); - fprintf(stderr, "Error: "); + fprintf(stderr, "\x1b[1;31mError:\x1b[0m "); va_start(args, fmt); vfprintf(stderr, fmt, args); va_end(args); @@ -66,11 +72,4 @@ void amal_log_warning(const char *fmt, ...) { va_end(args); fprintf(stderr, "\n"); ignore_result_int(amal_mutex_unlock(&mutex)); -} - -void amal_log_perror(const char *prefix) { - mutex_init(); - ignore_result_int(amal_mutex_lock(&mutex, NULL)); - perror(prefix); - ignore_result_int(amal_mutex_unlock(&mutex)); -} +} \ No newline at end of file -- cgit v1.2.3