(logerror): Ensure that logerror() only writes to the log file after log_init()
has been called
This commit is contained in:
parent
8babf97d81
commit
3afb3925a2
1 changed files with 9 additions and 7 deletions
|
@ -89,13 +89,15 @@ logerror(char *format, ...)
|
||||||
p = strchr(msg, '\n');
|
p = strchr(msg, '\n');
|
||||||
p[1] = 0;
|
p[1] = 0;
|
||||||
fputs(msg, stderr);
|
fputs(msg, stderr);
|
||||||
time(&now);
|
if (logfile[0] != '\0') {
|
||||||
memcpy(buf, ctime(&now), ctime_len);
|
time(&now);
|
||||||
buf[ctime_len] = ' ';
|
memcpy(buf, ctime(&now), ctime_len);
|
||||||
if ((logf = open(logfile, O_WRONLY | O_CREAT | O_APPEND, 0666)) < 0)
|
buf[ctime_len] = ' ';
|
||||||
return;
|
if ((logf = open(logfile, O_WRONLY | O_CREAT | O_APPEND, 0666)) < 0)
|
||||||
write(logf, buf, strlen(buf));
|
return;
|
||||||
close(logf);
|
write(logf, buf, strlen(buf));
|
||||||
|
close(logf);
|
||||||
|
}
|
||||||
va_end(list);
|
va_end(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue