X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Flog.c;h=f17b8d9be616edb32066d49e489bb33ef478e22b;hb=6a2259c2522c346df06c31ebd23582760dfab5a8;hp=55431cc1fb06e2985fcb90d2ceebb544c4d06ab6;hpb=b65c2563a8a425593f91dfcb82ede8cf53fec6cd;p=libucw.git diff --git a/lib/log.c b/lib/log.c index 55431cc1..f17b8d9b 100644 --- a/lib/log.c +++ b/lib/log.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -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); + } +}