handle errors initializing, and deal with logFilePatterns that don't include a full path (e.g. log-#.txt instead of logs/log-#.txt)

This commit is contained in:
jrandom
2004-08-14 20:57:50 +00:00
committed by zzz
parent 0af07e5352
commit 6bc7a3d8aa

View File

@ -46,11 +46,17 @@ class LogWriter implements Runnable {
public void run() {
_write = true;
try {
rotateFile();
while (_write) {
flushRecords();
rereadConfig();
}
System.err.println("Done writing");
} catch (Exception e) {
System.err.println("Error writing the logs: " + e.getMessage());
e.printStackTrace();
}
}
public void flushRecords() {
@ -131,6 +137,7 @@ class LogWriter implements Runnable {
_currentFile = f;
_numBytesInCurrentFile = 0;
File parent = f.getParentFile();
if (parent != null) {
if (!parent.exists()) {
boolean ok = parent.mkdirs();
if (!ok) {
@ -142,6 +149,7 @@ class LogWriter implements Runnable {
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) {