diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2018-12-06 09:23:52 +0200 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2018-12-06 09:23:52 +0200 |
commit | eabd52462bfdb409121b351f198d535649d2b3b9 (patch) | |
tree | 434ec71438df3c822d34fc0b8d83fa977264c546 /src/ckerrlog.c | |
parent | bd85acf6a408674bcdcb5116963fe4fea2247280 (diff) | |
download | ck-eabd52462bfdb409121b351f198d535649d2b3b9.tar.gz ck-eabd52462bfdb409121b351f198d535649d2b3b9.tar.bz2 ck-eabd52462bfdb409121b351f198d535649d2b3b9.zip |
Add log to file, fix list ckconf bug
Diffstat (limited to 'src/ckerrlog.c')
-rw-r--r-- | src/ckerrlog.c | 21 |
1 files changed, 19 insertions, 2 deletions
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 |