]> mj.ucw.cz Git - libucw.git/blobdiff - lib/log.c
Yet another bug in the pattern matcher fixed.
[libucw.git] / lib / log.c
index 55431cc1fb06e2985fcb90d2ceebb544c4d06ab6..f17b8d9be616edb32066d49e489bb33ef478e22b 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#include <fcntl.h>
 #include <unistd.h>
 #include <sys/time.h>
 
@@ -72,6 +73,21 @@ basename(byte *n)
 void
 initlog(byte *argv0)
 {
-  progname = basename(argv0);
+  if (argv0)
+    progname = basename(argv0);
   pid = getpid();
 }
+
+void
+open_log_file(byte *name)
+{
+  if (name)
+    {
+      int fd = open(name, O_WRONLY | O_CREAT | O_APPEND, 0666);
+      if (fd < 0)
+       die("Unable to open log file");
+      close(2);
+      dup(fd);
+      close(fd);
+    }
+}