]> mj.ucw.cz Git - libucw.git/blobdiff - lib/log-file.c
Added the local copy of the regex library back.
[libucw.git] / lib / log-file.c
index 1ef69a14456ff4a64828266ed9e220a75fa81e02..0b22ff243e8811618dadf45c201b17b9051f74ec 100644 (file)
@@ -20,7 +20,7 @@
 static char *log_name_patt;
 static int log_params;
 static int log_filename_size;
-volatile int log_switch_nest;
+static int log_switch_nest;
 
 static int
 do_log_switch(struct tm *tm)
@@ -43,11 +43,8 @@ do_log_switch(struct tm *tm)
       fd = sh_open(name, O_WRONLY | O_CREAT | O_APPEND, 0666);
       if (fd < 0)
        die("Unable to open log file %s: %m", name);
-      close(2);
-      dup(fd);
+      dup2(fd, 2);
       close(fd);
-      close(1);
-      dup(2);
       switched = 1;
     }
   log_switch_nest--;
@@ -70,7 +67,7 @@ internal_log_switch(struct tm *tm)
 }
 
 void
-log_file(byte *name)
+log_file(const char *name)
 {
   if (name)
     {
@@ -97,6 +94,19 @@ log_fork(void)
   log_pid = getpid();
 }
 
+void
+log_switch_disable(void)
+{
+  log_switch_nest++;
+}
+
+void
+log_switch_enable(void)
+{
+  ASSERT(log_switch_nest);
+  log_switch_nest--;
+}
+
 #ifdef TEST
 
 int main(int argc, char **argv)