I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 6bc7a3d8 authored by jrandom's avatar jrandom Committed by zzz
Browse files

handle errors initializing, and deal with logFilePatterns that don't include a...

handle errors initializing, and deal with logFilePatterns that don't include a full path (e.g. log-#.txt instead of logs/log-#.txt)
parent 0af07e53
No related branches found
No related tags found
No related merge requests found
...@@ -46,10 +46,16 @@ class LogWriter implements Runnable { ...@@ -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 { ...@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment