+ improve log

pull/1/merge
io42630 3 years ago
parent dca4b1e3bb
commit 4f9d9eb8d6

@ -18,7 +18,7 @@ public class MainApp {
final private static Tools TOOLS = new Tools(); final private static Tools TOOLS = new Tools();
public static void main(String[] args) throws JSONException { public static void main(String[] args) throws JSONException {
LogU.remake(null, "com.olexyn.ensync.", "[%1$tF %1$tT] [%2$-7s] [%3$-10s] %4$-180s [%5$s]\n"); LogU.remake(null, "com.olexyn.ensync.", "[%1$tF %1$tT] [%2$-7s] [%3$-14s] %4$-180s [%5$s]\n");
var configPath = Path.of(System.getProperty("user.dir") + "/src/main/resources/config.json"); var configPath = Path.of(System.getProperty("user.dir") + "/src/main/resources/config.json");
String configString = Tools.fileToString(LockUtil.lockFile(configPath).getFc()); String configString = Tools.fileToString(LockUtil.lockFile(configPath).getFc());

@ -3,6 +3,8 @@ package com.olexyn.ensync.lock;
import com.olexyn.min.log.LogU; import com.olexyn.min.log.LogU;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.nio.channels.OverlappingFileLockException; import java.nio.channels.OverlappingFileLockException;
import java.nio.file.Path; import java.nio.file.Path;
@ -22,7 +24,12 @@ public class LockUtil {
var fc = FileChannel.open(filePath, CREATE_NEW, WRITE); var fc = FileChannel.open(filePath, CREATE_NEW, WRITE);
return new FcState(filePath, fc, false); return new FcState(filePath, fc, false);
} catch (IOException | OverlappingFileLockException e) { } catch (IOException | OverlappingFileLockException e) {
LogU.warnPlain("Could not NEW %s\n%s", filePath, e.getMessage()); var writer = new PrintWriter(new StringWriter());
e.printStackTrace(writer);
writer.flush();
LogU.warnPlain("Could not NEW %s", filePath, e.getMessage());
LogU.warnPlain(writer.toString());
e.printStackTrace();
return new FcState(filePath, null, false); return new FcState(filePath, null, false);
} }
} }

Loading…
Cancel
Save