direc = CNF_GetLogDir();
if (!mkdir_and_parents(direc)) {
LOG(LOGS_ERR, LOGF_RtcLinux, "Could not create directory %s", direc);
- logfile = NULL;
} else {
logfilename = MallocArray(char, 2 + strlen(direc) + strlen(RTC_LOG));
strcpy(logfilename, direc);
strcat(logfilename, "/");
strcat(logfilename, RTC_LOG);
- logfile = fopen(logfilename, "a");
- if (!logfile) {
- LOG(LOGS_WARN, LOGF_RtcLinux, "Couldn't open logfile %s for update", logfilename);
- }
}
}
if (logfile) {
fclose(logfile);
}
-
+ Free(logfilename);
}
/* ================================================== */
}
- if (logfile) {
+ if (logfilename) {
+ if (!logfile) {
+ logfile = fopen(logfilename, "a");
+ if (!logfile) {
+ LOG(LOGS_WARN, LOGF_RtcLinux, "Couldn't open logfile %s for update", logfilename);
+ Free(logfilename);
+ logfilename = NULL;
+ return;
+ }
+ }
+
rtc_fast = (double)(rtc_time - system_time->tv_sec) - 1.0e-6 * (double) system_time->tv_usec;
if (((logwrites++) % 32) == 0) {
void
RTC_Linux_CycleLogFile(void)
{
- if (logfile && logfilename) {
+ if (logfile) {
fclose(logfile);
- logfile = fopen(logfilename, "a");
- if (!logfile) {
- LOG(LOGS_WARN, LOGF_RtcLinux, "Could not reopen logfile %s", logfilename);
- }
+ logfile = NULL;
logwrites = 0;
}
}