Skip to content

Commit

Permalink
Logging not creating file
Browse files Browse the repository at this point in the history
  • Loading branch information
brett-smith committed Feb 29, 2024
1 parent ee72fb1 commit 8ac6c3a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/com/sshtools/uhttpd/UHTTPD.java
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,7 @@ public void accept(Transaction tx) {
writer.close();
logFile = dir.resolve(filename);
try {
writer = new PrintWriter(Files.newBufferedWriter(logFile, append? StandardOpenOption.APPEND : StandardOpenOption.CREATE), true);
writer = new PrintWriter(Files.newBufferedWriter(logFile, openOpens()), true);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
Expand Down Expand Up @@ -1648,6 +1648,13 @@ public void accept(Transaction tx) {
writer.println(buf.toString());
}
}

private OpenOption[] openOpens() {
if(append)
return new OpenOption[] { StandardOpenOption.WRITE, StandardOpenOption.APPEND, StandardOpenOption.CREATE };
else
return new OpenOption[] { StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING };
}

}
}
Expand Down

0 comments on commit 8ac6c3a

Please sign in to comment.