From ef143d8ede598a9750e970a86682bac01d4ceaa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Fri, 29 Jan 2021 08:56:18 +0100 Subject: [PATCH] string concatenation in logger inspection --- libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java | 2 +- .../src/com/jpexs/decompiler/flash/abc/ScriptPack.java | 2 +- .../src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java | 2 +- .../jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java | 7 ++++--- .../com/jpexs/decompiler/flash/action/swf4/ActionIf.java | 2 +- .../jpexs/decompiler/flash/action/swf4/ActionJump.java | 4 ++-- .../flash/exporters/script/AS2ScriptExporter.java | 4 ++-- .../flash/exporters/script/AS3ScriptExporter.java | 2 +- .../src/com/jpexs/decompiler/flash/tags/base/TextTag.java | 4 ++-- src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java | 8 ++++---- src/com/jpexs/decompiler/flash/gui/MainPanel.java | 4 ++-- src/com/jpexs/process/win32/Win32ProcessTools.java | 2 +- 12 files changed, 22 insertions(+), 21 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 349d2fd86..152e925ff 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -1621,7 +1621,7 @@ public final class SWF implements SWFContainerItem, Timelined { for (ScriptPack item : packs) { ClassPath key = item.getClassPath(); if (classPaths.contains(key)) { - logger.log(Level.SEVERE, "Duplicate pack path found (" + key + ")!"); + logger.log(Level.SEVERE, "Duplicate pack path found ({0})!", key); } else { classPaths.add(key); ret.add(item); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java index bb0feee3a..898208658 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java @@ -507,7 +507,7 @@ public class ScriptPack extends AS3ClassTreeItem { continue; } addedLines.add(line); - logger.log(Level.FINE, "Script " + path + ": Insert debugline(" + line + ") at pos " + i + " to body " + bodyIndex); + logger.log(Level.FINE, "Script {0}: Insert debugline({1}) at pos {2} to body {3}", new Object[]{path, line, i, bodyIndex}); b.insertInstruction(i + dpos, new AVM2Instruction(0, AVM2Instructions.DebugLine, new int[]{line})); } //remove old debug instructions diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 41f7df544..0fbfe1bf8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -2147,7 +2147,7 @@ public class AVM2Code implements Cloneable { } } if (someIgnored) { - logger.log(Level.WARNING, path + ": One or more invalid jump offsets found in the code. Those instructions were ignored."); + logger.log(Level.WARNING, "{0}: One or more invalid jump offsets found in the code. Those instructions were ignored.", path); } removeIgnored(body); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java index a88b17be0..cdb8e9a83 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java @@ -90,6 +90,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; +import java.util.logging.Level; import java.util.logging.Logger; /** @@ -189,7 +190,7 @@ public class AVM2Graph extends Graph { } public Map> calculateLocalRegsUsage(Set ignoredSwitches, String path, Set allParts) { - logger.fine("--- " + path + " ---"); + logger.log(Level.FINE, "--- {0} ---", path); Map> setLocalPosToGetLocalPos = new TreeMap<>(); Map>> partUnresolvedRegisterToGetLocalPos = new HashMap<>(); Map> partRegisterToLastSetLocalPos = new HashMap<>(); @@ -258,10 +259,10 @@ public class AVM2Graph extends Graph { for (int setLocalPos : setLocalPosToGetLocalPos.keySet()) { AVM2Instruction ins = avm2code.code.get(setLocalPos); int regId = ((SetLocalTypeIns) ins.definition).getRegisterId(ins); - logger.fine("set local reg " + regId + " at pos " + (setLocalPos + 1)); + logger.log(Level.FINE, "set local reg {0} at pos {1}{2}", new Object[]{regId, setLocalPos, 1}); for (int getLocalPos : setLocalPosToGetLocalPos.get(setLocalPos)) { - logger.fine("- usage at pos " + (getLocalPos + 1)); + logger.log(Level.FINE, "- usage at pos {0}{1}", new Object[]{getLocalPos, 1}); } } return setLocalPosToGetLocalPos; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java index 9c2241005..01f9a920a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionIf.java @@ -134,7 +134,7 @@ public class ActionIf extends Action { int jmp = code.adr2pos(targetAddress); int after = code.adr2pos(getAddress() + length); if (jmp == -1) { - Logger.getLogger(ActionIf.class.getName()).log(Level.SEVERE, "Invalid IF jump to ofs" + Helper.formatAddress(targetAddress)); + Logger.getLogger(ActionIf.class.getName()).log(Level.SEVERE, "Invalid IF jump to ofs{0}", Helper.formatAddress(targetAddress)); ret.add(after); } else { ret.add(jmp); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java index 0967b5f96..b2b3bd9e2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionJump.java @@ -12,7 +12,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. */ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.SWFInputStream; @@ -125,7 +125,7 @@ public class ActionJump extends Action { if (ofs == -1) { int length = getBytesLength(); ofs = code.adr2pos(getAddress() + length); - Logger.getLogger(ActionJump.class.getName()).log(Level.SEVERE, "Invalid jump to ofs" + Helper.formatAddress(targetAddress) + " from ofs" + Helper.formatAddress(getAddress())); + Logger.getLogger(ActionJump.class.getName()).log(Level.SEVERE, "Invalid jump to ofs{0} from ofs{1}", new Object[]{Helper.formatAddress(targetAddress), Helper.formatAddress(getAddress())}); } ret.add(ofs); return ret; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS2ScriptExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS2ScriptExporter.java index cdc7e3c72..8e733d198 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS2ScriptExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS2ScriptExporter.java @@ -12,7 +12,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. */ package com.jpexs.decompiler.flash.exporters.script; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; @@ -117,7 +117,7 @@ public class AS2ScriptExporter { try { executor.shutdown(); if (!executor.awaitTermination(Configuration.exportTimeout.get(), TimeUnit.SECONDS)) { - logger.log(Level.SEVERE, Helper.formatTimeToText(Configuration.exportTimeout.get()) + " ActionScript export limit reached"); + logger.log(Level.SEVERE, "{0} ActionScript export limit reached", Helper.formatTimeToText(Configuration.exportTimeout.get())); } } catch (InterruptedException ex) { } finally { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java index 3a007f1f2..23f89e82f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java @@ -430,7 +430,7 @@ public class AS3ScriptExporter { try { executor.shutdown(); if (!executor.awaitTermination(Configuration.exportTimeout.get(), TimeUnit.SECONDS)) { - logger.log(Level.SEVERE, Helper.formatTimeToText(Configuration.exportTimeout.get()) + " ActionScript export limit reached"); + logger.log(Level.SEVERE, "{0} ActionScript export limit reached", Helper.formatTimeToText(Configuration.exportTimeout.get())); } } catch (InterruptedException ex) { } finally { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java index 0c72826ce..9314c0e92 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java @@ -12,7 +12,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. */ package com.jpexs.decompiler.flash.tags.base; import com.jpexs.decompiler.flash.SWF; @@ -267,7 +267,7 @@ public abstract class TextTag extends DrawableTag { } textHeight = rec.textHeight; if (font == null) { - Logger.getLogger(TextTag.class.getName()).log(Level.SEVERE, "Font with id=" + rec.fontId + " was not found."); + Logger.getLogger(TextTag.class.getName()).log(Level.SEVERE, "Font with id={0} was not found.", rec.fontId); continue; } diff --git a/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java b/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java index d53955b93..aeefbe6d0 100644 --- a/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java +++ b/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java @@ -265,7 +265,7 @@ public class DebuggerHandler implements DebugConnectionListener { public boolean addBreakPoint(String scriptName, int line) { synchronized (this) { Logger.getLogger(DebuggerHandler.class - .getName()).log(Level.FINE, "adding bp " + scriptName + ":" + line); + .getName()).log(Level.FINE, "adding bp {0}:{1}", new Object[]{scriptName, line}); if (isBreakpointToRemove(scriptName, line)) { toRemoveBPointMap.get(scriptName).remove(line); if (toRemoveBPointMap.get(scriptName).isEmpty()) { @@ -275,12 +275,12 @@ public class DebuggerHandler implements DebugConnectionListener { } if (isBreakpointConfirmed(scriptName, line)) { - Logger.getLogger(DebuggerHandler.class.getName()).log(Level.FINE, "bp " + scriptName + ":" + line + " already confirmed"); + Logger.getLogger(DebuggerHandler.class.getName()).log(Level.FINE, "bp {0}:{1} already confirmed", new Object[]{scriptName, line}); return true; } if (isBreakpointInvalid(scriptName, line)) { - Logger.getLogger(DebuggerHandler.class.getName()).log(Level.FINE, "bp " + scriptName + ":" + line + " already invalid"); + Logger.getLogger(DebuggerHandler.class.getName()).log(Level.FINE, "bp {0}:{1} already invalid", new Object[]{scriptName, line}); return false; } if (!toAddBPointMap.containsKey(scriptName)) { @@ -289,7 +289,7 @@ public class DebuggerHandler implements DebugConnectionListener { toAddBPointMap.get(scriptName).add(line); Logger .getLogger(DebuggerHandler.class - .getName()).log(Level.FINE, "bp " + scriptName + ":" + line + " added to todo"); + .getName()).log(Level.FINE, "bp {0}:{1} added to todo", new Object[]{scriptName, line}); } try { sendBreakPoints(false); diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index c47032faf..aed826b5e 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -2224,14 +2224,14 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se @Override public boolean handle(TextTag textTag) { String msg = translate("error.text.import"); - logger.log(Level.SEVERE, msg + getTextTagInfo(textTag)); + logger.log(Level.SEVERE, "{0}{1}", new Object[]{msg, getTextTagInfo(textTag)}); return View.showConfirmDialog(MainPanel.this, msg, translate("error"), JOptionPane.OK_CANCEL_OPTION, showAgainImportError, JOptionPane.OK_OPTION) != JOptionPane.OK_OPTION; } @Override public boolean handle(TextTag textTag, String message, long line) { String msg = translate("error.text.invalid.continue").replace("%text%", message).replace("%line%", Long.toString(line)); - logger.log(Level.SEVERE, msg + getTextTagInfo(textTag)); + logger.log(Level.SEVERE, "{0}{1}", new Object[]{msg, getTextTagInfo(textTag)}); return View.showConfirmDialog(MainPanel.this, msg, translate("error"), JOptionPane.OK_CANCEL_OPTION, showAgainInvalidText, JOptionPane.OK_OPTION) != JOptionPane.OK_OPTION; } }); diff --git a/src/com/jpexs/process/win32/Win32ProcessTools.java b/src/com/jpexs/process/win32/Win32ProcessTools.java index de1854a86..47ea0d716 100644 --- a/src/com/jpexs/process/win32/Win32ProcessTools.java +++ b/src/com/jpexs/process/win32/Win32ProcessTools.java @@ -73,7 +73,7 @@ public class Win32ProcessTools extends ProcessTools { mbi = new MEMORY_BASIC_INFORMATION(); BaseTSD.SIZE_T t = Kernel32.INSTANCE.VirtualQueryEx(hOtherProcess, lpMem, mbi, new BaseTSD.SIZE_T(mbi.size())); if (t.longValue() == 0) { - Logger.getLogger(Win32ProcessTools.class.getName()).log(Level.SEVERE, "Cannot get page ranges. Last error:" + Kernel32.INSTANCE.GetLastError()); + Logger.getLogger(Win32ProcessTools.class.getName()).log(Level.SEVERE, "Cannot get page ranges. Last error:{0}", Kernel32.INSTANCE.GetLastError()); break; } ret.add(mbi);