208
209
sprintf(buf2, "%s.%010d", szLogRoot, tLogStart);
210
211
tLogEnd = tLogStart + tRotation;
211
apr_file_open(&nLogFD, buf2, APR_READ | APR_WRITE | APR_CREATE | APR_APPEND,
212
APR_OS_DEFAULT, pool);
213
if (nLogFD == NULL) {
212
rv = apr_file_open(&nLogFD, buf2, APR_WRITE | APR_CREATE | APR_APPEND,
213
APR_OS_DEFAULT, pool);
214
if (rv != APR_SUCCESS) {
217
apr_strerror(rv, error, sizeof error);
214
219
/* Uh-oh. Failed to open the new log file. Try to clear
215
220
* the previous log file, note the lost log entries,
216
221
* and keep on truckin'. */
217
222
if (nLogFDprev == NULL) {
218
fprintf(stderr, "1 Previous file handle doesn't exists %s\n", buf2);
223
fprintf(stderr, "Could not open log file '%s' (%s)\n", buf2, error);
222
227
nLogFD = nLogFDprev;
224
"Resetting log file due to error opening "
225
"new log file. %10d messages lost.\n",
228
/* Try to keep this error message constant length
229
* in case it occurs several times. */
230
apr_snprintf(errbuf, sizeof errbuf,
231
"Resetting log file due to error opening "
232
"new log file, %10d messages lost: %-25.25s\n",
227
234
nWrite = strlen(errbuf);
228
235
apr_file_trunc(nLogFD, 0);
229
236
if (apr_file_write(nLogFD, errbuf, &nWrite) != APR_SUCCESS) {