Fixed bug 128 (Logger NullPointerException), moved some code.
This commit is contained in:
parent
d1fe0ad7c8
commit
6a7e0ec908
1 changed files with 7 additions and 5 deletions
|
@ -161,11 +161,6 @@ public final class Logger {
|
||||||
if (entries.isEmpty ())
|
if (entries.isEmpty ())
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
if (logfile != null &&
|
|
||||||
(writer == null || !logfile.exists() || !logfile.canWrite())) {
|
|
||||||
// rotate the log file if we can't write to it
|
|
||||||
rotateLogFile ();
|
|
||||||
}
|
|
||||||
|
|
||||||
int l = entries.size();
|
int l = entries.size();
|
||||||
|
|
||||||
|
@ -177,6 +172,10 @@ public final class Logger {
|
||||||
out.println (entry);
|
out.println (entry);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (writer == null || !logfile.exists() || !logfile.canWrite()) {
|
||||||
|
// rotate the log file if we can't write to it
|
||||||
|
rotateLogFile ();
|
||||||
|
}
|
||||||
for (int i=0; i<l; i++) {
|
for (int i=0; i<l; i++) {
|
||||||
String entry = (String) entries.get (0);
|
String entry = (String) entries.get (0);
|
||||||
entries.remove (0);
|
entries.remove (0);
|
||||||
|
@ -203,6 +202,9 @@ public final class Logger {
|
||||||
* start a new one.
|
* start a new one.
|
||||||
*/
|
*/
|
||||||
private void rotateLogFile () throws IOException {
|
private void rotateLogFile () throws IOException {
|
||||||
|
// if the logger is not file based do nothing
|
||||||
|
if (logfile == null)
|
||||||
|
return;
|
||||||
if (writer != null) try {
|
if (writer != null) try {
|
||||||
writer.close();
|
writer.close();
|
||||||
} catch (Exception ignore) {}
|
} catch (Exception ignore) {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue