From a0db476bed7d7b814c426d23b55a74d585a6d8cb Mon Sep 17 00:00:00 2001 From: Anastasis Grammenos Date: Fri, 5 Oct 2018 18:16:16 +0300 Subject: errlog in actionparser and configparser --- src/ckerrlog.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'src/ckerrlog.c') diff --git a/src/ckerrlog.c b/src/ckerrlog.c index 9a63ffd..357d112 100644 --- a/src/ckerrlog.c +++ b/src/ckerrlog.c @@ -14,7 +14,7 @@ #include "ckutil.h" #include "cklist.h" -ERRLOG(ckerrlog); +ERRLOG(logger); static int loglvl; static char buf[STR_M]; @@ -32,12 +32,13 @@ char * get_time() { return buf; } -void initialize_errlog() { -#define X(stream) stream = NULL; - CK_STREAMS -#undef X - loglvl = 0; - cklog("%s Log session started", get_time()); +void log_command(int argc, char* argv[]) { + char tmp[STR_L] = ""; + for(int i = 0; i < argc; i++) { + strcat(tmp, argv[i]); + strcat(tmp, " "); + } + LOG("Command issued: %s", tmp); } #define X(stream) \ @@ -66,6 +67,16 @@ CK_STREAMS CK_STREAMS #undef X +#define X(stream) \ + void ck## stream ##_with_delim(char *d, char *txt, ...) { \ + va_list args; \ + va_start(args, txt); \ + add_## stream ##_with_delim(d, txt, args); \ + va_end(args); \ + } +CK_STREAMS +#undef X + #define X(stream) \ void reset_## stream() { \ list_free(stream); \ @@ -111,3 +122,13 @@ void ckerr_add_component(char *txt, ...) { extern void errlog_set_verbose(int level) { loglvl = level; } + + +void initialize_errlog(int argc, char* argv[]) { +#define X(stream) stream = NULL; + CK_STREAMS +#undef X + loglvl = 0; + LOG("%s Log session started", get_time()); + log_command(argc, argv); +} -- cgit v1.2.3