From: Ben Soares Date: Wed, 12 Aug 2020 12:48:57 +0000 (+0100) Subject: JAL-3676 Removed BACKUPFILESPRESETENTRY logging for opening the file browser. Changed... X-Git-Tag: Develop-2_11_2_0-d20201215~15^2~28 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=23f48ce9323e41c62de8963626aff888249e9aa3;p=jalview.git JAL-3676 Removed BACKUPFILESPRESETENTRY logging for opening the file browser. Changed most BACKUPFILES logging from DEBUG to TRACE level. Minor wording changes. --- diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 4da30ea..a5ec3d8 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -1288,7 +1288,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, BackupFiles backupfiles = null; if (doBackup) { - Cache.log.debug( + Cache.log.trace( "ALIGNFRAME making backupfiles object for " + file); backupfiles = new BackupFiles(file); } @@ -1296,19 +1296,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { String tempFilePath = doBackup ? backupfiles.getTempFilePath() : file; - Cache.log.debug("ALIGNFRAME setting PrintWriter"); + Cache.log.trace("ALIGNFRAME setting PrintWriter"); PrintWriter out = new PrintWriter(new FileWriter(tempFilePath)); if (backupfiles != null) { - Cache.log.debug("ALIGNFRAME about to write to temp file " + Cache.log.trace("ALIGNFRAME about to write to temp file " + backupfiles.getTempFilePath()); } out.print(output); - Cache.log.debug("ALIGNFRAME about to close file"); + Cache.log.trace("ALIGNFRAME about to close file"); out.close(); - Cache.log.debug("ALIGNFRAME closed file"); + Cache.log.trace("ALIGNFRAME closed file"); AlignFrame.this.setTitle(file); statusBar.setText(MessageManager.formatMessage( "label.successfully_saved_to_file_in_format", @@ -1326,7 +1326,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { lastSaveSuccessful = false; Cache.log.error( - "ALIGNFRAME Something else happened writing the temp file"); + "ALIGNFRAME Something unexpected happened writing the temp file"); Cache.log.error(ex.getMessage()); Cache.log.debug(Cache.getStackTraceString(ex)); } @@ -1337,7 +1337,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, Cache.log.debug("ALIGNFRAME writing temp file was " + (lastSaveSuccessful ? "" : "NOT ") + "successful"); // do the backup file roll and rename the temp file to actual file - Cache.log.debug( + Cache.log.trace( "ALIGNFRAME about to rollBackupsAndRenameTempFile"); lastSaveSuccessful = backupfiles.rollBackupsAndRenameTempFile(); Cache.log.debug( diff --git a/src/jalview/io/BackupFiles.java b/src/jalview/io/BackupFiles.java index 7567a81..6fdbf2c 100644 --- a/src/jalview/io/BackupFiles.java +++ b/src/jalview/io/BackupFiles.java @@ -131,7 +131,7 @@ public class BackupFiles { String tempfilename = file.getName(); File tempdir = file.getParentFile(); - Cache.log.debug( + Cache.log.trace( "BACKUPFILES [file!=null] attempting to create temp file for " + tempfilename + " in dir " + tempdir); temp = File.createTempFile(tempfilename, @@ -141,7 +141,7 @@ public class BackupFiles } else { - Cache.log.debug( + Cache.log.trace( "BACKUPFILES [file==null] attempting to create default temp file " + DEFAULT_TEMP_FILE + " with extension " + TEMP_FILE_EXT); @@ -163,15 +163,16 @@ public class BackupFiles public static void classInit() { - Cache.log.debug("BACKUPFILES classInit"); + Cache.initLogger(); + Cache.log.trace("BACKUPFILES classInit"); boolean e = Cache.getDefault(ENABLED, !Platform.isJS()); setEnabled(e); - Cache.log.debug("BACKUPFILES " + (e ? "enabled" : "disabled")); + Cache.log.trace("BACKUPFILES " + (e ? "enabled" : "disabled")); BackupFilesPresetEntry bfpe = BackupFilesPresetEntry .getSavedBackupEntry(); - Cache.log.debug("BACKUPFILES preset scheme " + bfpe.toString()); + Cache.log.trace("BACKUPFILES preset scheme " + bfpe.toString()); setConfirmDelete(bfpe.confirmDelete); - Cache.log.debug("BACKUPFILES confirm delete " + bfpe.confirmDelete); + Cache.log.trace("BACKUPFILES confirm delete " + bfpe.confirmDelete); } public static void setEnabled(boolean flag) @@ -262,7 +263,7 @@ public class BackupFiles return true; } - Cache.log.debug("BACKUPFILES rollBackupFiles starting"); + Cache.log.trace("BACKUPFILES rollBackupFiles starting"); String dir = ""; File dirFile; @@ -270,7 +271,7 @@ public class BackupFiles { dirFile = file.getParentFile(); dir = dirFile.getCanonicalPath(); - Cache.log.debug("BACKUPFILES dir: " + dir); + Cache.log.trace("BACKUPFILES dir: " + dir); } catch (Exception e) { Cache.log.error( @@ -282,7 +283,7 @@ public class BackupFiles String filename = file.getName(); String basename = filename; - Cache.log.debug("BACKUPFILES filename is " + filename); + Cache.log.trace("BACKUPFILES filename is " + filename); boolean ret = true; // Create/move backups up one @@ -295,11 +296,11 @@ public class BackupFiles int nextIndexNum = 0; Cache.log - .debug("BACKUPFILES backupFiles.length: " + backupFiles.length); + .trace("BACKUPFILES backupFiles.length: " + backupFiles.length); if (backupFiles.length == 0) { // No other backup files. Just need to move existing file to backupfile_1 - Cache.log.debug( + Cache.log.trace( "BACKUPFILES no existing backup files, setting index to 1"); nextIndexNum = 1; } @@ -313,7 +314,7 @@ public class BackupFiles if (reverseOrder) { // backup style numbering - Cache.log.debug("BACKUPFILES rolling files in reverse order"); + Cache.log.trace("BACKUPFILES rolling files in reverse order"); int tempMax = noMax ? -1 : max; // noMax == true means no limits @@ -345,7 +346,7 @@ public class BackupFiles // no "oldest" file to delete previousFile = backupfile_n; fileToBeDeleted = null; - Cache.log.debug("BACKUPFILES No oldest file to delete"); + Cache.log.trace("BACKUPFILES No oldest file to delete"); continue; } @@ -356,9 +357,9 @@ public class BackupFiles File replacementFile = backupfile_n; long fileToBeDeletedLMT = fileToBeDeleted.lastModified(); long replacementFileLMT = replacementFile.lastModified(); - Cache.log.debug("BACKUPFILES fileToBeDeleted is " + Cache.log.trace("BACKUPFILES fileToBeDeleted is " + fileToBeDeleted.getAbsolutePath()); - Cache.log.debug("BACKUPFILES replacementFile is " + Cache.log.trace("BACKUPFILES replacementFile is " + backupfile_n.getAbsolutePath()); try @@ -383,7 +384,7 @@ public class BackupFiles boolean delete = confirmNewerDeleteFile(fileToBeDeleted, replacementFile, true); - Cache.log.debug("BACKUPFILES " + Cache.log.trace("BACKUPFILES " + (delete ? "confirmed" : "not") + " deleting file " + fileToBeDeleted.getAbsolutePath() + " which is newer than " @@ -458,12 +459,12 @@ public class BackupFiles } bfsb.append(backupFiles[i].getName()); } - Cache.log.debug("BACKUPFILES backupFiles: " + bfsb.toString()); + Cache.log.trace("BACKUPFILES backupFiles: " + bfsb.toString()); // noMax == true means keep all backup files if ((!noMax) && bfTreeMap.size() >= max) { - Cache.log.debug("BACKUPFILES noMax: " + noMax + ", " + "max: " + Cache.log.trace("BACKUPFILES noMax: " + noMax + ", " + "max: " + max + ", " + "bfTreeMap.size(): " + bfTreeMap.size()); // need to delete some files to keep number of backups to designated // max. @@ -473,7 +474,7 @@ public class BackupFiles int numToDelete = suffix.indexOf(NUM_PLACEHOLDER) > -1 ? bfTreeMap.size() - max + 1 : 0; - Cache.log.debug("BACKUPFILES numToDelete: " + numToDelete); + Cache.log.trace("BACKUPFILES numToDelete: " + numToDelete); // the "replacement" file is the latest backup file being kept (it's // not replacing though) File replacementFile = numToDelete < backupFiles.length @@ -486,7 +487,7 @@ public class BackupFiles File fileToBeDeleted = backupFiles[i]; boolean delete = true; - Cache.log.debug( + Cache.log.trace( "BACKUPFILES fileToBeDeleted: " + fileToBeDeleted); boolean newer = false; @@ -549,7 +550,7 @@ public class BackupFiles String latestBackupFilename = dir + File.separatorChar + BackupFilenameParts.getBackupFilename(nextIndexNum, basename, suffix, digits); - Cache.log.debug("BACKUPFILES Moving old file [" + file + Cache.log.trace("BACKUPFILES Moving old file [" + file + "] to latestBackupFilename [" + latestBackupFilename + "]"); // using boolean '&' instead of '&&' as don't want moveFileToFile attempt to // be conditional (short-circuit) @@ -725,10 +726,10 @@ public class BackupFiles for (int i = 0; i < deleteFiles.size(); i++) { File fileToDelete = deleteFiles.get(i); - Cache.log.debug( - "BACKUPFILES deleting fileToDelete:" + fileToDelete); + Cache.log.trace("BACKUPFILES about to delete fileToDelete:" + + fileToDelete); fileToDelete.delete(); - Cache.log.warn("deleting '" + fileToDelete.getName() + "'"); + Cache.log.warn("deleted '" + fileToDelete.getName() + "'"); } } @@ -895,19 +896,20 @@ public class BackupFiles public static boolean moveFileToFile(File oldFile, File newFile) { + Cache.initLogger(); boolean ret = false; Path oldPath = Paths.get(oldFile.getAbsolutePath()); Path newPath = Paths.get(newFile.getAbsolutePath()); try { // delete destination file - not usually necessary but Just In Case... - Cache.log.debug("BACKUPFILES deleting " + newFile.getAbsolutePath()); + Cache.log.trace("BACKUPFILES deleting " + newFile.getAbsolutePath()); newFile.delete(); - Cache.log.debug("BACKUPFILES moving " + oldFile.getAbsolutePath() + Cache.log.trace("BACKUPFILES moving " + oldFile.getAbsolutePath() + " to " + newFile.getAbsolutePath()); Files.move(oldPath, newPath, StandardCopyOption.REPLACE_EXISTING); ret = true; - Cache.log.debug("BACKUPFILES move seems to have succeeded"); + Cache.log.trace("BACKUPFILES move seems to have succeeded"); } catch (IOException e) { Cache.log.warn("Could not move file '" + oldPath.toString() + "' to '" diff --git a/src/jalview/io/BackupFilesPresetEntry.java b/src/jalview/io/BackupFilesPresetEntry.java index 0734665..ff8a5e6 100644 --- a/src/jalview/io/BackupFilesPresetEntry.java +++ b/src/jalview/io/BackupFilesPresetEntry.java @@ -135,8 +135,6 @@ public class BackupFilesPresetEntry { String savedPresetString = Cache .getDefault(BackupFilesPresetEntry.SAVEDCONFIG, null); - Cache.log.debug("BACKUPFILESPRESETENTRY saved preset string is " - + savedPresetString); BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry .createBackupFilesPresetEntry(savedPresetString); if (savedPreset == null)