if the log pattern/path referenced doesn't exist, create all necessary parent directories (killing the JVM if it fails, rather than silently gobble the log messages to /dev/null)

This commit is contained in:
jrandom
2004-07-19 17:18:49 +00:00
committed by zzz
parent b56845e200
commit c4e6a2f0a8

View File

@ -122,6 +122,18 @@ class LogWriter implements Runnable {
File f = getNextFile(pattern);
_currentFile = f;
_numBytesInCurrentFile = 0;
File parent = f.getParentFile();
if (!parent.exists()) {
boolean ok = parent.mkdirs();
if (!ok) {
System.err.println("Unable to create the parent directy: " + parent.getAbsolutePath());
System.exit(0);
}
}
if (!parent.isDirectory()) {
System.err.println("wtf, we cannot put the logs in a subdirectory of a plain file! we want to stre the log as " + f.getAbsolutePath());
System.exit(0);
}
try {
_currentOut = new FileOutputStream(f);
} catch (IOException ioe) {