From 3ad85b1744b1c31891e7874a960b8881bca5688b Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 29 May 2005 10:33:49 +0000 Subject: [PATCH] log_switch() returns whether the logs have been really switched. --- lib/lib.h | 2 +- lib/log-file.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/lib.h b/lib/lib.h index 2102dd43..be42c413 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -86,7 +86,7 @@ void die(byte *, ...) NONRET; void log_init(byte *argv0); void log_file(byte *name); void log_fork(void); -void log_switch(void); +int log_switch(void); void assert_failed(char *assertion, char *file, int line) NONRET; void assert_failed_noinfo(void) NONRET; diff --git a/lib/log-file.c b/lib/log-file.c index ca144d6e..83229669 100644 --- a/lib/log-file.c +++ b/lib/log-file.c @@ -1,7 +1,7 @@ /* * UCW Library -- Keeping of Log Files * - * (c) 1997--2004 Martin Mares + * (c) 1997--2005 Martin Mares * * This software may be freely distributed and used according to the terms * of the GNU Lesser General Public License. @@ -21,15 +21,16 @@ static int log_params; static int log_filename_size; int log_switch_nest; -static void +static int do_log_switch(struct tm *tm) { int fd, l; char name[log_filename_size]; + int switched = 0; if (!log_name_patt || log_filename[0] && !log_params) - return; + return 0; log_switch_nest++; l = strftime(name, log_filename_size, log_name_patt, tm); if (l < 0 || l >= log_filename_size) @@ -45,15 +46,17 @@ do_log_switch(struct tm *tm) close(fd); close(1); dup(2); + switched = 1; } log_switch_nest--; + return switched; } -void +int log_switch(void) { time_t tim = time(NULL); - do_log_switch(localtime(&tim)); + return do_log_switch(localtime(&tim)); } static void -- 2.39.2