summaryrefslogtreecommitdiffstats
path: root/loader2/log.c
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2005-06-16 21:57:55 +0000
committerPeter Jones <pjones@redhat.com>2005-06-16 21:57:55 +0000
commit77cd55b5b540e876d7461e66ddcf48512b84dae6 (patch)
tree49efe6c85e7ccbfb1e0b1b384286b3f93bb629f9 /loader2/log.c
parenta8d726380abc1282c9a64f61274a569031f92831 (diff)
downloadanaconda-77cd55b5b540e876d7461e66ddcf48512b84dae6.tar.gz
anaconda-77cd55b5b540e876d7461e66ddcf48512b84dae6.tar.xz
anaconda-77cd55b5b540e876d7461e66ddcf48512b84dae6.zip
get rid of lots of crap
Diffstat (limited to 'loader2/log.c')
-rw-r--r--loader2/log.c74
1 files changed, 36 insertions, 38 deletions
diff --git a/loader2/log.c b/loader2/log.c
index 20030ae06..c05de1278 100644
--- a/loader2/log.c
+++ b/loader2/log.c
@@ -24,13 +24,10 @@
#include "log.h"
-static FILE * logfile = NULL;
-static int logfd;
+static FILE * logfile;
+static FILE * logfile2;
static int loglevel = 10;
-static FILE * logfile2 = NULL;
-static int logfd2 = 0;
-
void logMessage(const char * s, ...) {
/* JKFIXME: need to make this debugMessage and handle a level param */
/* if (level > loglevel)
@@ -38,60 +35,61 @@ void logMessage(const char * s, ...) {
va_list args;
- if (!logfile) return;
-
- va_start(args, s);
-
- fprintf(logfile, "* ");
- vfprintf(logfile, s, args);
- fprintf(logfile, "\n");
- fflush(logfile);
-
- va_end(args);
+ if (logfile) {
+ va_start(args, s);
- if (!logfile2) return;
+ fprintf(logfile, "* ");
+ vfprintf(logfile, s, args);
+ fprintf(logfile, "\n");
+ fflush(logfile);
- va_start(args, s);
+ va_end(args);
+ }
- fprintf(logfile2, "* ");
- vfprintf(logfile2, s, args);
- fprintf(logfile2, "\n");
- fflush(logfile2);
+ if (logfile2) {
+ va_start(args, s);
- va_end(args);
+ fprintf(logfile, "* ");
+ vfprintf(logfile, s, args);
+ fprintf(logfile, "\n");
+ fflush(logfile);
+ va_end(args);
+ }
return;
}
void openLog(int useLocal) {
+ int flags, fd;
+
if (!useLocal) {
logfile = fopen("/dev/tty3", "w");
- if (logfile) {
- logfd = open("/dev/tty3", O_WRONLY);
- logfile2 = fopen("/tmp/anaconda.log", "w");
- if (logfile2)
- logfd2 = open("/tmp/anaconda.log", O_WRONLY | O_APPEND);
- } else {
- logfile = fopen("/tmp/anaconda.log", "w");
- logfd = open("/tmp/anaconda.log", O_WRONLY| O_APPEND);
- }
+ logfile2 = fopen("/tmp/anaconda.log", "w");
} else {
logfile = fopen("debug.log", "w");
- logfd = open("debug.log", O_WRONLY);
}
-}
-void closeLog(void) {
if (logfile) {
- fclose(logfile);
- close(logfd);
+ fd = fileno(logfile);
+ flags = fcntl(fd, F_GETFD, 0) | FD_CLOEXEC;
+ fcntl(fd, F_SETFD, flags);
}
+
if (logfile2) {
- fclose(logfile2);
- close(logfd2);
+ fd = fileno(logfile2);
+ flags = fcntl(fd, F_GETFD, 0) | FD_CLOEXEC;
+ fcntl(fd, F_SETFD, flags);
}
}
+void closeLog(void) {
+ if (logfile)
+ fclose(logfile);
+
+ if (logfile2)
+ fclose(logfile2);
+}
+
/* set the level. higher means you see more verbosity */
void setLogLevel(int level) {
loglevel = level;