ret = logfile_mod_syslog_open(lf, patharg, bufsz, fatal_flag);
#endif
} else {
+ debugs(50, DBG_IMPORTANT, "WARNING: log parameters now start with a module name. Use 'stdio:" << patharg << "'");
+ snprintf(lf->path, MAXPATHLEN, "stdio:%s", patharg);
ret = logfile_mod_stdio_open(lf, patharg, bufsz, fatal_flag);
}
if (!ret) {
if (fatal_flag)
- fatalf("logfileOpen: path %s: couldn't open!\n", path);
+ fatalf("logfileOpen: %s: couldn't open!\n", path);
else
- debugs(50, 1, "logfileOpen: path " << path << ": couldn't open!");
+ debugs(50, 1, "logfileOpen: " << path << ": couldn't open!");
lf->f_close(lf);
cbdataFree(lf);
return NULL;
if (!lf->flags.fatal)
return;
- fatalf("logfileWrite (stdio): %s: %s\n", lf->path, xstrerror());
+ fatalf("logfileWrite: %s: %s\n", lf->path, xstrerror());
}
static void
char to[MAXPATHLEN];
l_stdio_t *ll = (l_stdio_t *) lf->data;
assert(lf->path);
+ const char *realpath = lf->path+6; // skip 'stdio:' prefix.
+ assert(realpath);
#ifdef S_ISREG
- if (stat(lf->path, &sb) == 0)
+ if (stat(realpath, &sb) == 0)
if (S_ISREG(sb.st_mode) == 0)
return;
#endif
- debugs(0, DBG_IMPORTANT, "logfileRotate (stdio): " << lf->path);
+ debugs(0, DBG_IMPORTANT, "Rotate log file " << lf->path);
/* Rotate numbers 0 through N up one */
for (i = Config.Log.rotateNumber; i > 1;) {
i--;
- snprintf(from, MAXPATHLEN, "%s.%d", lf->path, i - 1);
- snprintf(to, MAXPATHLEN, "%s.%d", lf->path, i);
+ snprintf(from, MAXPATHLEN, "%s.%d", realpath, i - 1);
+ snprintf(to, MAXPATHLEN, "%s.%d", realpath, i);
xrename(from, to);
}
file_close(ll->fd); /* always close */
if (Config.Log.rotateNumber > 0) {
- snprintf(to, MAXPATHLEN, "%s.%d", lf->path, 0);
- xrename(lf->path, to);
+ snprintf(to, MAXPATHLEN, "%s.%d", realpath, 0);
+ xrename(realpath, to);
}
/* Reopen the log. It may have been renamed "manually" */
- ll->fd = file_open(lf->path, O_WRONLY | O_CREAT | O_TEXT);
+ ll->fd = file_open(realpath, O_WRONLY | O_CREAT | O_TEXT);
if (DISK_ERROR == ll->fd && lf->flags.fatal) {
- debugs(50, DBG_CRITICAL, "logfileRotate (stdio): " << lf->path << ": " << xstrerror());
+ debugs(50, DBG_CRITICAL, "ERROR: logfileRotate: " << lf->path << ": " << xstrerror());
fatalf("Cannot open %s: %s", lf->path, xstrerror());
}
}
} else if (EISDIR == errno && fatal_flag) {
fatalf("Cannot open '%s' because it is a directory, not a file.\n", path);
} else {
- debugs(50, DBG_IMPORTANT, "logfileOpen (stdio): " << path << ": " << xstrerror());
+ debugs(50, DBG_IMPORTANT, "ERROR: logfileOpen " << lf->path << ": " << xstrerror());
return 0;
}
}