From 9c24e438b689af042672182f6d87f824ef435492 Mon Sep 17 00:00:00 2001 From: Anastasis Grammenos Date: Thu, 4 Oct 2018 15:46:42 +0300 Subject: More error/logs and fix failing test --- src/ckerrlog.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'src/ckerrlog.c') diff --git a/src/ckerrlog.c b/src/ckerrlog.c index 1be1c08..9e1fc51 100644 --- a/src/ckerrlog.c +++ b/src/ckerrlog.c @@ -15,11 +15,13 @@ #define COMPONENT "ckerrlog" -static char *err; -static char *log; static int loglvl; static char buf[STR_M]; +#define X(stream) static char *stream; +CK_STREAMS +#undef X + char * get_time() { time_t rawtime; struct tm * timeinfo; @@ -30,8 +32,9 @@ char * get_time() { } void initialize_errlog() { - err = NULL; - log = NULL; +#define X(stream) stream = NULL; + CK_STREAMS +#undef X loglvl = 0; cklog("%s Log session started", get_time()); } @@ -78,9 +81,35 @@ void cklog(char *txt, ...) { va_end(args); } +void ckhelp(char *txt, ...) { + va_list args; + va_start(args, txt); + add_help_with_delim("\n", txt, args); + va_end(args); +} + void ckerr_add_component(char *txt, ...) { va_list args; va_start(args, txt); add_err_with_delim(" ", txt, args); va_end(args); } + +void ckhelp_add_component(char *txt, ...) { + va_list args; + va_start(args, txt); + add_help_with_delim(" ", txt, args); + va_end(args); +} + +void report_err() { + printf("%s", err); + free(err); + err = NULL; +} + +void report_help() { + printf("%s", help); + free(help); + help = NULL; +} -- cgit v1.2.3