Actually log error on log file, not stdout

This commit is contained in:
Laurent Clouet
2018-06-30 01:41:54 +02:00
parent 25d5259332
commit af32a104de
2 changed files with 9 additions and 4 deletions

View File

@@ -711,7 +711,7 @@ public class Client {
renderer_path_file.mkdir(); renderer_path_file.mkdir();
// unzip the archive // unzip the archive
ret = Utils.unzipFileIntoDirectory(renderer_archive, renderer_path, null); ret = Utils.unzipFileIntoDirectory(renderer_archive, renderer_path, null, log);
if (ret != 0) { if (ret != 0) {
this.log.error("Client::prepareWorkingDirectory, error(1) with Utils.unzipFileIntoDirectory(" + renderer_archive + ", " + renderer_path + ") returned " + ret); this.log.error("Client::prepareWorkingDirectory, error(1) with Utils.unzipFileIntoDirectory(" + renderer_archive + ", " + renderer_path + ") returned " + ret);
this.gui.error("Client::prepareWorkingDirectory, error with Utils.unzipFileIntoDirectory of the renderer (returned " + ret + ")"); this.gui.error("Client::prepareWorkingDirectory, error with Utils.unzipFileIntoDirectory of the renderer (returned " + ret + ")");
@@ -739,7 +739,7 @@ public class Client {
scene_path_file.mkdir(); scene_path_file.mkdir();
// unzip the archive // unzip the archive
ret = Utils.unzipFileIntoDirectory(scene_archive, scene_path, ajob.getSceneArchivePassword()); ret = Utils.unzipFileIntoDirectory(scene_archive, scene_path, ajob.getSceneArchivePassword(), log);
if (ret != 0) { if (ret != 0) {
this.log.error("Client::prepareWorkingDirectory, error(2) with Utils.unzipFileIntoDirectory(" + scene_archive + ", " + scene_path + ") returned " + ret); this.log.error("Client::prepareWorkingDirectory, error(2) with Utils.unzipFileIntoDirectory(" + scene_archive + ", " + scene_path + ") returned " + ret);
this.gui.error("Client::prepareWorkingDirectory, error with Utils.unzipFileIntoDirectory of the scene (returned " + ret + ")"); this.gui.error("Client::prepareWorkingDirectory, error with Utils.unzipFileIntoDirectory of the scene (returned " + ret + ")");

View File

@@ -24,6 +24,8 @@ import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.security.DigestInputStream; import java.security.DigestInputStream;
@@ -49,7 +51,7 @@ import com.sheepit.client.Error.ServerCode;
import com.sheepit.client.exception.FermeExceptionNoSpaceLeftOnDevice; import com.sheepit.client.exception.FermeExceptionNoSpaceLeftOnDevice;
public class Utils { public class Utils {
public static int unzipFileIntoDirectory(String zipFileName_, String destinationDirectory, String password) throws FermeExceptionNoSpaceLeftOnDevice { public static int unzipFileIntoDirectory(String zipFileName_, String destinationDirectory, String password, Log log) throws FermeExceptionNoSpaceLeftOnDevice {
try { try {
ZipFile zipFile = new ZipFile(zipFileName_); ZipFile zipFile = new ZipFile(zipFileName_);
UnzipParameters unzipParameters = new UnzipParameters(); UnzipParameters unzipParameters = new UnzipParameters();
@@ -61,7 +63,10 @@ public class Utils {
zipFile.extractAll(destinationDirectory, unzipParameters); zipFile.extractAll(destinationDirectory, unzipParameters);
} }
catch (ZipException e) { catch (ZipException e) {
e.printStackTrace(); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
log.debug("Utils::unzipFileIntoDirectory(" + zipFileName_ + "," + destinationDirectory + ") exception " + e + " stacktrace: " + sw.toString());
return -1; return -1;
} }
return 0; return 0;