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