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:
@ -46,10 +46,16 @@ class LogWriter implements Runnable {
|
|||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
_write = true;
|
_write = true;
|
||||||
rotateFile();
|
try {
|
||||||
while (_write) {
|
rotateFile();
|
||||||
flushRecords();
|
while (_write) {
|
||||||
rereadConfig();
|
flushRecords();
|
||||||
|
rereadConfig();
|
||||||
|
}
|
||||||
|
System.err.println("Done writing");
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Error writing the logs: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,17 +137,19 @@ class LogWriter implements Runnable {
|
|||||||
_currentFile = f;
|
_currentFile = f;
|
||||||
_numBytesInCurrentFile = 0;
|
_numBytesInCurrentFile = 0;
|
||||||
File parent = f.getParentFile();
|
File parent = f.getParentFile();
|
||||||
if (!parent.exists()) {
|
if (parent != null) {
|
||||||
boolean ok = parent.mkdirs();
|
if (!parent.exists()) {
|
||||||
if (!ok) {
|
boolean ok = parent.mkdirs();
|
||||||
System.err.println("Unable to create the parent directy: " + parent.getAbsolutePath());
|
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);
|
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 {
|
try {
|
||||||
_currentOut = new FileOutputStream(f);
|
_currentOut = new FileOutputStream(f);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
|
Reference in New Issue
Block a user