From eabd52462bfdb409121b351f198d535649d2b3b9 Mon Sep 17 00:00:00 2001 From: gramanas Date: Thu, 6 Dec 2018 09:23:52 +0200 Subject: Add log to file, fix list ckconf bug --- src/ckerrlog.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/ckerrlog.c') diff --git a/src/ckerrlog.c b/src/ckerrlog.c index cf5a6e8..5605fbd 100644 --- a/src/ckerrlog.c +++ b/src/ckerrlog.c @@ -16,13 +16,14 @@ ERRLOG(logger); static int loglvl; +static char logfile[STR_L] = ""; static char buf[STR_M] = ""; #define X(stream) static cklist *stream; CK_STREAMS #undef X -char *get_time() { +static char *get_time() { time_t rawtime; struct tm * timeinfo; time (&rawtime); @@ -94,6 +95,16 @@ CK_STREAMS #undef X void report_errlog() { + LOG("------- end -------\n"); + if (!str_is_empty(logfile)) { +#define X(stream) \ + if (stream) { \ + list_write_to_file(stream, logfile, 1); \ + } + CK_STREAMS +#undef X + } + if (!loglvl) { #define X(stream) \ if (stream) { \ @@ -119,11 +130,17 @@ void ckerr_add_component(char *txt, ...) { va_end(args); } +void errlog_make_logfile(char *logdir) { + if (!logdir) { + return; + } + str_join_dirname_with_basename(logfile, logdir, "ck.log"); +} + void errlog_set_verbose(int level) { loglvl = level; } - void initialize_errlog(int argc, const char** argv) { #define X(stream) stream = NULL; CK_STREAMS -- cgit v1.2.3