]> mj.ucw.cz Git - libucw.git/commitdiff
log_switch() returns whether the logs have been really switched.
authorMartin Mares <mj@ucw.cz>
Sun, 29 May 2005 10:33:49 +0000 (10:33 +0000)
committerMartin Mares <mj@ucw.cz>
Sun, 29 May 2005 10:33:49 +0000 (10:33 +0000)
lib/lib.h
lib/log-file.c

index 2102dd43feded5ec8779cd2044fff9236e20c57b..be42c41368eed57e553350b61c996181084955a2 100644 (file)
--- 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;
index ca144d6eda50cda4f33b1ad573f8be17932104b9..832296692f11ef78bd4e06a8b0f20109ba521b29 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     UCW Library -- Keeping of Log Files
  *
- *     (c) 1997--2004 Martin Mares <mj@ucw.cz>
+ *     (c) 1997--2005 Martin Mares <mj@ucw.cz>
  *
  *     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