mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-15 05:45:05 -05:00
* resolve relative log-file paths against {appdata}/logs
This commit is contained in:
parent
84075b35c8
commit
efa024ccd2
@ -94,9 +94,16 @@ public class Main {
|
||||
|
||||
// tee stdout and stderr to log file if set
|
||||
if (args.logFile != null) {
|
||||
File logFile = args.getLogFile();
|
||||
FileChannel logChannel = new FileOutputStream(logFile, true).getChannel();
|
||||
File logFile = new File(args.logFile);
|
||||
if (!logFile.isAbsolute()) {
|
||||
logFile = new File(new File(getApplicationFolder(), "logs"), logFile.getPath()).getAbsoluteFile(); // by default resolve relative paths against {applicationFolder}/logs/{logFile}
|
||||
}
|
||||
if (!logFile.exists() && !logFile.getParentFile().mkdirs() && !logFile.createNewFile()) {
|
||||
throw new IOException("Failed to create log file: " + logFile);
|
||||
}
|
||||
|
||||
// open file channel and lock
|
||||
FileChannel logChannel = new FileOutputStream(logFile, true).getChannel();
|
||||
if (args.logLock) {
|
||||
System.out.println("Locking " + logFile);
|
||||
logChannel.lock();
|
||||
|
@ -6,7 +6,6 @@ import static java.util.Collections.*;
|
||||
import static net.sourceforge.tuned.FileUtilities.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -188,13 +187,4 @@ public class ArgumentBean {
|
||||
return Level.parse(log.toUpperCase());
|
||||
}
|
||||
|
||||
|
||||
public File getLogFile() throws IOException {
|
||||
File f = new File(logFile).getAbsoluteFile();
|
||||
if (!f.exists() && !f.getParentFile().mkdirs() && !f.createNewFile()) {
|
||||
throw new IOException("Failed to create log file: " + f);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user