diff --git a/.classpath b/.classpath
index fb1a79e75..da46644a7 100644
--- a/.classpath
+++ b/.classpath
@@ -19,5 +19,7 @@
+
+
diff --git a/build.xml b/build.xml
index 932571124..112d6095f 100644
--- a/build.xml
+++ b/build.xml
@@ -5,6 +5,8 @@
+
+
@@ -31,7 +33,7 @@
deprecation="false"
debug="false"
debuglevel="lines,vars,source"
- classpath="${classpath}:${jorbis.file}:${rsyntaxtextarea.file}:${jhexview.file}:${montemedia.file}:${apng_writer.file}:${json.file}:${commonmark.file}:${flatlaf.file}:${flatlafthemes.file}">
+ classpath="${classpath}:${tinylog-api.file}:${tinylog-impl.file}:${jorbis.file}:${rsyntaxtextarea.file}:${jhexview.file}:${montemedia.file}:${apng_writer.file}:${json.file}:${commonmark.file}:${flatlaf.file}:${flatlafthemes.file}">
@@ -50,6 +52,8 @@
basedir="${build.path}"
includes="**/*"
level="9">
+
+
diff --git a/lib/tinylog/license.txt b/lib/tinylog/license.txt
new file mode 100644
index 000000000..f433b1a53
--- /dev/null
+++ b/lib/tinylog/license.txt
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/lib/tinylog/readme.txt b/lib/tinylog/readme.txt
new file mode 100644
index 000000000..cadda4f7a
--- /dev/null
+++ b/lib/tinylog/readme.txt
@@ -0,0 +1,24 @@
+Copyright 2018 Martin Winandy
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+this file except in compliance with the License. You may obtain a copy of the
+License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed
+under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+CONDITIONS OF ANY KIND, either express or implied. See the License for the
+specific language governing permissions and limitations under the License.
+
+-------------------
+ Using tinylog
+-------------------
+
+To use tinylog as a logging framework, add tinylog-api.jar and an
+implementation such as tinylog-impl.jar to the classpath.
+
+tinylog-impl.jar is the default implementation for tinylog. There are also
+implementations for application and web servers to use their logging
+frameworks. Since tinylog 2, multiple implementations can even be used in
+parallel.
diff --git a/lib/tinylog/tinylog-api-2.7.0-sources.jar b/lib/tinylog/tinylog-api-2.7.0-sources.jar
new file mode 100644
index 000000000..8ba31eea1
Binary files /dev/null and b/lib/tinylog/tinylog-api-2.7.0-sources.jar differ
diff --git a/lib/tinylog/tinylog-api-2.7.0.jar b/lib/tinylog/tinylog-api-2.7.0.jar
new file mode 100644
index 000000000..94c2bdc36
Binary files /dev/null and b/lib/tinylog/tinylog-api-2.7.0.jar differ
diff --git a/lib/tinylog/tinylog-impl-2.7.0-sources.jar b/lib/tinylog/tinylog-impl-2.7.0-sources.jar
new file mode 100644
index 000000000..a72d47e1c
Binary files /dev/null and b/lib/tinylog/tinylog-impl-2.7.0-sources.jar differ
diff --git a/lib/tinylog/tinylog-impl-2.7.0.jar b/lib/tinylog/tinylog-impl-2.7.0.jar
new file mode 100644
index 000000000..3daf6899c
Binary files /dev/null and b/lib/tinylog/tinylog-impl-2.7.0.jar differ
diff --git a/src/org/infinity/NearInfinity.java b/src/org/infinity/NearInfinity.java
index 5068dde3e..71ddbfdee 100644
--- a/src/org/infinity/NearInfinity.java
+++ b/src/org/infinity/NearInfinity.java
@@ -134,6 +134,7 @@
import org.infinity.util.io.FileEx;
import org.infinity.util.io.FileManager;
import org.infinity.util.tuples.Couple;
+import org.tinylog.Logger;
public final class NearInfinity extends JFrame implements ActionListener, ViewableContainer {
// the current Near Infinity version
@@ -371,7 +372,7 @@ public static void main(String args[]) {
final LookAndFeel o = lf.getDeclaredConstructor().newInstance();
UIManager.installLookAndFeel(o.getName(), o.getClass().getCanonicalName());
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
@@ -445,7 +446,7 @@ protected Void doInBackground() throws Exception {
try {
checkFileAccess(tlkFile);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
JOptionPane.showMessageDialog(NearInfinity.this,
String.format("Unable to open the game \"%s\".\n" +
"The file \"%s\" is locked by another process.",
@@ -468,7 +469,7 @@ protected Void doInBackground() throws Exception {
worker.execute();
worker.get();
} catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
+ Logger.error(e);
System.exit(10);
}
@@ -484,7 +485,7 @@ public void windowClosing(WindowEvent event) {
UIManager.setLookAndFeel(info.getClassName());
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
cacheResourceIcons(true);
@@ -623,7 +624,7 @@ public void popupWindowWillBecomeInvisible(PopupWindowEvent event) {
}
}
} catch (Exception e) {
- System.out.println("Failed to check for updates: " + e.getMessage());
+ Logger.warn("Failed to check for updates: {}", e.getMessage());
}
}).start();
}
@@ -704,7 +705,7 @@ public void actionPerformed(ActionEvent event) {
LookAndFeelInfo info = BrowserMenuBar.getInstance().getOptions().getLookAndFeel();
updateLookAndFeel(info, true);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
} else if (event.getActionCommand().equals("Collapse")) {
try {
@@ -840,7 +841,7 @@ public void openGame(Path keyFile) {
try {
checkFileAccess(tlkPath);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
JOptionPane.showMessageDialog(NearInfinity.this,
String.format("The file \"%s\" of the game \"%s\"\nis locked by another process. "
+ "Reverting to the previous game.", tlkPath.getFileName(),
@@ -1285,7 +1286,7 @@ private boolean migratePreferences(String sourceNode, Preferences curPrefs, bool
}
} catch (Exception e) {
prefsOld = null;
- e.printStackTrace();
+ Logger.error(e);
}
if (isPrefsEmpty && prefsOld != null && !prefsOld.equals(curPrefs)) {
try {
@@ -1297,7 +1298,7 @@ private boolean migratePreferences(String sourceNode, Preferences curPrefs, bool
curPrefs.clear();
} catch (BackingStoreException bse) {
}
- e.printStackTrace();
+ Logger.error(e);
if (showError) {
JOptionPane.showMessageDialog(this, "Error migrating old Near Infinity settings. Using defaults.", "Error",
JOptionPane.ERROR_MESSAGE);
@@ -1350,7 +1351,7 @@ private void enableOSXQuitStrategy() {
method.invoke(instance, closeAllWindows);
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
@@ -1370,7 +1371,7 @@ private boolean launchGameBinary(Path binPath) {
}
retVal = true;
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
return retVal;
@@ -1578,7 +1579,7 @@ private void cacheResourceIcons(boolean threaded) {
}
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
};
@@ -1593,7 +1594,7 @@ protected Void doInBackground() throws Exception {
try {
operation.perform();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
setProgress(100);
return null;
@@ -1660,7 +1661,7 @@ public void write(byte buf[], int off, int len) {
try {
text.append(new String(buf, off, len));
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
@@ -1698,7 +1699,7 @@ public void drop(DropTargetDropEvent event) {
event.acceptDrop(DnDConstants.ACTION_COPY);
files = (List) event.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
event.dropComplete(false);
}
event.dropComplete(true);
diff --git a/src/org/infinity/check/BCSIDSChecker.java b/src/org/infinity/check/BCSIDSChecker.java
index dd931a119..89674ec13 100644
--- a/src/org/infinity/check/BCSIDSChecker.java
+++ b/src/org/infinity/check/BCSIDSChecker.java
@@ -41,6 +41,7 @@
import org.infinity.resource.key.ResourceEntry;
import org.infinity.search.AbstractSearcher;
import org.infinity.util.Misc;
+import org.tinylog.Logger;
/** Performs checking {@link BcsResource BCS} & {@code BS} resources. */
public final class BCSIDSChecker extends AbstractSearcher implements Runnable, ActionListener, ListSelectionListener {
@@ -179,9 +180,7 @@ protected Runnable newWorker(ResourceEntry entry) {
try {
checkScript(new BcsResource(entry));
} catch (Exception e) {
- synchronized (System.err) {
- e.printStackTrace();
- }
+ Logger.error(e);
}
advanceProgress();
};
diff --git a/src/org/infinity/check/CreInvChecker.java b/src/org/infinity/check/CreInvChecker.java
index 23a8aeecf..da7b25746 100644
--- a/src/org/infinity/check/CreInvChecker.java
+++ b/src/org/infinity/check/CreInvChecker.java
@@ -44,6 +44,7 @@
import org.infinity.resource.key.ResourceEntry;
import org.infinity.search.AbstractSearcher;
import org.infinity.util.Misc;
+import org.tinylog.Logger;
/** Performs checking {@link CreResource CRE} & {@code CHR} resources. */
public final class CreInvChecker extends AbstractSearcher implements Runnable, ActionListener, ListSelectionListener {
@@ -181,9 +182,7 @@ protected Runnable newWorker(ResourceEntry entry) {
try {
checkCreature(new CreResource(entry));
} catch (Exception e) {
- synchronized (System.err) {
- e.printStackTrace();
- }
+ Logger.error(e);
}
advanceProgress();
};
diff --git a/src/org/infinity/check/DialogChecker.java b/src/org/infinity/check/DialogChecker.java
index 3d0915621..e33637325 100644
--- a/src/org/infinity/check/DialogChecker.java
+++ b/src/org/infinity/check/DialogChecker.java
@@ -48,6 +48,7 @@
import org.infinity.resource.key.ResourceEntry;
import org.infinity.search.AbstractSearcher;
import org.infinity.util.Misc;
+import org.tinylog.Logger;
/** Performs checking {@link DlgResource DLG} resources. */
public final class DialogChecker extends AbstractSearcher
@@ -242,9 +243,7 @@ protected Runnable newWorker(ResourceEntry entry) {
}
}
} catch (Exception e) {
- synchronized (System.err) {
- e.printStackTrace();
- }
+ Logger.error(e);
}
advanceProgress();
};
diff --git a/src/org/infinity/check/ResourceUseChecker.java b/src/org/infinity/check/ResourceUseChecker.java
index 10454331d..b2e8e2a33 100644
--- a/src/org/infinity/check/ResourceUseChecker.java
+++ b/src/org/infinity/check/ResourceUseChecker.java
@@ -58,6 +58,7 @@
import org.infinity.resource.text.PlainTextResource;
import org.infinity.util.Misc;
import org.infinity.util.StringTable;
+import org.tinylog.Logger;
public final class ResourceUseChecker extends AbstractChecker
implements Runnable, ListSelectionListener, ActionListener {
@@ -245,9 +246,7 @@ private void checkDialog(DlgResource dialog) {
checkCode(compiler.getCode(), type);
} catch (Exception e) {
- synchronized (System.err) {
- e.printStackTrace();
- }
+ Logger.error(e);
}
} else if (checkTypes.contains("WAV") && (entry instanceof State || entry instanceof Transition)) {
for (final StructEntry e : ((AbstractStruct) entry).getFlatFields()) {
@@ -263,9 +262,7 @@ private void checkScript(BcsResource script) {
try {
checkCode(script.getCode(), ScriptType.BCS);
} catch (Exception e) {
- synchronized (System.err) {
- e.printStackTrace();
- }
+ Logger.error(e);
}
}
diff --git a/src/org/infinity/check/ScriptChecker.java b/src/org/infinity/check/ScriptChecker.java
index 096dc2b99..1fa10873e 100644
--- a/src/org/infinity/check/ScriptChecker.java
+++ b/src/org/infinity/check/ScriptChecker.java
@@ -43,6 +43,7 @@
import org.infinity.resource.key.ResourceEntry;
import org.infinity.search.AbstractSearcher;
import org.infinity.util.Misc;
+import org.tinylog.Logger;
/** Performs checking {@link BcsResource BCS} & {@code BS} resources. */
public final class ScriptChecker extends AbstractSearcher
@@ -240,9 +241,7 @@ protected Runnable newWorker(ResourceEntry entry) {
}
}
} catch (Exception e) {
- synchronized (System.err) {
- e.printStackTrace();
- }
+ Logger.error(e);
}
advanceProgress();
};
diff --git a/src/org/infinity/check/StringUseChecker.java b/src/org/infinity/check/StringUseChecker.java
index 93623347c..dcbde2e78 100644
--- a/src/org/infinity/check/StringUseChecker.java
+++ b/src/org/infinity/check/StringUseChecker.java
@@ -61,6 +61,7 @@
import org.infinity.util.StringTable;
import org.infinity.util.Table2da;
import org.infinity.util.Table2daCache;
+import org.tinylog.Logger;
public final class StringUseChecker extends AbstractSearcher
implements Runnable, ListSelectionListener, SearchClient, ActionListener {
@@ -375,9 +376,7 @@ private void checkDialog(DlgResource dialog) {
checkCode(compiler.getCode(), type);
} catch (Exception e) {
- synchronized (System.err) {
- e.printStackTrace();
- }
+ Logger.error(e);
}
}
}
@@ -387,9 +386,7 @@ private void checkScript(BcsResource script) {
try {
checkCode(script.getCode(), ScriptType.BCS);
} catch (Exception e) {
- synchronized (System.err) {
- e.printStackTrace();
- }
+ Logger.error(e);
}
}
@@ -550,7 +547,7 @@ private void checkBestiaryLua() {
}
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
diff --git a/src/org/infinity/check/StringValidationChecker.java b/src/org/infinity/check/StringValidationChecker.java
index c5dff6629..ecbb45e19 100644
--- a/src/org/infinity/check/StringValidationChecker.java
+++ b/src/org/infinity/check/StringValidationChecker.java
@@ -55,6 +55,7 @@
import org.infinity.util.Misc;
import org.infinity.util.StringTable;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
public class StringValidationChecker extends AbstractSearcher
implements Runnable, ActionListener, ListSelectionListener {
@@ -257,17 +258,13 @@ protected Runnable newWorker(ResourceEntry entry) {
try {
validateInput(decoder, inBuf, outBuf, entry, idx, isFemale);
} catch (IllegalStateException | CoderMalfunctionError e) {
- synchronized (System.err) {
- e.printStackTrace();
- }
+ Logger.error(e);
}
}
decoder.reset();
}
} catch (Exception e) {
- synchronized (System.err) {
- e.printStackTrace();
- }
+ Logger.error(e);
}
advanceProgress();
diff --git a/src/org/infinity/check/StrrefIndexChecker.java b/src/org/infinity/check/StrrefIndexChecker.java
index 18c9edc9c..fa63e74bf 100644
--- a/src/org/infinity/check/StrrefIndexChecker.java
+++ b/src/org/infinity/check/StrrefIndexChecker.java
@@ -52,6 +52,7 @@
import org.infinity.util.StringTable;
import org.infinity.util.Table2da;
import org.infinity.util.Table2daCache;
+import org.tinylog.Logger;
public class StrrefIndexChecker extends AbstractChecker implements ListSelectionListener {
private final ChildFrame resultFrame = new ChildFrame("Illegal strrefs found", true);
@@ -217,9 +218,7 @@ private void checkDialog(DlgResource dialog) {
}
}
} catch (Exception e) {
- synchronized (System.err) {
- e.printStackTrace();
- }
+ Logger.error(e);
}
}
}
@@ -254,9 +253,7 @@ private void checkScript(BcsResource script) {
}
}
} catch (Exception e) {
- synchronized (System.err) {
- e.printStackTrace();
- }
+ Logger.error(e);
}
}
@@ -302,9 +299,7 @@ private void checkText(PlainTextResource text) {
}
}
} catch (NumberFormatException e) {
- synchronized (System.err) {
- e.printStackTrace();
- }
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/check/StructChecker.java b/src/org/infinity/check/StructChecker.java
index 320639028..5d2584dbe 100644
--- a/src/org/infinity/check/StructChecker.java
+++ b/src/org/infinity/check/StructChecker.java
@@ -57,6 +57,7 @@
import org.infinity.resource.wed.Tilemap;
import org.infinity.util.Misc;
import org.infinity.util.StringTable;
+import org.tinylog.Logger;
public final class StructChecker extends AbstractChecker implements ListSelectionListener {
private static final String[] FILETYPES = { "ARE", "CHR", "CHU", "CRE", "DLG", "EFF", "GAM", "ITM", "PRO", "SPL",
@@ -498,7 +499,7 @@ private void showInViewer(Corruption corruption, boolean newWindow) {
try {
((AbstractStruct) res).getViewer().selectEntry(offset);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
} else {
@@ -512,7 +513,7 @@ private void showInViewer(Corruption corruption, boolean newWindow) {
try {
((AbstractStruct) res).getViewer().selectEntry(offset);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
} else {
@@ -522,7 +523,7 @@ private void showInViewer(Corruption corruption, boolean newWindow) {
try {
((AbstractStruct) viewable).getViewer().selectEntry(offset);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
});
diff --git a/src/org/infinity/datatype/AreResourceRef.java b/src/org/infinity/datatype/AreResourceRef.java
index f2dd49478..0107b7758 100644
--- a/src/org/infinity/datatype/AreResourceRef.java
+++ b/src/org/infinity/datatype/AreResourceRef.java
@@ -47,8 +47,8 @@ public AreResourceRef(ByteBuffer buffer, int offset, String name, AreResource ar
}
// ResourceEntry entry = ResourceFactory.getInstance().getResourceEntry(getResourceName());
// if (!isLegalEntry(entry)) {
-// System.out.println("Illegal: " + entry + " from " + entry.getActualFile());
-// System.out.println("In: " + are.getResourceEntry() + " from " + are.getResourceEntry().getActualFile());
+// Logger.info("Illegal: {} from {}", entry, entry.getActualFile());
+// Logger.info("In: {} from {}", are.getResourceEntry(), are.getResourceEntry().getActualFile());
// }
}
diff --git a/src/org/infinity/datatype/Bestiary.java b/src/org/infinity/datatype/Bestiary.java
index 75fbc89aa..6862a1cbe 100644
--- a/src/org/infinity/datatype/Bestiary.java
+++ b/src/org/infinity/datatype/Bestiary.java
@@ -67,6 +67,7 @@
import org.infinity.util.IniMapSection;
import org.infinity.util.Misc;
import org.infinity.util.StringTable;
+import org.tinylog.Logger;
/**
* Datatype for {@link GamResource#GAM_BESTIARY Bestiary} field of the {@link GamResource GAM} resource.
@@ -809,18 +810,17 @@ private static List readCreatures() {
private static List readCreatures(String filename, IniMap ini) {
final IniMapSection init = ini.getSection("init");
if (init == null) {
- System.err.println(filename + ": [init] section not found in the file. Creatures not loaded");
+ Logger.warn("{}: [init] section not found in the file. Creatures not loaded", filename);
return Collections.emptyList();
}
final IniMapEntry entry = init.getEntry("beastcount");
if (entry == null) {
- System.err.println(filename + ": \"beastcount\" key in [init] section not found. Creatures not loaded");
+ Logger.warn("{}: \"beastcount\" key in [init] section not found. Creatures not loaded", filename);
return Collections.emptyList();
}
final Integer count = entry.getIntValue();
if (count == null) {
- System.err.println(filename + ": \"beastcount\" key in [init] section: expected integer buf found "
- + entry.getValue() + ". Creatures not loaded");
+ Logger.warn("{}: \"beastcount\" key in [init] section: expected integer but found {}. Creatures not loaded.", filename, entry.getValue());
return Collections.emptyList();
}
@@ -833,8 +833,7 @@ private static List readCreatures(String filename, IniMap ini) {
continue;
}
if (i < 0 || i >= 256) {
- System.err.println(
- filename + ": invalid creature number " + i + ", expected number in range [0; 256]. Creature skipped");
+ Logger.warn("{}: invalid creature number {}, expected number in range [0; 256]. Creature skipped.", filename, i);
continue;
}
result.ensureCapacity(i);
diff --git a/src/org/infinity/datatype/ColorValue.java b/src/org/infinity/datatype/ColorValue.java
index 31fdcb377..9b959d96e 100644
--- a/src/org/infinity/datatype/ColorValue.java
+++ b/src/org/infinity/datatype/ColorValue.java
@@ -61,6 +61,7 @@
import org.infinity.util.Misc;
import org.infinity.util.Table2da;
import org.infinity.util.Table2daCache;
+import org.tinylog.Logger;
/**
* Field that represents indexed color or color range.
@@ -431,7 +432,7 @@ private void initEntries(int defaultWidth, int defaultHeight) {
colors.add(range);
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/datatype/Datatype.java b/src/org/infinity/datatype/Datatype.java
index f37d35e03..20ca9d25a 100644
--- a/src/org/infinity/datatype/Datatype.java
+++ b/src/org/infinity/datatype/Datatype.java
@@ -19,6 +19,7 @@
import org.infinity.resource.StructEntry;
import org.infinity.util.io.ByteBufferOutputStream;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* Base class for all types of fields. Supplies base properties for fields: its name (not stored in the file), offset in
@@ -152,7 +153,7 @@ public ByteBuffer getDataBuffer() {
try (ByteBufferOutputStream bbos = new ByteBufferOutputStream(bb)) {
write(bbos);
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
bb.position(0);
return bb;
diff --git a/src/org/infinity/datatype/DecNumber.java b/src/org/infinity/datatype/DecNumber.java
index 9bb9d38e9..6265c059f 100644
--- a/src/org/infinity/datatype/DecNumber.java
+++ b/src/org/infinity/datatype/DecNumber.java
@@ -12,6 +12,7 @@
import java.util.Objects;
import org.infinity.resource.AbstractStruct;
+import org.tinylog.Logger;
/**
* Field that represents numerical value which is usually edited in a decimal mode.
@@ -52,7 +53,7 @@ public boolean update(Object value) {
}
return true;
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
return false;
diff --git a/src/org/infinity/datatype/EffectType.java b/src/org/infinity/datatype/EffectType.java
index 89f5e4795..58f3ec652 100644
--- a/src/org/infinity/datatype/EffectType.java
+++ b/src/org/infinity/datatype/EffectType.java
@@ -12,6 +12,7 @@
import org.infinity.resource.AbstractStruct;
import org.infinity.resource.StructEntry;
import org.infinity.resource.effects.BaseOpcode;
+import org.tinylog.Logger;
public final class EffectType extends Bitmap implements UpdateListener {
// EffectType-specific field labels
@@ -42,7 +43,7 @@ public boolean updateValue(AbstractStruct struct) {
struct.addFields(this, list);
return true;
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
return false;
}
@@ -56,7 +57,7 @@ public boolean valueUpdated(UpdateEvent event) {
try {
return BaseOpcode.updateOpcode(event.getStructure());
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
return false;
}
@@ -80,7 +81,7 @@ public int readAttributes(ByteBuffer buffer, int off, List list) {
try {
off = BaseOpcode.makeEffectStruct(getValue(), this, buffer, off, list, isV1);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
attrLength = off - attrLength;
return off;
diff --git a/src/org/infinity/datatype/FloatNumber.java b/src/org/infinity/datatype/FloatNumber.java
index 0514391c4..ad9d674bb 100644
--- a/src/org/infinity/datatype/FloatNumber.java
+++ b/src/org/infinity/datatype/FloatNumber.java
@@ -12,6 +12,7 @@
import org.infinity.resource.AbstractStruct;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* Field that represents numerical value which is usually edited in a floating point mode.
@@ -51,7 +52,7 @@ public boolean update(Object value) {
return true;
} catch (NumberFormatException e) {
- e.printStackTrace();
+ Logger.error(e);
}
return false;
}
diff --git a/src/org/infinity/datatype/HexNumber.java b/src/org/infinity/datatype/HexNumber.java
index 4fa09c440..14097c588 100644
--- a/src/org/infinity/datatype/HexNumber.java
+++ b/src/org/infinity/datatype/HexNumber.java
@@ -6,6 +6,8 @@
import java.nio.ByteBuffer;
+import org.tinylog.Logger;
+
public class HexNumber extends DecNumber {
public HexNumber(ByteBuffer buffer, int offset, int length, String desc) {
super(buffer, offset, length, desc);
@@ -19,7 +21,7 @@ public boolean update(Object value) {
setValue((int) DecNumber.parseNumber(value, getSize(), true, true));
return true;
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
return false;
}
diff --git a/src/org/infinity/datatype/ItemTypeBitmap.java b/src/org/infinity/datatype/ItemTypeBitmap.java
index d60efad59..0f46d12e1 100644
--- a/src/org/infinity/datatype/ItemTypeBitmap.java
+++ b/src/org/infinity/datatype/ItemTypeBitmap.java
@@ -16,6 +16,7 @@
import org.infinity.util.Misc;
import org.infinity.util.Table2da;
import org.infinity.util.Table2daCache;
+import org.tinylog.Logger;
/**
* Specialized {@link HashBitmap} that uses a mix of hardcoded entries and custom entries from ITEMTYPE.2DA
@@ -104,7 +105,7 @@ private static TreeMap buildCategories() {
retVal.put((long) idx, catName);
} catch (NumberFormatException e) {
// skip entry with log message
- System.err.printf("%s: Invalid index at row=%d (value=%s)\n", TABLE_NAME, row, idxValue);
+ Logger.warn("{}: Invalid index at row={} (value={})", TABLE_NAME, row, idxValue);
}
}
} else if (Profile.getEngine() == Profile.Engine.PST) {
diff --git a/src/org/infinity/datatype/MultiNumber.java b/src/org/infinity/datatype/MultiNumber.java
index 7d6111de9..f1c211414 100644
--- a/src/org/infinity/datatype/MultiNumber.java
+++ b/src/org/infinity/datatype/MultiNumber.java
@@ -32,6 +32,7 @@
import org.infinity.gui.menu.BrowserMenuBar;
import org.infinity.resource.AbstractStruct;
import org.infinity.util.Misc;
+import org.tinylog.Logger;
/**
* A Number object consisting of multiple values of a given number of bits.
@@ -393,7 +394,7 @@ public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
data[VALUE][rowIndex] = Integer.valueOf(newVal);
fireTableCellUpdated(rowIndex, columnIndex);
} catch (NumberFormatException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/datatype/ResourceRef.java b/src/org/infinity/datatype/ResourceRef.java
index a7d10e2d1..ea8924220 100644
--- a/src/org/infinity/datatype/ResourceRef.java
+++ b/src/org/infinity/datatype/ResourceRef.java
@@ -46,6 +46,7 @@
import org.infinity.resource.sound.SoundResource;
import org.infinity.util.Misc;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* Represents reference to another resource in game. This resource can be sound, item, dialog, creature, image.
@@ -429,7 +430,7 @@ private void closeResource(Resource resource) {
try {
((Closeable) resource).close();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/datatype/StringRef.java b/src/org/infinity/datatype/StringRef.java
index 66a25136b..8aef8bab7 100644
--- a/src/org/infinity/datatype/StringRef.java
+++ b/src/org/infinity/datatype/StringRef.java
@@ -54,6 +54,7 @@
import org.infinity.util.Misc;
import org.infinity.util.StringTable;
import org.infinity.util.io.FileManager;
+import org.tinylog.Logger;
/**
* A struct field that represents reference to string in a talk table file (dialog.tlk or dialogF.tlk).
@@ -474,7 +475,7 @@ private String getStringRef(int strref, StringTable.Format fmt) {
}
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
} else {
// load TOH/TOT directly
diff --git a/src/org/infinity/datatype/Summon2daBitmap.java b/src/org/infinity/datatype/Summon2daBitmap.java
index a8a35c576..29dc93118 100644
--- a/src/org/infinity/datatype/Summon2daBitmap.java
+++ b/src/org/infinity/datatype/Summon2daBitmap.java
@@ -11,6 +11,7 @@
import org.infinity.resource.ResourceFactory;
import org.infinity.util.Table2da;
import org.infinity.util.Table2daCache;
+import org.tinylog.Logger;
/** Specialized HashBitmap type for parsing {@code SMTABLES.2DA} from IWDEE. */
public class Summon2daBitmap extends HashBitmap {
@@ -38,10 +39,10 @@ private static synchronized TreeMap getSummonTable() {
String resref = table.get(row, 1).toUpperCase(Locale.ENGLISH) + ".2DA";
SUMMON_MAP.put(id, resref);
if (!ResourceFactory.resourceExists(resref)) {
- System.err.println("Resource does not exist: " + resref);
+ Logger.warn("Resource does not exist: {}", resref);
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/datatype/UnknownDecimal.java b/src/org/infinity/datatype/UnknownDecimal.java
index 21fc2c810..fdbb67878 100644
--- a/src/org/infinity/datatype/UnknownDecimal.java
+++ b/src/org/infinity/datatype/UnknownDecimal.java
@@ -8,6 +8,7 @@
import java.nio.ByteBuffer;
import org.infinity.resource.AbstractStruct;
+import org.tinylog.Logger;
/**
* Field that represents binary data in decimal format in their editor.
@@ -50,7 +51,7 @@ public boolean updateValue(AbstractStruct struct) {
return true;
}
} catch (NumberFormatException e) {
- e.printStackTrace();
+ Logger.error(e);
}
return false;
}
diff --git a/src/org/infinity/datatype/UnsignHexNumber.java b/src/org/infinity/datatype/UnsignHexNumber.java
index e65494be2..0b99c36ca 100644
--- a/src/org/infinity/datatype/UnsignHexNumber.java
+++ b/src/org/infinity/datatype/UnsignHexNumber.java
@@ -6,6 +6,8 @@
import java.nio.ByteBuffer;
+import org.tinylog.Logger;
+
public class UnsignHexNumber extends UnsignDecNumber {
public UnsignHexNumber(ByteBuffer buffer, int offset, int length, String desc) {
super(buffer, offset, length, desc);
@@ -19,7 +21,7 @@ public boolean update(Object value) {
setValue(UnsignDecNumber.parseNumber(value, getSize(), false, true));
return true;
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
return false;
}
diff --git a/src/org/infinity/gui/BIFFEditor.java b/src/org/infinity/gui/BIFFEditor.java
index 4907afd66..4eb909796 100644
--- a/src/org/infinity/gui/BIFFEditor.java
+++ b/src/org/infinity/gui/BIFFEditor.java
@@ -45,6 +45,7 @@
import org.infinity.util.io.FileEx;
import org.infinity.util.io.FileManager;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
public final class BIFFEditor implements ActionListener, ListSelectionListener, Runnable {
private static boolean firstRun = true;
@@ -121,7 +122,7 @@ public void run() {
progress.setProgress(2, false);
JOptionPane.showMessageDialog(editframe, "Error while extracting files from " + bifentry, "Error",
JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
blocker.setBlocked(false);
return;
}
@@ -147,7 +148,7 @@ public void run() {
} catch (Exception e) {
progress.setProgress(3, false);
JOptionPane.showMessageDialog(editframe, "Error while saving " + bifentry, "Error", JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
blocker.setBlocked(false);
return;
}
@@ -159,7 +160,7 @@ public void run() {
try {
Files.delete(file);
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
@@ -182,7 +183,7 @@ public void run() {
} catch (IOException e) {
progress.setProgress(6, false);
JOptionPane.showMessageDialog(editframe, "Error while saving keyfile", "Error", JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
}
ResourceFactory.getResourceTreeModel().sort();
blocker.setBlocked(false);
diff --git a/src/org/infinity/gui/BcsDropFrame.java b/src/org/infinity/gui/BcsDropFrame.java
index 93f1d2bd4..86556d2d0 100644
--- a/src/org/infinity/gui/BcsDropFrame.java
+++ b/src/org/infinity/gui/BcsDropFrame.java
@@ -63,6 +63,7 @@
import org.infinity.util.Misc;
import org.infinity.util.io.FileEx;
import org.infinity.util.io.FileManager;
+import org.tinylog.Logger;
public class BcsDropFrame extends ChildFrame implements ActionListener, ListSelectionListener {
private final JButton bOpen = new JButton("Open selected", Icons.ICON_OPEN_16.getIcon());
@@ -242,7 +243,7 @@ private SortedSet compileFile(Path file) {
line = br.readLine();
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
return null;
}
Compiler compiler = new Compiler(source.toString());
@@ -269,7 +270,7 @@ private SortedSet compileFile(Path file) {
try (BufferedWriter bw = Files.newBufferedWriter(output)) {
bw.write(compiled);
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
return null;
}
}
@@ -285,7 +286,7 @@ private boolean decompileFile(Path file) {
line = br.readLine();
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
return false;
}
String filename = file.getFileName().toString();
@@ -302,7 +303,7 @@ private boolean decompileFile(Path file) {
bw.write(decompiler.getSource().replaceAll("\r?\n", Misc.LINE_SEPARATOR));
bw.newLine();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
return false;
}
return true;
@@ -322,7 +323,7 @@ private void filesDropped(Component component, List files) {
files.add(p.toFile());
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
} else if (file.getFileName().toString().toUpperCase(Locale.ENGLISH).endsWith(".BAF")) {
SortedSet errors = compileFile(file);
@@ -352,7 +353,7 @@ private void filesDropped(Component component, List files) {
files.add(p.toFile());
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
} else if (file.getFileName().toString().toUpperCase(Locale.ENGLISH).endsWith(".BCS")
|| file.getFileName().toString().toUpperCase(Locale.ENGLISH).endsWith(".BS")) {
@@ -407,7 +408,7 @@ public void drop(DropTargetDropEvent event) {
event.acceptDrop(DnDConstants.ACTION_COPY);
files = (List) event.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
event.dropComplete(false);
return;
}
diff --git a/src/org/infinity/gui/ChildFrame.java b/src/org/infinity/gui/ChildFrame.java
index b2d2ddb85..a797fc3cb 100644
--- a/src/org/infinity/gui/ChildFrame.java
+++ b/src/org/infinity/gui/ChildFrame.java
@@ -34,6 +34,7 @@
import org.infinity.resource.Viewable;
import org.infinity.resource.ViewableContainer;
import org.infinity.resource.graphics.BamResource;
+import org.tinylog.Logger;
public class ChildFrame extends JFrame {
private static final List WINDOWS = new ArrayList<>();
@@ -190,7 +191,7 @@ public void actionPerformed(ActionEvent e) {
return;
}
} catch (Exception e2) {
- e2.printStackTrace();
+ Logger.error(e2);
return;
}
WINDOWS.remove(ChildFrame.this);
@@ -338,7 +339,7 @@ private static void closeWindow(ChildFrame frame, WindowEvent event) {
}
frame.dispose();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/gui/ChooseBIFFrame.java b/src/org/infinity/gui/ChooseBIFFrame.java
index ecafd399f..c910fd675 100644
--- a/src/org/infinity/gui/ChooseBIFFrame.java
+++ b/src/org/infinity/gui/ChooseBIFFrame.java
@@ -29,6 +29,7 @@
import org.infinity.resource.ResourceFactory;
import org.infinity.resource.key.AbstractBIFFReader;
import org.infinity.resource.key.BIFFEntry;
+import org.tinylog.Logger;
final class ChooseBIFFrame extends ChildFrame implements ActionListener {
private final BIFFEditor editor;
@@ -211,7 +212,7 @@ public void actionPerformed(ActionEvent event) {
close();
editor.makeEditor(entry, file.getType());
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/gui/DebugConsole.java b/src/org/infinity/gui/DebugConsole.java
index fea613db0..f8aa330fc 100644
--- a/src/org/infinity/gui/DebugConsole.java
+++ b/src/org/infinity/gui/DebugConsole.java
@@ -28,6 +28,7 @@
import org.infinity.resource.Profile;
import org.infinity.util.Misc;
import org.infinity.util.io.FileEx;
+import org.tinylog.Logger;
public class DebugConsole extends ChildFrame implements ActionListener {
private final JButton bClearConsole = new JButton("Clear", Icons.ICON_NEW_16.getIcon());
@@ -104,7 +105,7 @@ public void actionPerformed(ActionEvent event) {
JOptionPane.INFORMATION_MESSAGE);
} catch (IOException e) {
JOptionPane.showMessageDialog(this, "Error while saving " + output, "Error", JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
}
}
} else if (event.getSource() == cbExtraInfo) {
diff --git a/src/org/infinity/gui/FontChooser.java b/src/org/infinity/gui/FontChooser.java
index c644a13fd..f497d1d73 100644
--- a/src/org/infinity/gui/FontChooser.java
+++ b/src/org/infinity/gui/FontChooser.java
@@ -49,6 +49,7 @@
import javax.swing.text.Position;
import org.infinity.util.Misc;
+import org.tinylog.Logger;
//import org.infinity.util.Misc;
@@ -61,7 +62,7 @@
* int result = fontChooser.showDialog(parent);
* if (result == FontChooser.OK_OPTION) {
* Font font = fontChooser.getSelectedFont();
- * System.out.println("Selected Font : " + font);
+ * Logger.info("Selected Font : {}", font);
* }
*
*
@@ -495,7 +496,7 @@ private void update(DocumentEvent event) {
Document doc = event.getDocument();
newValue = doc.getText(0, doc.getLength());
} catch (BadLocationException e) {
- e.printStackTrace();
+ Logger.error(e);
}
if (newValue.length() > 0) {
diff --git a/src/org/infinity/gui/InfinityAmp.java b/src/org/infinity/gui/InfinityAmp.java
index 6a627f6ae..b9aaf9311 100644
--- a/src/org/infinity/gui/InfinityAmp.java
+++ b/src/org/infinity/gui/InfinityAmp.java
@@ -40,6 +40,7 @@
import org.infinity.util.Misc;
import org.infinity.util.SimpleListModel;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
public final class InfinityAmp extends ChildFrame
implements ActionListener, ListSelectionListener, Runnable, Closeable {
@@ -284,7 +285,7 @@ private void playMus(ResourceEntry musEntry) {
} catch (Exception e) {
JOptionPane.showMessageDialog(this, "Error accessing " + musEntry + '\n' + e.getMessage(), "Error",
JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/gui/InfinityTextArea.java b/src/org/infinity/gui/InfinityTextArea.java
index 30df0a300..6a798c63d 100644
--- a/src/org/infinity/gui/InfinityTextArea.java
+++ b/src/org/infinity/gui/InfinityTextArea.java
@@ -44,6 +44,7 @@
import org.infinity.resource.text.modes.TLKTokenMaker;
import org.infinity.resource.text.modes.WeiDULogTokenMaker;
import org.infinity.util.Misc;
+import org.tinylog.Logger;
/**
* Extends {@link RSyntaxTextArea} by NearInfinity-specific features.
@@ -402,7 +403,7 @@ public static void applyExtendedSettings(RSyntaxTextArea edit, Language language
} catch (NullPointerException e) {
// ignore
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
diff --git a/src/org/infinity/gui/LinkButton.java b/src/org/infinity/gui/LinkButton.java
index b2b554e2c..a6028c34e 100644
--- a/src/org/infinity/gui/LinkButton.java
+++ b/src/org/infinity/gui/LinkButton.java
@@ -22,6 +22,7 @@
import org.infinity.resource.ResourceFactory;
import org.infinity.resource.key.ResourceEntry;
import org.infinity.updater.Utils;
+import org.tinylog.Logger;
/**
* A JLabel-based control which supports either internal game resources or external URLs.
@@ -214,7 +215,7 @@ public void actionPerformed(ActionEvent e) {
try {
Utils.openWebPage(new URL(getUrl()));
} catch (Exception ex) {
- ex.printStackTrace();
+ Logger.error(ex);
JOptionPane.showMessageDialog(((LinkButton) e.getSource()).getTopLevelAncestor(),
"Error opening link in browser.", "Error", JOptionPane.ERROR_MESSAGE);
}
diff --git a/src/org/infinity/gui/OpenFileFrame.java b/src/org/infinity/gui/OpenFileFrame.java
index d794d8dbf..3d34b91b2 100644
--- a/src/org/infinity/gui/OpenFileFrame.java
+++ b/src/org/infinity/gui/OpenFileFrame.java
@@ -48,6 +48,7 @@
import org.infinity.resource.key.ResourceEntry;
import org.infinity.util.io.FileEx;
import org.infinity.util.io.FileManager;
+import org.tinylog.Logger;
public final class OpenFileFrame extends ChildFrame implements ActionListener {
private static final JFileChooser FC = new JFileChooser(".");
@@ -275,7 +276,7 @@ public void drop(DropTargetDropEvent event) {
event.acceptDrop(DnDConstants.ACTION_COPY);
files = (List) event.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
event.dropComplete(false);
return;
}
diff --git a/src/org/infinity/gui/PreferencesDialog.java b/src/org/infinity/gui/PreferencesDialog.java
index a11c3ddc9..8c024b7c9 100644
--- a/src/org/infinity/gui/PreferencesDialog.java
+++ b/src/org/infinity/gui/PreferencesDialog.java
@@ -89,6 +89,7 @@
import org.infinity.icon.Icons;
import org.infinity.resource.Profile;
import org.infinity.util.Misc;
+import org.tinylog.Logger;
/**
* This modal dialog provides access to application-wide options and preferences
@@ -1380,7 +1381,7 @@ private void globalFontSizeOnAccept(OptionGroupBox gb) {
gb.getOption().setValue(-size);
}
} catch (IndexOutOfBoundsException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
@@ -1431,7 +1432,7 @@ private boolean globalFontSizeOnSelect(OptionGroupBox gb) {
return true;
} catch (IndexOutOfBoundsException e) {
- e.printStackTrace();
+ Logger.error(e);
}
return true;
@@ -1463,7 +1464,7 @@ private void lookAndFeelClassOnInit(OptionGroupBox gb) {
label = ((LookAndFeel) o).getName();
}
} catch (Exception e) {
-// e.printStackTrace();
+// Logger.error(e);
}
if (label == null) {
@@ -1484,7 +1485,7 @@ private void lookAndFeelClassOnInit(OptionGroupBox gb) {
// need to track item index separately in case that a L&F class is not accessible
curIdx++;
} catch (Exception e) {
-// e.printStackTrace();
+// Logger.error(e);
}
}
@@ -1504,7 +1505,7 @@ private void lookAndFeelClassOnAccept(OptionGroupBox gb) {
final DataItem item = (DataItem) gb.getItem(gb.getSelectedIndex());
gb.getOption().setValue(item.getData().getClassName());
} catch (IndexOutOfBoundsException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
@@ -1557,7 +1558,7 @@ private void textFontOnAccept(OptionGroupBox gb) {
}
gb.getOption().setValue(Integer.valueOf(index));
} catch (IndexOutOfBoundsException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
@@ -1583,7 +1584,7 @@ private boolean textFontOnSelect(OptionGroupBox gb) {
}
}
} catch (IndexOutOfBoundsException e) {
- e.printStackTrace();
+ Logger.error(e);
}
return true;
@@ -1642,7 +1643,7 @@ private void tlkCharsetTypeOnAccept(OptionGroupBox gb) {
gb.getOption().setValue(item.getData());
}
} catch (IndexOutOfBoundsException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
@@ -1704,7 +1705,7 @@ private void gameLanguagesOnAccept(OptionGroupBox gb) {
languageDefinitions = OptionsMenuItem.updateGameLanguages(languageDefinitions, Profile.getGame(), langCode);
gb.getOption().setValue(languageDefinitions);
} catch (IndexOutOfBoundsException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
@@ -1768,7 +1769,7 @@ private void uiScaleFactorOnAccept(OptionGroupBox gb) {
final DataItem item = (DataItem) gb.getItem(gb.getSelectedIndex());
gb.getOption().setValue(item.getData());
} catch (IndexOutOfBoundsException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
@@ -1819,7 +1820,7 @@ private boolean uiScaleFactorOnSelect(OptionGroupBox gb) {
return true;
} catch (IndexOutOfBoundsException e) {
- e.printStackTrace();
+ Logger.error(e);
}
return false;
}
diff --git a/src/org/infinity/gui/ResourceTree.java b/src/org/infinity/gui/ResourceTree.java
index 5049c8d32..882774d34 100644
--- a/src/org/infinity/gui/ResourceTree.java
+++ b/src/org/infinity/gui/ResourceTree.java
@@ -72,6 +72,7 @@
import org.infinity.util.io.FileEx;
import org.infinity.util.io.FileManager;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
public final class ResourceTree extends JPanel implements TreeSelectionListener, ActionListener {
private final JButton bnext = new JButton("Forward", Icons.ICON_FORWARD_16.getIcon());
@@ -302,7 +303,7 @@ public static void renameResource(FileResourceEntry entry) {
} catch (IOException e) {
JOptionPane.showMessageDialog(NearInfinity.getInstance(), "Error renaming file \"" + filename + "\"!", "Error",
JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
return;
}
// ResourceFactory.getResourceTreeModel().resourceEntryChanged(entry);
@@ -323,7 +324,7 @@ public static void deleteResource(ResourceEntry entry) {
try {
Files.delete(bakFile);
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
try {
@@ -331,7 +332,7 @@ public static void deleteResource(ResourceEntry entry) {
} catch (IOException e) {
JOptionPane.showMessageDialog(NearInfinity.getInstance(),
"Error deleting file \"" + entry.getResourceName() + "\"!", "Error", JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
}
} else if (entry instanceof BIFFResourceEntry) {
String options[] = { "Delete", "Cancel" };
@@ -346,7 +347,7 @@ public static void deleteResource(ResourceEntry entry) {
try {
Files.delete(bakFile);
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
try {
@@ -354,7 +355,7 @@ public static void deleteResource(ResourceEntry entry) {
} catch (IOException e) {
JOptionPane.showMessageDialog(NearInfinity.getInstance(),
"Error deleting file \"" + entry.getResourceName() + "\"!", "Error", JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
}
}
}
@@ -385,7 +386,7 @@ public static void restoreResource(ResourceEntry entry) {
try {
Files.delete(tmpFile);
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
JOptionPane.showMessageDialog(NearInfinity.getInstance(), "Backup has been restored successfully.",
"Restore backup", JOptionPane.INFORMATION_MESSAGE);
@@ -401,11 +402,11 @@ public static void restoreResource(ResourceEntry entry) {
+ String.format("Please manually rename the file \"%s\" into \"%s\", located in \n + \"%s\"",
tmpName, curName, path),
"Critical Error", JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
return;
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
JOptionPane.showMessageDialog(NearInfinity.getInstance(),
@@ -420,7 +421,7 @@ public static void restoreResource(ResourceEntry entry) {
} catch (IOException e) {
JOptionPane.showMessageDialog(NearInfinity.getInstance(),
"Error removing file \"" + entry + "\" from override folder!", "Error", JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
}
}
}
@@ -442,7 +443,7 @@ public static void createZipFile(Path path) {
JOptionPane.showMessageDialog(NearInfinity.getInstance(), "Zip file created.", "Information",
JOptionPane.INFORMATION_MESSAGE);
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
wb.setBlocked(false);
JOptionPane.showMessageDialog(NearInfinity.getInstance(), "Error while creating zip file.", "Error",
JOptionPane.ERROR_MESSAGE);
@@ -727,7 +728,7 @@ public void actionPerformed(ActionEvent event) {
new ViewFrame(NearInfinity.getInstance(), res);
}
} catch (NullPointerException e) {
- System.err.println("Does not exist in BIFF: " + node);
+ Logger.warn("Does not exist in BIFF: {}", node);
JOptionPane.showMessageDialog(NearInfinity.getInstance(),
"Does not exist in BIFF: " + node, "Error", JOptionPane.ERROR_MESSAGE);
}
diff --git a/src/org/infinity/gui/SortableTable.java b/src/org/infinity/gui/SortableTable.java
index b1be0ec35..268626bbb 100644
--- a/src/org/infinity/gui/SortableTable.java
+++ b/src/org/infinity/gui/SortableTable.java
@@ -36,6 +36,7 @@
import org.infinity.resource.Profile;
import org.infinity.util.ArrayUtil;
import org.infinity.util.io.FileEx;
+import org.tinylog.Logger;
public final class SortableTable extends JTable implements MouseListener {
private static final String WITH_DELIMITERS = "(?<=%1$s)(?!%1$s)|(? FILTER_INFO_LIST = new ArrayList<>();
@@ -99,7 +101,7 @@ public static BamFilterBase createInstance(ConvertToBam parent, Class extends
try {
return filterClass.getConstructor(ConvertToBam.class).newInstance(parent);
} catch (Throwable t) {
- t.printStackTrace();
+ Logger.error(t);
}
}
return null;
diff --git a/src/org/infinity/gui/converter/BamFilterOutputDefault.java b/src/org/infinity/gui/converter/BamFilterOutputDefault.java
index 4c0823db1..da5c69bc7 100644
--- a/src/org/infinity/gui/converter/BamFilterOutputDefault.java
+++ b/src/org/infinity/gui/converter/BamFilterOutputDefault.java
@@ -17,6 +17,7 @@
import org.infinity.resource.graphics.DxtEncoder;
import org.infinity.resource.graphics.PseudoBamDecoder;
import org.infinity.resource.graphics.PseudoBamDecoder.PseudoBamFrameEntry;
+import org.tinylog.Logger;
/**
* The default BAM output filter.
@@ -88,7 +89,7 @@ private boolean applyEffect(PseudoBamDecoder decoder) throws Exception {
return decoder.exportBamV1(outFile, getConverter().getProgressMonitor(),
getConverter().getProgressMonitorStage());
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
throw e;
}
} else {
@@ -99,7 +100,7 @@ private boolean applyEffect(PseudoBamDecoder decoder) throws Exception {
return decoder.exportBamV2(outFile, dxtType, pvrzIndex, getConverter().getProgressMonitor(),
getConverter().getProgressMonitorStage());
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
throw e;
}
}
diff --git a/src/org/infinity/gui/converter/BamFilterOutputImage.java b/src/org/infinity/gui/converter/BamFilterOutputImage.java
index 655f5c2fc..29fb9bafa 100644
--- a/src/org/infinity/gui/converter/BamFilterOutputImage.java
+++ b/src/org/infinity/gui/converter/BamFilterOutputImage.java
@@ -32,6 +32,7 @@
import org.infinity.resource.graphics.PseudoBamDecoder;
import org.infinity.resource.graphics.PseudoBamDecoder.PseudoBamFrameEntry;
import org.infinity.util.Misc;
+import org.tinylog.Logger;
/**
* Output filter: Exports each frame as separate image.
@@ -245,7 +246,7 @@ private boolean applyEffect(PseudoBamDecoder decoder) throws Exception {
throw new IOException();
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
throw new Exception("Could not export frame " + frameIdx);
}
image.flush();
diff --git a/src/org/infinity/gui/converter/BamFilterOutputSplitted.java b/src/org/infinity/gui/converter/BamFilterOutputSplitted.java
index 8782a64ed..70f463e61 100644
--- a/src/org/infinity/gui/converter/BamFilterOutputSplitted.java
+++ b/src/org/infinity/gui/converter/BamFilterOutputSplitted.java
@@ -35,6 +35,7 @@
import org.infinity.resource.graphics.PseudoBamDecoder.PseudoBamFrameEntry;
import org.infinity.util.Misc;
import org.infinity.util.io.FileManager;
+import org.tinylog.Logger;
/**
* Output filter: split BAM and output each part into a separate file.
@@ -472,7 +473,7 @@ private boolean convertBam(Path outFileName, PseudoBamDecoder decoder) throws Ex
return decoder.exportBamV1(outFileName, getConverter().getProgressMonitor(),
getConverter().getProgressMonitorStage());
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
throw e;
}
} else {
@@ -483,7 +484,7 @@ private boolean convertBam(Path outFileName, PseudoBamDecoder decoder) throws Ex
return decoder.exportBamV2(outFileName, dxtType, pvrzIndex, getConverter().getProgressMonitor(),
getConverter().getProgressMonitorStage());
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
throw e;
}
}
diff --git a/src/org/infinity/gui/converter/BamOptionsDialog.java b/src/org/infinity/gui/converter/BamOptionsDialog.java
index fc6182169..4ec5c6c35 100644
--- a/src/org/infinity/gui/converter/BamOptionsDialog.java
+++ b/src/org/infinity/gui/converter/BamOptionsDialog.java
@@ -46,6 +46,7 @@
import org.infinity.resource.graphics.ColorConvert;
import org.infinity.util.io.FileEx;
import org.infinity.util.io.FileManager;
+import org.tinylog.Logger;
/**
* An options dialog for the BAM converter.
@@ -264,7 +265,7 @@ public static void updateRecentSession(Path session) {
}
recentSessions.add(0, session);
} catch (IOError e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/gui/converter/ConvertToBam.java b/src/org/infinity/gui/converter/ConvertToBam.java
index c5514648f..abaa2c857 100644
--- a/src/org/infinity/gui/converter/ConvertToBam.java
+++ b/src/org/infinity/gui/converter/ConvertToBam.java
@@ -127,6 +127,7 @@
import org.infinity.util.io.FileManager;
import org.infinity.util.io.StreamUtils;
import org.infinity.util.tuples.Couple;
+import org.tinylog.Logger;
public class ConvertToBam extends ChildFrame implements ActionListener, PropertyChangeListener, FocusListener,
ChangeListener, ListSelectionListener, MouseListener, KeyListener {
@@ -793,7 +794,7 @@ public void propertyChange(PropertyChangeEvent event) {
try {
result = workerConvert.get();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
workerConvert = null;
@@ -2694,7 +2695,7 @@ private boolean framesAddImage(int listIndex, ResourceEntry entry, int frameInde
}
} catch (Exception e) {
retVal = false;
- e.printStackTrace();
+ Logger.error(e);
}
}
return retVal;
@@ -2803,7 +2804,7 @@ public void framesAddFolder(Path path, int insertIndex) {
}
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
return;
}
@@ -3425,7 +3426,7 @@ private void previewPrepare(boolean update) {
try {
updateFilteredBamDecoder(getBamVersion(), false);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
@@ -3933,7 +3934,7 @@ private List convert() {
}
result.add("Conversion finished successfully.");
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
result.add(null);
result.add(String.format("Error while exporting BAM files.\n(%s)", e.getMessage()));
}
@@ -4009,7 +4010,7 @@ private void updateFilteredBamDecoder(int bamVersion, boolean force) throws Exce
}
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
throw e;
}
} else if (filter instanceof BamFilterBaseTransform) {
@@ -4028,16 +4029,16 @@ private void updateFilteredBamDecoder(int bamVersion, boolean force) throws Exce
}
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
throw e;
}
} else if (filter instanceof BamFilterBaseOutput) {
// skipping output filter
} else {
if (filter != null) {
- System.err.println(String.format("Skipping unrecognized filter: %s", filter));
+ Logger.warn("Skipping unrecognized filter: {}", filter);
} else {
- System.err.println("Skipping null filter");
+ Logger.warn("Skipping null filter");
}
}
}
@@ -5657,7 +5658,7 @@ private boolean saveData(Path outFile, boolean silent) {
}
retVal = true;
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
if (!silent) {
JOptionPane.showMessageDialog(bam, "Error exporting BAM session.", "Error", JOptionPane.ERROR_MESSAGE);
}
diff --git a/src/org/infinity/gui/converter/ConvertToBmp.java b/src/org/infinity/gui/converter/ConvertToBmp.java
index 20a24a3a1..c755768b0 100644
--- a/src/org/infinity/gui/converter/ConvertToBmp.java
+++ b/src/org/infinity/gui/converter/ConvertToBmp.java
@@ -58,6 +58,7 @@
import org.infinity.util.io.FileEx;
import org.infinity.util.io.FileManager;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
public class ConvertToBmp extends ChildFrame implements ActionListener, FocusListener, PropertyChangeListener {
private static Path currentPath = Profile.getGameRoot();
@@ -221,7 +222,7 @@ public void propertyChange(PropertyChangeEvent event) {
try {
sl = workerConvert.get();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
workerConvert = null;
@@ -522,7 +523,7 @@ private void inputAddFolder() {
} catch (IOException e) {
JOptionPane.showMessageDialog(this, "Unable to read files from the specified folder.", "Error",
JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
return;
}
listInputFiles.setSelectedIndex(idx - 1);
@@ -768,7 +769,7 @@ private boolean writeBMP(Image srcImage, Path file, boolean hasAlpha) {
}
return true;
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
return false;
diff --git a/src/org/infinity/gui/converter/ConvertToMos.java b/src/org/infinity/gui/converter/ConvertToMos.java
index 98c562bcf..03ceaefa1 100644
--- a/src/org/infinity/gui/converter/ConvertToMos.java
+++ b/src/org/infinity/gui/converter/ConvertToMos.java
@@ -63,6 +63,7 @@
import org.infinity.util.io.FileEx;
import org.infinity.util.io.FileManager;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
public class ConvertToMos extends ChildFrame
implements ActionListener, PropertyChangeListener, ChangeListener, FocusListener {
@@ -241,7 +242,7 @@ public static boolean convertV1(Component parent, BufferedImage img, String mosF
try (OutputStream os = StreamUtils.getOutputStream(mosFile, true)) {
os.write(dst);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
result.add(null);
result.add("Error writing TIS file to disk.");
return false;
@@ -386,7 +387,7 @@ public static boolean convertV2(Component parent, BufferedImage img, String mosF
try (OutputStream os = StreamUtils.getOutputStream(mosFile, true)) {
os.write(dst);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
result.add(null);
result.add("Error writing MOS file to disk.");
return false;
@@ -496,14 +497,14 @@ private static boolean createPvrzPages(Path path, BufferedImage img, DxtEncoder.
try (OutputStream os = StreamUtils.getOutputStream(pvrzFile, true)) {
os.write(pvrz);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
result.add(null);
result.add(String.format("Error writing PVRZ file \"%s\" to disk.", pvrzFile));
return false;
}
pvrz = null;
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
result.add(null);
result.add(String.format("Error while generating PVRZ files:\n%s", e.getMessage()));
return false;
@@ -614,7 +615,7 @@ public void propertyChange(PropertyChangeEvent event) {
try {
sl = workerConvert.get();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
workerConvert = null;
diff --git a/src/org/infinity/gui/converter/ConvertToPvrz.java b/src/org/infinity/gui/converter/ConvertToPvrz.java
index e8bb6210e..26c12a0dd 100644
--- a/src/org/infinity/gui/converter/ConvertToPvrz.java
+++ b/src/org/infinity/gui/converter/ConvertToPvrz.java
@@ -59,6 +59,7 @@
import org.infinity.util.io.FileEx;
import org.infinity.util.io.FileManager;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
public class ConvertToPvrz extends ChildFrame implements ActionListener, PropertyChangeListener {
private static String currentDir = Profile.getGameRoot().toString();
@@ -276,7 +277,7 @@ public void propertyChange(PropertyChangeEvent event) {
try {
sl = workerConvert.get();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
workerConvert = null;
@@ -613,7 +614,7 @@ private List convert() {
} catch (IOException e) {
bb = null;
errors++;
- e.printStackTrace();
+ Logger.error(e);
}
if (bb != null) {
byte[] buffer = bb.array();
@@ -622,7 +623,7 @@ private List convert() {
os.write(output);
} catch (Exception e) {
errors++;
- e.printStackTrace();
+ Logger.error(e);
}
}
} else if (isGraphics) {
@@ -744,7 +745,7 @@ private List convert() {
os.write(pvrz);
} catch (Exception e) {
errors++;
- e.printStackTrace();
+ Logger.error(e);
}
// cleaning up
diff --git a/src/org/infinity/gui/converter/ConvertToTis.java b/src/org/infinity/gui/converter/ConvertToTis.java
index 49f75dd93..5e87f990e 100644
--- a/src/org/infinity/gui/converter/ConvertToTis.java
+++ b/src/org/infinity/gui/converter/ConvertToTis.java
@@ -65,6 +65,7 @@
import org.infinity.util.io.FileEx;
import org.infinity.util.io.FileManager;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
public class ConvertToTis extends ChildFrame
implements ActionListener, PropertyChangeListener, ChangeListener, FocusListener, KeyListener {
@@ -229,7 +230,7 @@ public static boolean convertV1(Component parent, BufferedImage img, String tisF
os.write(dst);
} catch (Exception e) {
// error handling
- e.printStackTrace();
+ Logger.error(e);
result.add(null);
result.add("Error writing TIS file to disk.");
return false;
@@ -384,7 +385,7 @@ public static boolean convertV2(Component parent, BufferedImage img, String tisF
os.write(dst);
} catch (Exception e) {
// error handling
- e.printStackTrace();
+ Logger.error(e);
result.add(null);
result.add("Error writing TIS file to disk.");
return false;
@@ -538,14 +539,14 @@ public static boolean createPvrzPages(String tisFileName, BufferedImage srcImg,
os.write(pvrz);
} catch (Exception e) {
// critical error
- e.printStackTrace();
+ Logger.error(e);
result.add(null);
result.add(String.format("Error writing PVRZ file \"%s\" to disk.", pvrzName));
return false;
}
pvrz = null;
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
result.add(null);
result.add(String.format("Error while generating PVRZ files:\n%s", e.getMessage()));
return false;
@@ -700,7 +701,7 @@ public void propertyChange(PropertyChangeEvent event) {
try {
sl = workerConvert.get();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
workerConvert = null;
diff --git a/src/org/infinity/gui/hexview/ResourceDataProvider.java b/src/org/infinity/gui/hexview/ResourceDataProvider.java
index c460c21d9..7b896d1e7 100644
--- a/src/org/infinity/gui/hexview/ResourceDataProvider.java
+++ b/src/org/infinity/gui/hexview/ResourceDataProvider.java
@@ -9,6 +9,7 @@
import java.util.HashMap;
import org.infinity.resource.key.ResourceEntry;
+import org.tinylog.Logger;
import tv.porst.jhexview.DataChangedEvent;
import tv.porst.jhexview.IDataChangedListener;
@@ -60,7 +61,7 @@ public byte[] getData(long offset, int length) {
}
return retVal;
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
return null;
@@ -76,7 +77,7 @@ public int getDataLength() {
size = (int) resSize;
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
return size;
diff --git a/src/org/infinity/gui/hexview/StructHexViewer.java b/src/org/infinity/gui/hexview/StructHexViewer.java
index 30b35911b..3d666887f 100644
--- a/src/org/infinity/gui/hexview/StructHexViewer.java
+++ b/src/org/infinity/gui/hexview/StructHexViewer.java
@@ -77,6 +77,7 @@
import org.infinity.util.io.FileEx;
import org.infinity.util.io.FileManager;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
import tv.porst.jhexview.DataChangedEvent;
import tv.porst.jhexview.HexViewEvent;
@@ -487,7 +488,7 @@ private boolean saveResource(Path outFile) {
} catch (IOException e) {
JOptionPane.showMessageDialog(this, "Unable to create override folder.", "Error",
JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
return false;
}
}
@@ -513,7 +514,7 @@ private boolean saveResource(Path outFile) {
Files.move(outPath, bakPath);
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
} else {
@@ -538,7 +539,7 @@ private boolean saveResource(Path outFile) {
} catch (IOException e) {
JOptionPane.showMessageDialog(this, "Error while saving " + getStruct().getResourceEntry().toString(), "Error",
JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
return false;
}
return true;
diff --git a/src/org/infinity/gui/hexview/StructuredDataProvider.java b/src/org/infinity/gui/hexview/StructuredDataProvider.java
index 15ae9405b..d883ff4f1 100644
--- a/src/org/infinity/gui/hexview/StructuredDataProvider.java
+++ b/src/org/infinity/gui/hexview/StructuredDataProvider.java
@@ -15,6 +15,7 @@
import org.infinity.resource.AbstractStruct;
import org.infinity.resource.StructEntry;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
import tv.porst.jhexview.DataChangedEvent;
import tv.porst.jhexview.IDataChangedListener;
@@ -97,7 +98,7 @@ public byte[] getData(long offset, int length) {
try {
entry.write(os);
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
curOfs += entry.getSize();
}
@@ -106,7 +107,7 @@ public byte[] getData(long offset, int length) {
try {
System.arraycopy(os.toByteArray(), (int) offset - startOffset, retVal, 0, length);
} catch (ArrayIndexOutOfBoundsException e) {
- e.printStackTrace();
+ Logger.error(e);
}
return retVal;
@@ -193,7 +194,7 @@ public void setData(long offset, byte[] data) {
hasChanged = true;
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/gui/menu/FileMenu.java b/src/org/infinity/gui/menu/FileMenu.java
index 5b7403984..1c530391c 100644
--- a/src/org/infinity/gui/menu/FileMenu.java
+++ b/src/org/infinity/gui/menu/FileMenu.java
@@ -26,6 +26,7 @@
import org.infinity.resource.key.BIFFResourceEntry;
import org.infinity.resource.key.FileResourceEntry;
import org.infinity.resource.key.ResourceEntry;
+import org.tinylog.Logger;
/**
* Handles File menu items for the {@link BrowserMenuBar}.
@@ -182,7 +183,7 @@ public void actionPerformed(ActionEvent event) {
new ViewFrame(NearInfinity.getInstance(), res);
}
} catch (NullPointerException e) {
- System.err.println("Does not exist in BIFF: " + node);
+ Logger.warn("Does not exist in BIFF: {}", node);
JOptionPane.showMessageDialog(NearInfinity.getInstance(),
"Does not exist in BIFF: " + node, "Error", JOptionPane.ERROR_MESSAGE);
}
diff --git a/src/org/infinity/gui/menu/GameMenu.java b/src/org/infinity/gui/menu/GameMenu.java
index e947437ae..48e24d549 100644
--- a/src/org/infinity/gui/menu/GameMenu.java
+++ b/src/org/infinity/gui/menu/GameMenu.java
@@ -34,6 +34,7 @@
import org.infinity.util.io.FileEx;
import org.infinity.util.io.FileManager;
import org.infinity.util.tuples.Couple;
+import org.tinylog.Logger;
/**
* Handles Game menu items for the {@link BrowserMenuBar}.
@@ -316,7 +317,7 @@ public void actionPerformed(ActionEvent event) {
try {
isEqual = keyFile.equals(Profile.getChitinKey().toAbsolutePath());
} catch (IOError e) {
- e.printStackTrace();
+ Logger.error(e);
}
if (!isEqual) {
int confirm = JOptionPane.YES_OPTION;
diff --git a/src/org/infinity/gui/menu/HelpMenu.java b/src/org/infinity/gui/menu/HelpMenu.java
index 548e37f9f..2fb32f6d9 100644
--- a/src/org/infinity/gui/menu/HelpMenu.java
+++ b/src/org/infinity/gui/menu/HelpMenu.java
@@ -45,6 +45,7 @@
import org.infinity.util.DataString;
import org.infinity.util.Misc;
import org.infinity.util.tuples.Couple;
+import org.tinylog.Logger;
/**
* Handles Help menu items for the {@link BrowserMenuBar}.
@@ -65,6 +66,7 @@ public class HelpMenu extends JMenu implements BrowserSubMenu, ActionListener {
private final JMenuItem helpApngWriterLicense;
private final JMenuItem helpCommonMarkLicense;
private final JMenuItem helpFlatLafLicense;
+ private final JMenuItem helpTinyLogLicense;
private final JMenuItem helpOracleLicense;
private final JMenuItem helpUpdateSettings;
private final JMenuItem helpUpdateCheck;
@@ -118,6 +120,9 @@ public HelpMenu(BrowserMenuBar parent) {
helpOracleLicense = BrowserMenuBar.makeMenuItem("Oracle License", KeyEvent.VK_O, Icons.ICON_EDIT_16.getIcon(), -1, this);
miscLicenses.add(helpOracleLicense);
+ helpTinyLogLicense = BrowserMenuBar.makeMenuItem("tinylog License", KeyEvent.VK_T, Icons.ICON_EDIT_16.getIcon(), -1, this);
+ miscLicenses.add(helpTinyLogLicense);
+
addSeparator();
helpUpdateSettings = BrowserMenuBar.makeMenuItem("Update settings...", KeyEvent.VK_S, null, -1, this);
@@ -187,6 +192,8 @@ public void actionPerformed(ActionEvent event) {
displayLicense("org/infinity/commonmark.License.txt", "BSD License");
} else if (event.getSource() == helpOracleLicense) {
displayLicense("org/infinity/Oracle.License.txt", "BSD License");
+ } else if (event.getSource() == helpTinyLogLicense) {
+ displayLicense("org/infinity/tinylog.License.txt", "Apache License");
} else if (event.getSource() == helpUpdateSettings) {
UpdaterSettings.showDialog(NearInfinity.getInstance());
} else if (event.getSource() == helpUpdateCheck) {
@@ -204,7 +211,7 @@ public void actionPerformed(ActionEvent event) {
info = null;
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
JOptionPane.showMessageDialog(NearInfinity.getInstance(), "Check for updates: " + e.getMessage(), "Error",
JOptionPane.ERROR_MESSAGE);
return;
@@ -257,6 +264,7 @@ private void displayAbout() {
add("JHexView by Sebastian Porst - GNU General Public License.");
add("CommonMark-Java (\u00A9) Atlassian Pty. Ltd. - BSD License.");
add("FlatLaf (\u00A9) FormDev Software GmbH - Apache License.");
+ add("tinylog 2 by Martin Winandy - Apache License.");
add("APNG Writer by Weoulren - BSD License.");
}
};
@@ -434,7 +442,7 @@ private void displayLicense(String classPath, String title) {
try {
tphelp.setPage(ClassLoader.getSystemResource(classPath));
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
JOptionPane.showMessageDialog(NearInfinity.getInstance(), panel, title, JOptionPane.PLAIN_MESSAGE);
diff --git a/src/org/infinity/gui/menu/OptionsMenuItem.java b/src/org/infinity/gui/menu/OptionsMenuItem.java
index 3636c7079..b7b84ec8a 100644
--- a/src/org/infinity/gui/menu/OptionsMenuItem.java
+++ b/src/org/infinity/gui/menu/OptionsMenuItem.java
@@ -51,6 +51,7 @@
import org.infinity.util.Misc;
import org.infinity.util.StringTable;
import org.infinity.util.tuples.Couple;
+import org.tinylog.Logger;
/**
* Handles Option menu items for the {@link BrowserMenuBar}.
@@ -966,7 +967,7 @@ private void applyChanges(Collection options) {
refresh = true;
restart = true;
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
} else if (option.equals(AppOption.TEXT_FONT)) {
int idx = option.getIntValue();
diff --git a/src/org/infinity/gui/menu/ToolsMenu.java b/src/org/infinity/gui/menu/ToolsMenu.java
index 9765632c9..17dda2f39 100644
--- a/src/org/infinity/gui/menu/ToolsMenu.java
+++ b/src/org/infinity/gui/menu/ToolsMenu.java
@@ -282,7 +282,7 @@ public ToolsMenu(BrowserMenuBar parent) {
// } catch (IOException e) {
// JOptionPane.showMessageDialog(NearInfinity.getInstance(), "Error writing keyfile", "Error",
// JOptionPane.ERROR_MESSAGE);
-// e.printStackTrace();
+// Logger.error(e);
// }
// }
// }
diff --git a/src/org/infinity/icon/Icons.java b/src/org/infinity/icon/Icons.java
index 29d952ead..760a6e845 100644
--- a/src/org/infinity/icon/Icons.java
+++ b/src/org/infinity/icon/Icons.java
@@ -11,6 +11,8 @@
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
+import org.tinylog.Logger;
+
/**
* Provides {@code ImageIcon} instances of selected graphics files.
*/
@@ -137,7 +139,7 @@ public static ImageIcon getIcon(Class> cls, String fileName) {
retVal = new ImageIcon(image);
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
return retVal;
@@ -167,7 +169,7 @@ public static Image getImage(Class> cls, String fileName) {
retVal = ImageIO.read(is);
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
return retVal;
diff --git a/src/org/infinity/resource/AbstractStruct.java b/src/org/infinity/resource/AbstractStruct.java
index 920119d94..c23c9cc11 100644
--- a/src/org/infinity/resource/AbstractStruct.java
+++ b/src/org/infinity/resource/AbstractStruct.java
@@ -44,6 +44,7 @@
import org.infinity.search.ReferenceSearcher;
import org.infinity.util.io.ByteBufferOutputStream;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
public abstract class AbstractStruct extends AbstractTableModel
implements StructEntry, Viewable, Closeable, Referenceable, PropertyChangeListener {
@@ -296,7 +297,7 @@ public ByteBuffer getDataBuffer() {
try (ByteBufferOutputStream bbos = new ByteBufferOutputStream(bb)) {
writeFlatFields(bbos);
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
bb.position(0);
return bb;
@@ -1221,7 +1222,7 @@ private void fixHoles(ByteBuffer buffer) {
Unknown hole = new Unknown(buffer, offset, delta, COMMON_UNUSED_BYTES);
fields.add(hole);
flatList.add(i, hole);
- System.out.println("Hole: " + name + " off: " + Integer.toHexString(offset) + "h len: " + delta);
+ Logger.warn("Hole: {} off: {} h len: {}", name, Integer.toHexString(offset), delta);
i++;
}
// Using max() as shared data regions may confuse the hole detection algorithm
@@ -1229,8 +1230,7 @@ private void fixHoles(ByteBuffer buffer) {
}
if (endoffset < buffer.limit()) { // Does this break anything?
fields.add(new Unknown(buffer, endoffset, buffer.limit() - endoffset, COMMON_UNUSED_BYTES));
- System.out.println(
- "Hole: " + name + " off: " + Integer.toHexString(endoffset) + "h len: " + (buffer.limit() - endoffset));
+ Logger.warn("Hole: {} off: {} h len: {}", name, Integer.toHexString(endoffset), (buffer.limit() - endoffset));
endoffset = buffer.limit();
}
}
diff --git a/src/org/infinity/resource/Profile.java b/src/org/infinity/resource/Profile.java
index 5a427bfd0..d98c45800 100644
--- a/src/org/infinity/resource/Profile.java
+++ b/src/org/infinity/resource/Profile.java
@@ -50,12 +50,14 @@
import org.infinity.resource.key.ResourceEntry;
import org.infinity.resource.key.ResourceTreeModel;
import org.infinity.util.DataString;
+import org.infinity.util.DebugTimer;
import org.infinity.util.Platform;
import org.infinity.util.Table2da;
import org.infinity.util.Table2daCache;
import org.infinity.util.io.DlcManager;
import org.infinity.util.io.FileEx;
import org.infinity.util.io.FileManager;
+import org.tinylog.Logger;
/**
* Provides engine- and game-specific properties of the currently opened Infinity Engine game.
@@ -640,7 +642,7 @@ public static Game gameFromString(String gameName) {
try {
return Enum.valueOf(Game.class, gameName);
} catch (IllegalArgumentException e) {
- System.err.println("Unknown game type \"" + gameName + "\" specified. Falling back to \"Unknown\".");
+ Logger.warn("Unknown game type \"{}\" specified. Falling back to \"Unknown\".", gameName);
}
}
return Game.Unknown;
@@ -678,10 +680,12 @@ public static boolean openGame(Path keyFile, String desc) {
public static boolean openGame(Path keyFile, String desc, Game forcedGame) {
try {
closeGame();
+ final DebugTimer timer = new DebugTimer();
instance = new Profile(keyFile, desc, forcedGame);
+ Logger.info(timer.getTimerFormatted("Initializing game resources"));
return true;
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
closeGame();
return false;
@@ -1709,7 +1713,7 @@ private static String getLuaValue(Path file, String key, String defaultValue, bo
}
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
return retVal;
@@ -2572,11 +2576,11 @@ private List initDlc(Path rootDir, Path homeDir) {
list.add(dlcRoot);
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
// DLCs of the same root are sorted alphabetically (in reverse order)
if (!list.isEmpty()) {
diff --git a/src/org/infinity/resource/ResourceFactory.java b/src/org/infinity/resource/ResourceFactory.java
index ba86db2d3..6c9f31fc8 100644
--- a/src/org/infinity/resource/ResourceFactory.java
+++ b/src/org/infinity/resource/ResourceFactory.java
@@ -93,6 +93,7 @@
import org.infinity.util.io.FileEx;
import org.infinity.util.io.FileManager;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* Handles game-specific resource access.
@@ -259,8 +260,7 @@ public static Resource getResource(ResourceEntry entry, String forcedExtension)
final String msg = String.format("Error reading %s @ %s - %s", entry, entry.getActualPath(), e);
NearInfinity.getInstance().getStatusBar().setMessage(msg);
}
- System.err.println("Error reading " + entry);
- e.printStackTrace();
+ Logger.error(e, "Error reading {}", entry);
}
return res;
}
@@ -314,7 +314,7 @@ public static ResourceEntry getResourceIcon(ResourceEntry entry, String forcedEx
// forward exception to caller
throw e;
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
@@ -418,7 +418,7 @@ public static Class extends Resource> detectResourceType(ResourceEntry entry)
throw new Exception(entry.getResourceName() + ": Unable to determine resource type");
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
return cls;
@@ -429,7 +429,7 @@ public static void exportResource(ResourceEntry entry, Component parent) {
try {
getInstance().exportResourceInternal(entry, parent, null);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
JOptionPane.showMessageDialog(parent, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
}
@@ -440,7 +440,7 @@ public static void exportResource(ResourceEntry entry, ByteBuffer buffer, String
try {
getInstance().exportResourceInternal(entry, buffer, filename, parent, null);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
JOptionPane.showMessageDialog(parent, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
}
@@ -766,7 +766,7 @@ public static List getAvailableGameLanguages() {
.isFile()))) {
dstream.forEach(path -> list.add(path));
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
@@ -802,7 +802,7 @@ public static String autodetectGameLanguage(Path iniFile) {
}
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
JOptionPane.showMessageDialog(NearInfinity.getInstance(),
"Error parsing " + iniFile.getFileName() + ". Using language defaults.", "Error",
JOptionPane.ERROR_MESSAGE);
@@ -838,7 +838,7 @@ static Path getHomeRoot(boolean allowMissing) {
userPrefix = splitted[splitted.length - 1];
userPath = FileManager.resolve(userPrefix, EE_DIR);
} catch (Throwable t) {
- t.printStackTrace();
+ Logger.error(t);
return null;
}
} else if (osName.contains("mac") || osName.contains("darwin")) {
@@ -908,7 +908,7 @@ static List getBIFFDirs() {
}
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
dirList.clear();
}
}
@@ -999,7 +999,7 @@ private ResourceFactory(Path keyFile) {
loadResourcesInternal();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "No Infinity Engine game found", "Error", JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
}
}
@@ -1523,7 +1523,7 @@ private void saveCopyOfResourceInternal(ResourceEntry entry) {
} catch (IOException e) {
JOptionPane.showMessageDialog(NearInfinity.getInstance(), "Could not create " + outPath + ".", "Error",
JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
return;
}
}
@@ -1547,7 +1547,7 @@ private void saveCopyOfResourceInternal(ResourceEntry entry) {
} catch (Exception e) {
JOptionPane.showMessageDialog(NearInfinity.getInstance(), "Error while copying " + entry, "Error",
JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
}
}
@@ -1586,7 +1586,7 @@ private boolean saveResourceInternal(Resource resource, Component parent, Path o
} catch (IOException e) {
JOptionPane.showMessageDialog(parent, "Unable to create override folder.", "Error",
JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
return false;
}
}
@@ -1603,7 +1603,7 @@ private boolean saveResourceInternal(Resource resource, Component parent, Path o
} catch (IOException e) {
JOptionPane.showMessageDialog(parent, "Unable to create folder: " + outPath.getParent(), "Error",
JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
return false;
}
}
@@ -1626,7 +1626,7 @@ private boolean saveResourceInternal(Resource resource, Component parent, Path o
Files.move(outPath, bakPath);
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
} else {
@@ -1638,7 +1638,7 @@ private boolean saveResourceInternal(Resource resource, Component parent, Path o
((Writeable) resource).write(os);
} catch (IOException e) {
JOptionPane.showMessageDialog(parent, "Error while saving " + entry, "Error", JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
return false;
}
diff --git a/src/org/infinity/resource/StructureFactory.java b/src/org/infinity/resource/StructureFactory.java
index 104ecc815..c6fe5f876 100644
--- a/src/org/infinity/resource/StructureFactory.java
+++ b/src/org/infinity/resource/StructureFactory.java
@@ -25,6 +25,7 @@
import org.infinity.util.io.FileEx;
import org.infinity.util.io.FileManager;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
// Create different pre-initialized IE game resources from scratch and writes them to disk.
public final class StructureFactory {
@@ -142,7 +143,7 @@ public void newResource(ResType type, Window parent) {
} catch (Exception e) {
JOptionPane.showMessageDialog(parent, "Error while creating " + outFile.getFileName(), title,
JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/resource/are/AreResource.java b/src/org/infinity/resource/are/AreResource.java
index 88144b85a..2296e3aeb 100644
--- a/src/org/infinity/resource/are/AreResource.java
+++ b/src/org/infinity/resource/are/AreResource.java
@@ -55,6 +55,7 @@
import org.infinity.util.Table2da;
import org.infinity.util.Table2daCache;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* The ARE resource describes the content of an area (rather than its visual representation). ARE files contain the list
@@ -212,7 +213,7 @@ private static void initMapNames(boolean force) {
LuaEntry entries = LuaParser.Parse(luaFiles, "cheatAreas\\w*", false);
mapNames = createMapNamesFromLua(entries);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
} else if (ResourceFactory.resourceExists("MAPNAME.2DA")) {
// PST map names
diff --git a/src/org/infinity/resource/are/viewer/AreaViewer.java b/src/org/infinity/resource/are/viewer/AreaViewer.java
index c868b2d9c..56c3d4683 100644
--- a/src/org/infinity/resource/are/viewer/AreaViewer.java
+++ b/src/org/infinity/resource/are/viewer/AreaViewer.java
@@ -117,6 +117,7 @@
import org.infinity.resource.wed.WedResource;
import org.infinity.util.io.FileManager;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* The Area Viewer shows a selected map with its associated structures, such as actors, regions or animations.
@@ -238,7 +239,7 @@ protected Void doInBackground() throws Exception {
try {
init();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
return null;
}
@@ -695,7 +696,7 @@ private void init() {
try {
initGuiSettings();
} catch (OutOfMemoryError e) {
- e.printStackTrace();
+ Logger.error(e);
JOptionPane.showMessageDialog(this, "Not enough memory to load area!", "Error", JOptionPane.ERROR_MESSAGE);
throw e;
}
@@ -2229,7 +2230,7 @@ private void exportMap() {
bRet = ImageIO.write(dstImage, "png", os);
dstImage.flush();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
} finally {
releaseProgressMonitor();
WindowBlocker.blockWindow(AreaViewer.this, false);
@@ -2402,7 +2403,7 @@ public void actionPerformed(ActionEvent event) {
try {
setZoomFactor(Settings.ITEM_ZOOM_FACTOR[cbZoomLevel.getSelectedIndex()], previousZoomFactor);
} catch (OutOfMemoryError e) {
- e.printStackTrace();
+ Logger.error(e);
cbZoomLevel.hidePopup();
WindowBlocker.blockWindow(AreaViewer.this, false);
String msg = "Not enough memory to set selected zoom level.\n"
@@ -2554,7 +2555,7 @@ public void mouseWheelMoved(MouseWheelEvent event) {
try {
setZoomFactor(zoom, previousZoomFactor);
} catch (OutOfMemoryError e) {
- e.printStackTrace();
+ Logger.error(e);
cbZoomLevel.hidePopup();
WindowBlocker.blockWindow(AreaViewer.this, false);
String msg = "Not enough memory to set selected zoom level.\n"
@@ -2918,7 +2919,7 @@ public void reloadWed(int dayNight) {
wedItem[dayNight].setVisible(false);
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
} else {
wed[dayNight] = wed[ViewerConstants.AREA_DAY];
@@ -2931,7 +2932,7 @@ public void reloadWed(int dayNight) {
try {
wed[dayNight] = new WedResource(ResourceFactory.getResourceEntry(wedNameNight));
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/resource/are/viewer/LayerActor.java b/src/org/infinity/resource/are/viewer/LayerActor.java
index 7146e8a45..c7d93a862 100644
--- a/src/org/infinity/resource/are/viewer/LayerActor.java
+++ b/src/org/infinity/resource/are/viewer/LayerActor.java
@@ -33,6 +33,7 @@
import org.infinity.util.IniMapCache;
import org.infinity.util.IniMapEntry;
import org.infinity.util.IniMapSection;
+import org.tinylog.Logger;
/**
* Manages actor layer objects.
@@ -83,7 +84,7 @@ protected void loadLayer() {
setListeners(obj);
objectList.add(obj);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
@@ -121,7 +122,7 @@ protected void loadLayer() {
setListeners(loa);
objectList.add(loa);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
@@ -191,7 +192,7 @@ public Void doInBackground() {
progress.setProgress(i + 1);
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
} finally {
progress.close();
if (blocker != null) {
diff --git a/src/org/infinity/resource/are/viewer/LayerAutomap.java b/src/org/infinity/resource/are/viewer/LayerAutomap.java
index 606883668..e23273812 100644
--- a/src/org/infinity/resource/are/viewer/LayerAutomap.java
+++ b/src/org/infinity/resource/are/viewer/LayerAutomap.java
@@ -17,6 +17,7 @@
import org.infinity.util.IniMap;
import org.infinity.util.IniMapCache;
import org.infinity.util.IniMapSection;
+import org.tinylog.Logger;
/**
* Manages automap notes layer objects (both PST-specific and generic types).
@@ -106,7 +107,7 @@ private void loadPredefinedAutoNotes(AreResource are) {
objectList.add(obj);
}
} catch (IllegalArgumentException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/resource/are/viewer/LayerDoor.java b/src/org/infinity/resource/are/viewer/LayerDoor.java
index 76785fd05..9438c82f0 100644
--- a/src/org/infinity/resource/are/viewer/LayerDoor.java
+++ b/src/org/infinity/resource/are/viewer/LayerDoor.java
@@ -10,6 +10,7 @@
import org.infinity.gui.layeritem.AbstractLayerItem;
import org.infinity.resource.are.AreResource;
import org.infinity.resource.are.Door;
+import org.tinylog.Logger;
/**
* Manages door layer objects.
@@ -61,7 +62,7 @@ public void setLayerVisible(boolean visible) {
break;
default:
item.setVisible(false);
- System.out.println("Unknown layer id: " + item.getId());
+ Logger.info("Unknown layer id: {}", item.getId());
}
}
});
diff --git a/src/org/infinity/resource/are/viewer/LayerManager.java b/src/org/infinity/resource/are/viewer/LayerManager.java
index b2a0dbf86..61daa5141 100644
--- a/src/org/infinity/resource/are/viewer/LayerManager.java
+++ b/src/org/infinity/resource/are/viewer/LayerManager.java
@@ -10,6 +10,7 @@
import org.infinity.resource.are.AreResource;
import org.infinity.resource.are.viewer.ViewerConstants.LayerType;
import org.infinity.resource.wed.WedResource;
+import org.tinylog.Logger;
/**
* Manages all layer objects of a single ARE map.
@@ -601,7 +602,7 @@ private void init(AreResource are, WedResource wed, boolean forced) {
loadLayer(layer, forced || wedChanged);
break;
default:
- System.err.println(String.format("Unsupported layer type: %s", layer.toString()));
+ Logger.warn("Unsupported layer type: {}", layer);
}
}
}
@@ -753,7 +754,7 @@ private int loadLayer(LayerType layer, boolean forced) {
break;
}
default:
- System.err.println(String.format("Unsupported layer type: %s", layer.toString()));
+ Logger.warn("Unsupported layer type: {}", layer);
}
}
return retVal;
diff --git a/src/org/infinity/resource/are/viewer/LayerObjectAmbient.java b/src/org/infinity/resource/are/viewer/LayerObjectAmbient.java
index 8bd53c5a2..9ee9593b1 100644
--- a/src/org/infinity/resource/are/viewer/LayerObjectAmbient.java
+++ b/src/org/infinity/resource/are/viewer/LayerObjectAmbient.java
@@ -22,6 +22,7 @@
import org.infinity.resource.are.Ambient;
import org.infinity.resource.are.AreResource;
import org.infinity.resource.are.viewer.icon.ViewerIcons;
+import org.tinylog.Logger;
/**
* Handles specific layer type: ARE/Ambient Sound and Ambient Sound Range
@@ -71,7 +72,7 @@ public LayerObjectAmbient(AreResource parent, Ambient ambient) {
msg = ambient.getAttribute(Ambient.ARE_AMBIENT_NAME).toString();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
// Using cached icons
diff --git a/src/org/infinity/resource/are/viewer/LayerObjectAnimation.java b/src/org/infinity/resource/are/viewer/LayerObjectAnimation.java
index b53ec5252..e03589112 100644
--- a/src/org/infinity/resource/are/viewer/LayerObjectAnimation.java
+++ b/src/org/infinity/resource/are/viewer/LayerObjectAnimation.java
@@ -28,6 +28,7 @@
import org.infinity.resource.key.FileResourceEntry;
import org.infinity.resource.key.ResourceEntry;
import org.infinity.util.io.FileManager;
+import org.tinylog.Logger;
/**
* Handles specific layer type: ARE/Background Animation
@@ -169,7 +170,7 @@ public LayerObjectAnimation(AreResource parent, Animation anim) {
animation.setStartFrame(skippedFrames);
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
// Using cached icons
@@ -306,7 +307,7 @@ private static int[] getExternalPalette(ResourceRef bmpRef) {
}
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
return new int[0];
diff --git a/src/org/infinity/resource/are/viewer/LayerObjectAreActor.java b/src/org/infinity/resource/are/viewer/LayerObjectAreActor.java
index da664290b..f041fc785 100644
--- a/src/org/infinity/resource/are/viewer/LayerObjectAreActor.java
+++ b/src/org/infinity/resource/are/viewer/LayerObjectAreActor.java
@@ -23,6 +23,7 @@
import org.infinity.resource.are.viewer.icon.ViewerIcons;
import org.infinity.resource.cre.CreResource;
import org.infinity.resource.key.ResourceEntry;
+import org.tinylog.Logger;
/**
* Handles specific layer type: ARE/Actor
@@ -79,7 +80,7 @@ public LayerObjectAreActor(AreResource parent, Actor actor) {
ea = ((IsNumeric) cre.getAttribute(CreResource.CRE_ALLEGIANCE)).getValue();
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
this.cre = cre;
@@ -142,7 +143,7 @@ public synchronized void loadAnimation() {
item.setAnimation(sprite);
item.setComposite(Settings.UseActorAccurateBlending ? sprite.getDecoder().getComposite() : null);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/resource/are/viewer/LayerObjectAutomap.java b/src/org/infinity/resource/are/viewer/LayerObjectAutomap.java
index e17606e29..39d3b5f17 100644
--- a/src/org/infinity/resource/are/viewer/LayerObjectAutomap.java
+++ b/src/org/infinity/resource/are/viewer/LayerObjectAutomap.java
@@ -18,6 +18,7 @@
import org.infinity.resource.key.FileResourceEntry;
import org.infinity.resource.to.TohResource;
import org.infinity.util.io.FileManager;
+import org.tinylog.Logger;
/**
* Handles specific layer type: ARE/Automap Note (except for PST)
@@ -60,7 +61,7 @@ public LayerObjectAutomap(AreResource parent, AutomapNote note) {
}
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
// Using cached icons
diff --git a/src/org/infinity/resource/are/viewer/LayerObjectAutomapPST.java b/src/org/infinity/resource/are/viewer/LayerObjectAutomapPST.java
index a5531def8..533a1ff4e 100644
--- a/src/org/infinity/resource/are/viewer/LayerObjectAutomapPST.java
+++ b/src/org/infinity/resource/are/viewer/LayerObjectAutomapPST.java
@@ -14,6 +14,7 @@
import org.infinity.resource.are.AreResource;
import org.infinity.resource.are.AutomapNotePST;
import org.infinity.resource.are.viewer.icon.ViewerIcons;
+import org.tinylog.Logger;
/**
* Handles specific layer type: ARE/Automap Note (PST-specific, user-defined)
@@ -42,7 +43,7 @@ public LayerObjectAutomapPST(AreResource parent, AutomapNotePST note) {
location.y = (int) (y.getValue() * MAP_SCALE);
msg = note.getAttribute(AutomapNotePST.ARE_AUTOMAP_TEXT).toString();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
// Using cached icons
diff --git a/src/org/infinity/resource/are/viewer/LayerObjectContainer.java b/src/org/infinity/resource/are/viewer/LayerObjectContainer.java
index 1bb11059c..8710bc055 100644
--- a/src/org/infinity/resource/are/viewer/LayerObjectContainer.java
+++ b/src/org/infinity/resource/are/viewer/LayerObjectContainer.java
@@ -21,6 +21,7 @@
import org.infinity.resource.are.Container;
import org.infinity.resource.are.viewer.icon.ViewerIcons;
import org.infinity.resource.vertex.Vertex;
+import org.tinylog.Logger;
/**
* Handles specific layer type: ARE/Container
@@ -73,7 +74,7 @@ public LayerObjectContainer(AreResource parent, Container container) {
launchPoint.x = ((IsNumeric) container.getAttribute(Container.ARE_CONTAINER_LAUNCH_POINT_X)).getValue();
launchPoint.y = ((IsNumeric) container.getAttribute(Container.ARE_CONTAINER_LAUNCH_POINT_Y)).getValue();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
final Polygon poly = createPolygon(shapeCoords, 1.0);
final Rectangle bounds = normalizePolygon(poly);
diff --git a/src/org/infinity/resource/are/viewer/LayerObjectDoor.java b/src/org/infinity/resource/are/viewer/LayerObjectDoor.java
index aaee4035c..a5be11750 100644
--- a/src/org/infinity/resource/are/viewer/LayerObjectDoor.java
+++ b/src/org/infinity/resource/are/viewer/LayerObjectDoor.java
@@ -27,6 +27,7 @@
import org.infinity.resource.are.viewer.icon.ViewerIcons;
import org.infinity.resource.vertex.ClosedVertex;
import org.infinity.resource.vertex.OpenVertex;
+import org.tinylog.Logger;
/**
* Handles specific layer type: ARE/Door
@@ -88,7 +89,7 @@ public LayerObjectDoor(AreResource parent, Door door) {
launchPoint.x = ((IsNumeric) door.getAttribute(Door.ARE_DOOR_LAUNCH_POINT_X)).getValue();
launchPoint.y = ((IsNumeric) door.getAttribute(Door.ARE_DOOR_LAUNCH_POINT_Y)).getValue();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
for (final DoorInfo info: getDoors()) {
diff --git a/src/org/infinity/resource/are/viewer/LayerObjectDoorCells.java b/src/org/infinity/resource/are/viewer/LayerObjectDoorCells.java
index a94971112..48bd8c746 100644
--- a/src/org/infinity/resource/are/viewer/LayerObjectDoorCells.java
+++ b/src/org/infinity/resource/are/viewer/LayerObjectDoorCells.java
@@ -23,6 +23,7 @@
import org.infinity.resource.are.Door;
import org.infinity.resource.vertex.ClosedVertexImpeded;
import org.infinity.resource.vertex.OpenVertexImpeded;
+import org.tinylog.Logger;
/**
* Handles specific layer subtype: ARE/Door blocked cells
@@ -63,7 +64,7 @@ public LayerObjectDoorCells(AreResource parent, Door door) {
itemCoords = createCellPolygons(loadVertices(door, cOfs, 0, cNum, ClosedVertexImpeded.class));
doorClosed.setCoords(itemCoords);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
for (final DoorInfo info: getDoors()) {
diff --git a/src/org/infinity/resource/are/viewer/LayerObjectDoorPoly.java b/src/org/infinity/resource/are/viewer/LayerObjectDoorPoly.java
index b5430e23c..835f76900 100644
--- a/src/org/infinity/resource/are/viewer/LayerObjectDoorPoly.java
+++ b/src/org/infinity/resource/are/viewer/LayerObjectDoorPoly.java
@@ -23,6 +23,7 @@
import org.infinity.resource.vertex.Vertex;
import org.infinity.resource.wed.Door;
import org.infinity.resource.wed.WedResource;
+import org.tinylog.Logger;
/**
* Handles specific layer type: WED/Door Polygon.
@@ -63,7 +64,7 @@ public LayerObjectDoorPoly(WedResource parent, Door doorPoly) {
// processing closed door polygons
fillData(ofsClosed, numClosed, numOpen, info);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
if (info == null) {
info = new String[count];
}
diff --git a/src/org/infinity/resource/are/viewer/LayerObjectEntrance.java b/src/org/infinity/resource/are/viewer/LayerObjectEntrance.java
index 23cbee50a..f4b15f787 100644
--- a/src/org/infinity/resource/are/viewer/LayerObjectEntrance.java
+++ b/src/org/infinity/resource/are/viewer/LayerObjectEntrance.java
@@ -15,6 +15,7 @@
import org.infinity.resource.are.AreResource;
import org.infinity.resource.are.Entrance;
import org.infinity.resource.are.viewer.icon.ViewerIcons;
+import org.tinylog.Logger;
/**
* Handles specific layer type: ARE/Entrance
@@ -46,7 +47,7 @@ public LayerObjectEntrance(AreResource parent, Entrance entrance) {
final String name = entrance.getAttribute(Entrance.ARE_ENTRANCE_NAME).toString();
msg = String.format("%s (%s)", name, AbstractStruct.OPTION_ORIENTATION[o]);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
// Using cached icons
diff --git a/src/org/infinity/resource/are/viewer/LayerObjectGlobalActor.java b/src/org/infinity/resource/are/viewer/LayerObjectGlobalActor.java
index 5175c1d19..4dd924458 100644
--- a/src/org/infinity/resource/are/viewer/LayerObjectGlobalActor.java
+++ b/src/org/infinity/resource/are/viewer/LayerObjectGlobalActor.java
@@ -23,6 +23,7 @@
import org.infinity.resource.gam.GamResource;
import org.infinity.resource.gam.PartyNPC;
import org.infinity.resource.key.ResourceEntry;
+import org.tinylog.Logger;
/**
* Handles specific layer type: global GAM/Actor
@@ -119,7 +120,7 @@ public void loadAnimation() {
item.setAnimation(sprite);
item.setComposite(Settings.UseActorAccurateBlending ? sprite.getDecoder().getComposite() : null);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/resource/are/viewer/LayerObjectIniActor.java b/src/org/infinity/resource/are/viewer/LayerObjectIniActor.java
index 2b0a6d639..175ec0628 100644
--- a/src/org/infinity/resource/are/viewer/LayerObjectIniActor.java
+++ b/src/org/infinity/resource/are/viewer/LayerObjectIniActor.java
@@ -21,6 +21,7 @@
import org.infinity.resource.text.PlainTextResource;
import org.infinity.util.IniMapEntry;
import org.infinity.util.IniMapSection;
+import org.tinylog.Logger;
/**
* Handles specific layer type: INI/Actor
@@ -71,7 +72,7 @@ public LayerObjectIniActor(PlainTextResource ini, IniMapSection creData, int cre
try {
cre = new CreResource(creEntry);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
throw new IllegalArgumentException(creData.getName() + ": Invalid CRE resource", e);
}
@@ -179,7 +180,7 @@ public synchronized void loadAnimation() {
item.setAnimation(sprite);
item.setComposite(Settings.UseActorAccurateBlending ? sprite.getDecoder().getComposite() : null);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/resource/are/viewer/LayerObjectProTrap.java b/src/org/infinity/resource/are/viewer/LayerObjectProTrap.java
index 721e7b88d..a1cfc3d21 100644
--- a/src/org/infinity/resource/are/viewer/LayerObjectProTrap.java
+++ b/src/org/infinity/resource/are/viewer/LayerObjectProTrap.java
@@ -14,6 +14,7 @@
import org.infinity.resource.are.AreResource;
import org.infinity.resource.are.ProTrap;
import org.infinity.resource.are.viewer.icon.ViewerIcons;
+import org.tinylog.Logger;
/**
* Handles specific layer type: ARE/Projectile Trap
@@ -49,7 +50,7 @@ public LayerObjectProTrap(AreResource parent, ProTrap trap) {
msg += " (friendly)";
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
// Using cached icons
diff --git a/src/org/infinity/resource/are/viewer/LayerObjectRegion.java b/src/org/infinity/resource/are/viewer/LayerObjectRegion.java
index 64ad68065..34a2d3b29 100644
--- a/src/org/infinity/resource/are/viewer/LayerObjectRegion.java
+++ b/src/org/infinity/resource/are/viewer/LayerObjectRegion.java
@@ -24,6 +24,7 @@
import org.infinity.resource.are.ITEPoint;
import org.infinity.resource.are.viewer.icon.ViewerIcons;
import org.infinity.resource.vertex.Vertex;
+import org.tinylog.Logger;
/**
* Handles specific layer type: ARE/Region
@@ -112,7 +113,7 @@ ITEPoint.TYPE_ARRAY[type], getAttributes(),
}
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
final Polygon poly = createPolygon(shapeCoords, 1.0);
final Rectangle bounds = normalizePolygon(poly);
diff --git a/src/org/infinity/resource/are/viewer/LayerObjectSpawnPoint.java b/src/org/infinity/resource/are/viewer/LayerObjectSpawnPoint.java
index da58e3381..01ff372a5 100644
--- a/src/org/infinity/resource/are/viewer/LayerObjectSpawnPoint.java
+++ b/src/org/infinity/resource/are/viewer/LayerObjectSpawnPoint.java
@@ -15,6 +15,7 @@
import org.infinity.resource.are.AreResource;
import org.infinity.resource.are.SpawnPoint;
import org.infinity.resource.are.viewer.icon.ViewerIcons;
+import org.tinylog.Logger;
/**
* Handles specific layer type: ARE/Spawn Point
@@ -43,7 +44,7 @@ public LayerObjectSpawnPoint(AreResource parent, SpawnPoint sp) {
scheduleFlags = ((Flag) sp.getAttribute(SpawnPoint.ARE_SPAWN_ACTIVE_AT));
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
// Using cached icons
diff --git a/src/org/infinity/resource/are/viewer/LayerObjectTransition.java b/src/org/infinity/resource/are/viewer/LayerObjectTransition.java
index 6d63f86c0..aa22406bc 100644
--- a/src/org/infinity/resource/are/viewer/LayerObjectTransition.java
+++ b/src/org/infinity/resource/are/viewer/LayerObjectTransition.java
@@ -13,6 +13,7 @@
import org.infinity.gui.layeritem.ShapedLayerItem;
import org.infinity.resource.Viewable;
import org.infinity.resource.are.AreResource;
+import org.tinylog.Logger;
/**
* Handles specific layer type: ARE/Map transition
@@ -46,7 +47,7 @@ public LayerObjectTransition(AreResource parent, AreResource destination, int ed
msg = String.format("Transition to %s", ref);
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
item = new ShapedLayerItem(destination, msg, null);
diff --git a/src/org/infinity/resource/are/viewer/LayerObjectWallPoly.java b/src/org/infinity/resource/are/viewer/LayerObjectWallPoly.java
index 148569a1d..bcb552a46 100644
--- a/src/org/infinity/resource/are/viewer/LayerObjectWallPoly.java
+++ b/src/org/infinity/resource/are/viewer/LayerObjectWallPoly.java
@@ -17,6 +17,7 @@
import org.infinity.resource.vertex.Vertex;
import org.infinity.resource.wed.WallPolygon;
import org.infinity.resource.wed.WedResource;
+import org.tinylog.Logger;
/**
* Handles specific layer type: ARE/Wall Polygon
@@ -45,7 +46,7 @@ public LayerObjectWallPoly(WedResource parent, WallPolygon wall) {
int startIdx = flags.isFlagSet(2) ? 2 : 0; // skipping first two vertices for "hovering walls"
shapeCoords = loadVertices(wall, vOfs, startIdx, vNum - startIdx, Vertex.class);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
final Polygon poly = createPolygon(shapeCoords, 1.0);
final Rectangle bounds = normalizePolygon(poly);
diff --git a/src/org/infinity/resource/are/viewer/LayerTransition.java b/src/org/infinity/resource/are/viewer/LayerTransition.java
index a7c580d94..301967190 100644
--- a/src/org/infinity/resource/are/viewer/LayerTransition.java
+++ b/src/org/infinity/resource/are/viewer/LayerTransition.java
@@ -9,6 +9,7 @@
import org.infinity.datatype.ResourceRef;
import org.infinity.resource.ResourceFactory;
import org.infinity.resource.are.AreResource;
+import org.tinylog.Logger;
/**
* Manages map transition layer objects.
@@ -33,7 +34,7 @@ protected void loadLayer() {
setListeners(obj);
list.add(obj);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/resource/are/viewer/Settings.java b/src/org/infinity/resource/are/viewer/Settings.java
index 1a1686108..d88629132 100644
--- a/src/org/infinity/resource/are/viewer/Settings.java
+++ b/src/org/infinity/resource/are/viewer/Settings.java
@@ -12,6 +12,7 @@
import org.infinity.resource.are.viewer.ViewerConstants.LayerStackingType;
import org.infinity.resource.are.viewer.ViewerConstants.LayerType;
+import org.tinylog.Logger;
/**
* Manages global area viewer settings.
@@ -307,7 +308,7 @@ public static void storeSettings(boolean force) {
try {
prefs.flush();
} catch (BackingStoreException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
diff --git a/src/org/infinity/resource/are/viewer/TilesetRenderer.java b/src/org/infinity/resource/are/viewer/TilesetRenderer.java
index 001a19e79..596ad1ded 100644
--- a/src/org/infinity/resource/are/viewer/TilesetRenderer.java
+++ b/src/org/infinity/resource/are/viewer/TilesetRenderer.java
@@ -31,6 +31,7 @@
import org.infinity.resource.wed.Overlay;
import org.infinity.resource.wed.Tilemap;
import org.infinity.resource.wed.WedResource;
+import org.tinylog.Logger;
/**
* Specialized renderer for drawing tileset-based graphics data.
@@ -761,11 +762,11 @@ private boolean hasOverlay(int ovlIdx) {
// Draws a grid on the map with the specified parameters
private void drawGrid(Graphics g, double gridWidth, double gridHeight, Color color) {
if (g == null) {
- System.err.println("TilesetRenderer.drawGrid: Graphics argument is null");
+ Logger.warn("TilesetRenderer.drawGrid: Graphics argument is null");
return;
}
if (color == null) {
- System.err.println("TilesetRenderer.drawGrid: Color argument is null");
+ Logger.warn("TilesetRenderer.drawGrid: Color argument is null");
return;
}
final double gridWidthZoomed = gridWidth * zoomFactor;
@@ -965,7 +966,7 @@ private synchronized void drawTile(Tile tile, boolean isDoorTile) {
if (tileIdx < listTilesets.get(0).listTileData.size()) {
srcSec = listTilesets.get(0).listTileData.get(tileIdx);
} else {
- System.err.println("Invalid tile index: " + tileIdx + " of " + listTilesets.get(0).listTileData.size());
+ Logger.warn("Invalid tile index: {} of {}", tileIdx, listTilesets.get(0).listTileData.size());
}
}
@@ -1156,7 +1157,7 @@ private void init(WedResource wed, Overlay ovl) {
decoder.close();
decoder = null;
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
return;
}
}
diff --git a/src/org/infinity/resource/bcs/BafResource.java b/src/org/infinity/resource/bcs/BafResource.java
index a11c32527..400f2ccd3 100644
--- a/src/org/infinity/resource/bcs/BafResource.java
+++ b/src/org/infinity/resource/bcs/BafResource.java
@@ -57,6 +57,7 @@
import org.infinity.util.Misc;
import org.infinity.util.StaticSimpleXorDecryptor;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
public class BafResource implements TextResource, Writeable, Closeable, ItemListener, ActionListener, DocumentListener {
// for source panel
@@ -416,7 +417,7 @@ private void compile() {
bpmUses.setMenuItems(usesItems);
bpmUses.setEnabled(usesItems.length > 0);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
@@ -429,7 +430,7 @@ private void decompile() {
try {
sourceText.setText(decompiler.getSource());
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
sourceText.setCaretPosition(0);
Set uses = decompiler.getResourcesUsed();
@@ -501,7 +502,7 @@ public String getDescription() {
} catch (IOException e) {
JOptionPane.showMessageDialog(panel, "Error saving " + chooser.getSelectedFile().toString(), "Error",
JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/resource/bcs/BcsResource.java b/src/org/infinity/resource/bcs/BcsResource.java
index 2d39ef827..fd96f19f0 100644
--- a/src/org/infinity/resource/bcs/BcsResource.java
+++ b/src/org/infinity/resource/bcs/BcsResource.java
@@ -62,6 +62,7 @@
import org.infinity.util.Misc;
import org.infinity.util.StaticSimpleXorDecryptor;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* This resource represent scripted actions. {@code .bcs} files are scripts attached to anything other than the player
@@ -487,7 +488,7 @@ public String getDescription() {
} catch (IOException e) {
JOptionPane.showMessageDialog(panel, "Error exporting " + chooser.getSelectedFile().toString(), "Error",
JOptionPane.ERROR_MESSAGE);
- e.printStackTrace();
+ Logger.error(e);
}
}
} else if (bpmExport.getSelectedItem() == iExportScript) {
@@ -529,7 +530,7 @@ public String getText() {
try {
return decompiler.getSource();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
return "// Error: " + e.getMessage();
}
}
@@ -739,7 +740,7 @@ private void decompile() {
try {
sourceText.setText(decompiler.getSource());
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
sourceText.setText("/*\nError: " + e.getMessage() + "\n*/");
}
sourceText.setCaretPosition(0);
diff --git a/src/org/infinity/resource/cre/CreResource.java b/src/org/infinity/resource/cre/CreResource.java
index 44d47239a..97c6530c7 100644
--- a/src/org/infinity/resource/cre/CreResource.java
+++ b/src/org/infinity/resource/cre/CreResource.java
@@ -79,6 +79,7 @@
import org.infinity.util.StringTable;
import org.infinity.util.Table2da;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* This resource describes a "creature". Creatures have several stats (some visible through the game UI) which are
@@ -617,7 +618,7 @@ public static void convertCHRtoCRE(ResourceEntry resourceEntry) {
JOptionPane.showMessageDialog(NearInfinity.getInstance(), "File saved to " + path, "Conversion complete",
JOptionPane.INFORMATION_MESSAGE);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
JOptionPane.showMessageDialog(NearInfinity.getInstance(), "Errors during conversion", "Error",
JOptionPane.ERROR_MESSAGE);
}
@@ -627,7 +628,7 @@ public static void convertCHRtoCRE(ResourceEntry resourceEntry) {
private static void convertToSemiStandard(CreResource crefile) {
final List fields = crefile.getFields();
if (!fields.get(1).toString().equals("V1.0")) {
- System.err.println("Conversion to semi-standard aborted: Unsupported CRE version");
+ Logger.warn("Conversion to semi-standard aborted: Unsupported CRE version");
return;
}
@@ -2135,7 +2136,7 @@ private boolean convertEffects(int version, SectionOffset so, SectionCount sc) {
addDatatype(newEff);
retVal |= true;
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
} else if (version == 1 && so.getSection().equals(Effect.class)) {
@@ -2165,7 +2166,7 @@ private boolean convertEffects(int version, SectionOffset so, SectionCount sc) {
addDatatype(newEff);
retVal |= true;
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
diff --git a/src/org/infinity/resource/cre/ViewerAnimation.java b/src/org/infinity/resource/cre/ViewerAnimation.java
index b08e438f8..21cda12a6 100644
--- a/src/org/infinity/resource/cre/ViewerAnimation.java
+++ b/src/org/infinity/resource/cre/ViewerAnimation.java
@@ -47,6 +47,7 @@
import org.infinity.resource.cre.decoder.util.Sequence;
import org.infinity.resource.cre.decoder.util.SpriteUtils;
import org.infinity.resource.graphics.ColorConvert;
+import org.tinylog.Logger;
/**
* A basic creature animation viewer.
@@ -247,7 +248,7 @@ public void open() {
WindowBlocker.blockWindow(true);
initAnimation();
} catch (Exception ex) {
- ex.printStackTrace();
+ Logger.error(ex);
WindowBlocker.blockWindow(false);
JOptionPane.showMessageDialog(NearInfinity.getInstance(),
"Creature animation could not be loaded.\nError message: " + ex.getMessage(), "Error",
@@ -286,7 +287,7 @@ public void actionPerformed(ActionEvent event) {
setAnimationSequence(seq);
updateControls();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
cbSequences.setSelectedItem(getAnimationSequence());
} finally {
@@ -315,7 +316,7 @@ public void actionPerformed(ActionEvent event) {
getDecoder().setBoundingBoxVisible(showOverlayBorders);
resetAnimationSequence();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
} finally {
WindowBlocker.blockWindow(false);
}
diff --git a/src/org/infinity/resource/cre/browser/CreUtils.java b/src/org/infinity/resource/cre/browser/CreUtils.java
index 24cb50d41..1c9c11388 100644
--- a/src/org/infinity/resource/cre/browser/CreUtils.java
+++ b/src/org/infinity/resource/cre/browser/CreUtils.java
@@ -25,6 +25,7 @@
import org.infinity.resource.cre.decoder.util.ItemInfo;
import org.infinity.resource.key.ResourceEntry;
import org.infinity.util.Misc;
+import org.tinylog.Logger;
/**
* Collection of methods for creating and manipulating CRE resources.
@@ -132,7 +133,7 @@ public static ItemInfo getEquipmentHelmet(CreResource cre) {
retVal = ItemInfo.getValidated(itemEntry);
retVal.overrideDroppableFlag(((Flag) item.getAttribute(Item.CRE_ITEM_FLAGS)).isFlagSet(3));
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
@@ -172,7 +173,7 @@ public static ItemInfo getEquipmentArmor(CreResource cre) {
retVal = ItemInfo.getValidated(itemEntry);
retVal.overrideDroppableFlag(((Flag) item.getAttribute(Item.CRE_ITEM_FLAGS)).isFlagSet(3));
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
@@ -220,7 +221,7 @@ public static ItemInfo getEquipmentShield(CreResource cre) {
retVal = ItemInfo.getValidated(itemEntry);
retVal.overrideDroppableFlag(((Flag) item.getAttribute(Item.CRE_ITEM_FLAGS)).isFlagSet(3));
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
@@ -266,7 +267,7 @@ public static ItemInfo getEquipmentWeapon(CreResource cre) {
retVal = ItemInfo.getValidated(itemEntry);
retVal.overrideDroppableFlag(((Flag) item.getAttribute(Item.CRE_ITEM_FLAGS)).isFlagSet(3));
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
@@ -383,7 +384,7 @@ private static void addEquippedItem(CreResource cre, ItemInfo item, String slotN
cre.addDatatype(newItem);
setFieldValue(cre.getAttribute(slotName), null, numItems);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
@@ -528,7 +529,7 @@ private static int setFieldValue(Readable field, ByteBuffer buf, int value) {
try {
retVal = field.read(buf, pos);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
return retVal;
@@ -556,7 +557,7 @@ private static int setFieldValue(Readable field, ByteBuffer buf, String value, i
try {
retVal = field.read(buf, pos);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
return retVal;
diff --git a/src/org/infinity/resource/cre/browser/CreatureBrowser.java b/src/org/infinity/resource/cre/browser/CreatureBrowser.java
index b68ac1dbc..d836a7304 100644
--- a/src/org/infinity/resource/cre/browser/CreatureBrowser.java
+++ b/src/org/infinity/resource/cre/browser/CreatureBrowser.java
@@ -27,6 +27,7 @@
import org.infinity.resource.cre.CreResource;
import org.infinity.resource.cre.decoder.SpriteDecoder;
import org.infinity.resource.cre.decoder.util.SpriteUtils;
+import org.tinylog.Logger;
/**
* The Creature Browser implements a highly customizable browser and viewer for creature animations.
@@ -199,7 +200,7 @@ private Object taskSetCreResource() throws Exception {
/** A generic catch-all operation that can be used to evaluate exceptions thrown in a background task. */
private void postTaskDefault(Object o, Exception e) {
if (e != null) {
- e.printStackTrace();
+ Logger.error(e);
JOptionPane.showMessageDialog(this, "Error: " + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
}
@@ -236,7 +237,7 @@ protected TaskInfo doInBackground() throws Exception {
if (retVal.postAction != null) {
retVal.exception = e;
} else {
- e.printStackTrace();
+ Logger.error(e);
}
} finally {
if (blocker != null) {
diff --git a/src/org/infinity/resource/cre/browser/CreatureControlModel.java b/src/org/infinity/resource/cre/browser/CreatureControlModel.java
index e2efa5fe1..2e971edf8 100644
--- a/src/org/infinity/resource/cre/browser/CreatureControlModel.java
+++ b/src/org/infinity/resource/cre/browser/CreatureControlModel.java
@@ -20,6 +20,7 @@
import org.infinity.resource.cre.decoder.util.ItemInfo;
import org.infinity.resource.cre.decoder.util.ItemInfo.ItemPredicate;
import org.infinity.resource.key.ResourceEntry;
+import org.tinylog.Logger;
/**
* This model controls the relationships between creature controls and provides access to the various creature-specific
@@ -480,7 +481,7 @@ public void reset() {
try {
creSelectionChanged();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
diff --git a/src/org/infinity/resource/cre/browser/CreatureControlPanel.java b/src/org/infinity/resource/cre/browser/CreatureControlPanel.java
index 08b452383..5f2eec4ed 100644
--- a/src/org/infinity/resource/cre/browser/CreatureControlPanel.java
+++ b/src/org/infinity/resource/cre/browser/CreatureControlPanel.java
@@ -44,6 +44,7 @@
import org.infinity.util.IdsMapCache;
import org.infinity.util.IdsMapEntry;
import org.infinity.util.Misc;
+import org.tinylog.Logger;
/**
* This panel provides controls for customizing various aspects of a CRE resource.
@@ -145,7 +146,7 @@ public void applySettings() {
try {
getControlModel().resetDecoder(cre);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
getBrowser().showErrorMessage(e.getMessage(), "Loading creature");
}
@@ -506,7 +507,7 @@ public void actionPerformed(ActionEvent e) {
getControlModel().creSelectionChanged();
updateToolTip(cbCreSelection);
} catch (Exception ex) {
- ex.printStackTrace();
+ Logger.error(ex);
getBrowser().showErrorMessage(ex.getMessage(), "Creature selection");
}
} else if (e.getSource() == cbCreAnimation) {
diff --git a/src/org/infinity/resource/cre/browser/CreatureSelectionModel.java b/src/org/infinity/resource/cre/browser/CreatureSelectionModel.java
index 16ed74a93..83ab844b6 100644
--- a/src/org/infinity/resource/cre/browser/CreatureSelectionModel.java
+++ b/src/org/infinity/resource/cre/browser/CreatureSelectionModel.java
@@ -25,6 +25,7 @@
import org.infinity.util.ResourceStructure;
import org.infinity.util.io.StreamUtils;
import org.infinity.util.tuples.Couple;
+import org.tinylog.Logger;
/**
* {@code ComboBoxModel} for the creature selection combo box used in the Creature Animation Browser.
@@ -261,7 +262,7 @@ private static ResourceEntry createCreature() {
retVal = new BufferedResourceEntry(buf, "*.CRE");
} catch (StructureException e) {
- e.printStackTrace();
+ Logger.error(e);
}
return retVal;
diff --git a/src/org/infinity/resource/cre/browser/MediaPanel.java b/src/org/infinity/resource/cre/browser/MediaPanel.java
index bad015b1d..c42dd0224 100644
--- a/src/org/infinity/resource/cre/browser/MediaPanel.java
+++ b/src/org/infinity/resource/cre/browser/MediaPanel.java
@@ -54,6 +54,7 @@
import org.infinity.resource.cre.decoder.util.Sequence;
import org.infinity.resource.graphics.ColorConvert;
import org.infinity.util.tuples.Couple;
+import org.tinylog.Logger;
import ork.sevenstates.apng.APNGSeqWriter;
@@ -321,7 +322,7 @@ public void loadSequence(Sequence seq) throws IllegalArgumentException {
throw new Exception();
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
throw new IllegalArgumentException("Could not load animation sequence");
}
@@ -819,7 +820,7 @@ private void exportBamSequence() {
JOptionPane.showMessageDialog(browser, message, "Export animation sequence",
JOptionPane.INFORMATION_MESSAGE);
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
JOptionPane.showMessageDialog(browser, "Unable to export animation sequence.", "Error", JOptionPane.ERROR_MESSAGE);
}
}
@@ -893,7 +894,7 @@ public void itemStateChanged(ItemEvent e) {
WindowBlocker.blockWindow(getBrowser(), true);
loadSequence(seq);
} catch (Exception ex) {
- ex.printStackTrace();
+ Logger.error(ex);
getBrowser().showErrorMessage(ex.getMessage(), "Sequence selection");
} finally {
WindowBlocker.blockWindow(getBrowser(), false);
diff --git a/src/org/infinity/resource/cre/browser/bg/Backgrounds.java b/src/org/infinity/resource/cre/browser/bg/Backgrounds.java
index 7f663fdcc..705d06587 100644
--- a/src/org/infinity/resource/cre/browser/bg/Backgrounds.java
+++ b/src/org/infinity/resource/cre/browser/bg/Backgrounds.java
@@ -15,6 +15,7 @@
import javax.swing.UIManager;
import org.infinity.resource.Profile;
+import org.tinylog.Logger;
/**
* Backgrounds for the creature animation browser.
@@ -80,7 +81,7 @@ public static Image getImage(Class> c, String fileName) {
URL url = getValidURL(c, fileName);
retVal = ImageIO.read(url);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
return retVal;
}
diff --git a/src/org/infinity/resource/cre/decoder/PlaceholderDecoder.java b/src/org/infinity/resource/cre/decoder/PlaceholderDecoder.java
index 89d53e599..37b0c56e4 100644
--- a/src/org/infinity/resource/cre/decoder/PlaceholderDecoder.java
+++ b/src/org/infinity/resource/cre/decoder/PlaceholderDecoder.java
@@ -24,6 +24,7 @@
import org.infinity.util.IniMapEntry;
import org.infinity.util.IniMapSection;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* General-purpose creature animation decoder for handling non-existing or unknown animation types.
@@ -50,7 +51,7 @@ private static ResourceEntry loadPlaceholderBam() {
baos.flush();
retVal = new BufferedResourceEntry(StreamUtils.getByteBuffer(baos.toByteArray()), "placeholder.bam");
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
}
return retVal;
}
diff --git a/src/org/infinity/resource/cre/decoder/SpriteDecoder.java b/src/org/infinity/resource/cre/decoder/SpriteDecoder.java
index 0a93a0bc0..83801270d 100644
--- a/src/org/infinity/resource/cre/decoder/SpriteDecoder.java
+++ b/src/org/infinity/resource/cre/decoder/SpriteDecoder.java
@@ -60,6 +60,7 @@
import org.infinity.util.IniMapSection;
import org.infinity.util.Misc;
import org.infinity.util.tuples.Couple;
+import org.tinylog.Logger;
/**
* Specialized BAM decoder for creature animation sprites.
@@ -295,7 +296,7 @@ public T getAttribute(DecoderAttribute att) {
try {
retVal = (T) data;
} catch (ClassCastException e) {
- // e.printStackTrace();
+ // Logger.error(e);
}
}
return retVal;
@@ -392,7 +393,7 @@ public boolean loadSequence(Sequence seq, Direction[] directions) throws Excepti
} catch (NullPointerException e) {
retVal = (seq != Sequence.NONE);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
retVal = (seq != Sequence.NONE);
}
}
@@ -841,7 +842,7 @@ public void applyAnimationChanges() {
try {
reset();
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
@@ -1490,7 +1491,7 @@ protected int[] getColorData(int colorIndex, boolean allowRandom) {
try {
retVal = SpriteUtils.getColorGradient(colorIndex, allowRandom);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
return retVal;
}
diff --git a/src/org/infinity/resource/cre/decoder/tables/InfinityTables.java b/src/org/infinity/resource/cre/decoder/tables/InfinityTables.java
index 5adcfa3c4..94e68f8d6 100644
--- a/src/org/infinity/resource/cre/decoder/tables/InfinityTables.java
+++ b/src/org/infinity/resource/cre/decoder/tables/InfinityTables.java
@@ -21,6 +21,7 @@
import org.infinity.util.IdsMapEntry;
import org.infinity.util.IniMap;
import org.infinity.util.Misc;
+import org.tinylog.Logger;
/**
* A static class dedicated to processing Infinity Animation slots.
@@ -57,7 +58,7 @@ public static List createIniMaps(int animationId) {
IdsMap table = new IdsMap(entry);
retVal.addAll(processTable(table, animationId));
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
return retVal;
@@ -95,9 +96,9 @@ private static List processTable(IdsMap idsMap, int animationId) {
}
} catch (InvocationTargetException ite) {
if (ite.getCause() != null) {
- ite.getCause().printStackTrace();
+ Logger.error(ite.getCause());
} else {
- ite.printStackTrace();
+ Logger.error(ite);
}
} catch (Exception e) {
return retVal;
diff --git a/src/org/infinity/resource/cre/decoder/tables/SpriteTables.java b/src/org/infinity/resource/cre/decoder/tables/SpriteTables.java
index f0a7b896b..50063f7bb 100644
--- a/src/org/infinity/resource/cre/decoder/tables/SpriteTables.java
+++ b/src/org/infinity/resource/cre/decoder/tables/SpriteTables.java
@@ -22,6 +22,7 @@
import org.infinity.resource.key.ResourceEntry;
import org.infinity.util.IniMap;
import org.infinity.util.Table2da;
+import org.tinylog.Logger;
/**
* A static class that provides information and methods for hardcoded creature animations.
@@ -206,12 +207,12 @@ private static List processTable(Table2da table, int animationId) {
}
} catch (InvocationTargetException ite) {
if (ite.getCause() != null) {
- ite.getCause().printStackTrace();
+ Logger.error(ite.getCause());
} else {
- ite.printStackTrace();
+ Logger.error(ite);
}
} catch (NoSuchMethodException | IllegalAccessException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
diff --git a/src/org/infinity/resource/cre/decoder/util/CreatureInfo.java b/src/org/infinity/resource/cre/decoder/util/CreatureInfo.java
index 373a99c09..789c4cee6 100644
--- a/src/org/infinity/resource/cre/decoder/util/CreatureInfo.java
+++ b/src/org/infinity/resource/cre/decoder/util/CreatureInfo.java
@@ -33,6 +33,7 @@
import org.infinity.util.Table2da;
import org.infinity.util.Table2daCache;
import org.infinity.util.tuples.Couple;
+import org.tinylog.Logger;
/**
* Provides useful information about a creature resource and their equipment.
@@ -893,7 +894,7 @@ private void initEquipmentItem(ItemSlots slot, int itemIndex, List
itemInfo.overrideDroppableFlag(isUndroppable);
equipment.put(slot, itemInfo);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/resource/cre/decoder/util/EffectInfo.java b/src/org/infinity/resource/cre/decoder/util/EffectInfo.java
index 93a5507ab..a8081fa79 100644
--- a/src/org/infinity/resource/cre/decoder/util/EffectInfo.java
+++ b/src/org/infinity/resource/cre/decoder/util/EffectInfo.java
@@ -28,6 +28,7 @@
import org.infinity.util.Table2da;
import org.infinity.util.Table2daCache;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* Manages effects opcodes for a specific target.
@@ -462,7 +463,7 @@ private void resolveSPL(List list, Effect parent, ResourceEntry entry) {
}
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
@@ -476,7 +477,7 @@ private void resolveEFF(List list, Effect parent, ResourceEntry entry) {
final List retList = resolveEffect(parent, Effect.fromEffectV2(entry.getResourceBuffer(), 8));
list.addAll(retList);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
diff --git a/src/org/infinity/resource/cre/decoder/util/ItemInfo.java b/src/org/infinity/resource/cre/decoder/util/ItemInfo.java
index 21639de04..f504728f0 100644
--- a/src/org/infinity/resource/cre/decoder/util/ItemInfo.java
+++ b/src/org/infinity/resource/cre/decoder/util/ItemInfo.java
@@ -24,6 +24,7 @@
import org.infinity.util.Misc;
import org.infinity.util.StringTable;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* Provides useful information about equippable items.
@@ -480,7 +481,7 @@ public static int getItemCategory(ResourceEntry itmEntry) {
Misc.requireCondition(is.skip(0x14) == 0x14, "Could not advance in data stream");
return StreamUtils.readShort(is);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
return -1;
diff --git a/src/org/infinity/resource/cre/decoder/util/SpriteUtils.java b/src/org/infinity/resource/cre/decoder/util/SpriteUtils.java
index 6d41a2181..5a26d3dae 100644
--- a/src/org/infinity/resource/cre/decoder/util/SpriteUtils.java
+++ b/src/org/infinity/resource/cre/decoder/util/SpriteUtils.java
@@ -65,6 +65,7 @@
import org.infinity.util.Table2daCache;
import org.infinity.util.io.StreamUtils;
import org.infinity.util.tuples.Couple;
+import org.tinylog.Logger;
/**
* Collection of helpful methods for Sprite rendering.
@@ -448,7 +449,7 @@ public static Couple loadBamDecoderCont
retVal = Couple.with(decoder, control);
BAM_CACHE.put(entry, retVal);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
return retVal;
@@ -616,7 +617,7 @@ public static int[] loadReplacementPalette(String resref, int index) {
PALETTE_CACHE.put(entry, retVal);
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
@@ -711,7 +712,7 @@ public static int[] getColorGradient(int index, boolean allowRandom) {
COLOR_GRADIENTS.put(y, pixels);
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
} else {
// dummy entry to skip continuous gradient initialization attempts if gradient bitmap isn't available
@@ -1279,7 +1280,7 @@ private static List guessIniMaps(int animationId) {
break;
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/resource/dlg/AbstractCode.java b/src/org/infinity/resource/dlg/AbstractCode.java
index a32620809..3dbf8d5fd 100644
--- a/src/org/infinity/resource/dlg/AbstractCode.java
+++ b/src/org/infinity/resource/dlg/AbstractCode.java
@@ -47,6 +47,7 @@
import org.infinity.resource.bcs.ScriptType;
import org.infinity.util.Misc;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
public abstract class AbstractCode extends Datatype
implements Editable, IsTextual, AddRemovable, ActionListener, DocumentListener, ItemListener {
@@ -325,7 +326,7 @@ public void addFlatList(List flatList) {
ts.setOffset(off.getValue());
flatList.add(ts);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
diff --git a/src/org/infinity/resource/dlg/DlgResource.java b/src/org/infinity/resource/dlg/DlgResource.java
index 2c497e1cf..0d0fe5dc2 100644
--- a/src/org/infinity/resource/dlg/DlgResource.java
+++ b/src/org/infinity/resource/dlg/DlgResource.java
@@ -50,6 +50,7 @@
import org.infinity.updater.Utils;
import org.infinity.util.StringTable;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* DLG resource contains the structure of conversation, in what is effectievly a state machine. Dialogs contains string
@@ -222,7 +223,7 @@ public void actionPerformed(ActionEvent e) {
throw new Exception();
}
} catch (Exception ex) {
- ex.printStackTrace();
+ Logger.error(ex);
JOptionPane.showMessageDialog(getViewer().getTopLevelAncestor(),
"Could not export resource into WeiDU dialog format.", "Error", JOptionPane.ERROR_MESSAGE);
return;
diff --git a/src/org/infinity/resource/dlg/DlgTreeModel.java b/src/org/infinity/resource/dlg/DlgTreeModel.java
index b2a1c2d78..fb95f28e6 100644
--- a/src/org/infinity/resource/dlg/DlgTreeModel.java
+++ b/src/org/infinity/resource/dlg/DlgTreeModel.java
@@ -35,6 +35,7 @@
import org.infinity.resource.ResourceFactory;
import org.infinity.resource.StructEntry;
import org.infinity.resource.key.ResourceEntry;
+import org.tinylog.Logger;
/** Creates and manages the dialog tree structure. */
final class DlgTreeModel implements TreeModel, TreeNode, TableModelListener, PropertyChangeListener {
@@ -905,7 +906,7 @@ private DlgResource getDialogResource(ResourceRef dlgRef) {
try {
return new DlgResource(ResourceFactory.getResourceEntry(name));
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
return null;
});
diff --git a/src/org/infinity/resource/dlg/TreeWorker.java b/src/org/infinity/resource/dlg/TreeWorker.java
index da9495add..c6d6e0fed 100644
--- a/src/org/infinity/resource/dlg/TreeWorker.java
+++ b/src/org/infinity/resource/dlg/TreeWorker.java
@@ -13,6 +13,8 @@
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
+import org.tinylog.Logger;
+
//-------------------------- INNER CLASSES --------------------------
/** Applies expand or collapse operations on a set of dialog tree nodes in a background task. */
@@ -49,7 +51,7 @@ protected Void doInBackground() throws Exception {
collapseNode(path);
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
return null;
}
@@ -88,7 +90,7 @@ private void expandNode(final TreePath path) {
try {
SwingUtilities.invokeAndWait(() -> dlgTree.expandPath(path));
} catch (InterruptedException | InvocationTargetException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
@@ -126,7 +128,7 @@ private void collapseNode(final TreePath path) {
try {
SwingUtilities.invokeAndWait(() -> dlgTree.collapsePath(path));
} catch (InterruptedException | InvocationTargetException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/resource/dlg/Viewer.java b/src/org/infinity/resource/dlg/Viewer.java
index 737da8dbd..a4a7efee0 100644
--- a/src/org/infinity/resource/dlg/Viewer.java
+++ b/src/org/infinity/resource/dlg/Viewer.java
@@ -53,6 +53,7 @@
import org.infinity.search.DialogSearcher;
import org.infinity.util.Misc;
import org.infinity.util.StringTable;
+import org.tinylog.Logger;
final class Viewer extends JPanel implements ActionListener, ItemListener, TableModelListener {
private static final ButtonPanel.Control CTRL_NEXT_STATE = ButtonPanel.Control.CUSTOM_1;
@@ -406,7 +407,7 @@ public void select(StructEntry entry) {
showState(stateNrToShow);
showTransition(transNrToShow);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
@@ -448,7 +449,7 @@ private void showState(int nr) {
if (!isValid) {
if (nr >= 0) {
// Print warning about not correct resource
- System.err.println(dlg.getName() + ": state " + nr + " is not exist");
+ Logger.warn("{}: state {} does not exist", dlg.getName(), nr);
}
stateTextPanel.clearDisplay();
stateTriggerPanel.clearDisplay();
@@ -500,10 +501,9 @@ private void showTransition(int nr) {
if (nr >= 0 && currentState != null) {
// Print warning about not correct resource
if (isValid) {
- System.err.println(
- dlg.getName() + ": transition " + nr + " is not transition from state " + currentState.getNumber());
+ Logger.warn("{}: transition {} is not transition from state {}", dlg.getName(), nr, currentState.getNumber());
} else if (isBroken) {
- System.err.println(dlg.getName() + ": transition " + nr + " is not exist");
+ Logger.warn("{}: transition {} does not exist", dlg.getName(), nr);
}
}
transTextPanel.clearDisplay();
diff --git a/src/org/infinity/resource/effects/BaseOpcode.java b/src/org/infinity/resource/effects/BaseOpcode.java
index 28de51e10..c9bce48c1 100644
--- a/src/org/infinity/resource/effects/BaseOpcode.java
+++ b/src/org/infinity/resource/effects/BaseOpcode.java
@@ -36,6 +36,7 @@
import org.infinity.util.Table2daCache;
import org.infinity.util.io.ByteBufferOutputStream;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* Base class for opcode-handling classes. Derived classes should handle one opcode per class for all game variants.
@@ -650,12 +651,12 @@ public static synchronized String[] getPortraitIconNames(String defaultName) {
portraitIconNames[index] = StringTable.getStringRef(strref);
}
} catch (NumberFormatException nfe) {
- nfe.printStackTrace();
+ Logger.error(nfe);
}
}
}
} catch (NullPointerException npe) {
- npe.printStackTrace();
+ Logger.error(npe);
}
}
@@ -888,7 +889,7 @@ public static ByteBuffer getEntryData(StructEntry entry)
try (ByteBufferOutputStream bbos = new ByteBufferOutputStream(bb)) {
entry.write(bbos);
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
return null;
}
return bb;
@@ -913,7 +914,7 @@ public static ByteBuffer getEntryData(AbstractStruct struct, EffectEntry id)
}
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
return null;
@@ -1026,7 +1027,7 @@ private static synchronized TreeMap getOpcodeMap() {
}
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException
| InstantiationException e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/resource/gam/GamResource.java b/src/org/infinity/resource/gam/GamResource.java
index dbf54c734..6c5dc5037 100644
--- a/src/org/infinity/resource/gam/GamResource.java
+++ b/src/org/infinity/resource/gam/GamResource.java
@@ -45,6 +45,7 @@
import org.infinity.resource.text.QuestsPanel;
import org.infinity.resource.text.QuestsResource;
import org.infinity.util.Variables;
+import org.tinylog.Logger;
/**
* This resource is used to hold game information in save games. The GAM file does not store {@link AreResource area},
@@ -192,7 +193,7 @@ public JComponent getViewerTab(int index) {
try {
return new QuestsPanel(new QuestsResource().readQuests(), globalVars);
} catch (Exception ex) {
- ex.printStackTrace();
+ Logger.error(ex);
final StringWriter w = new StringWriter();
ex.printStackTrace(new PrintWriter(w));
return new JTextArea(w.toString());
diff --git a/src/org/infinity/resource/graphics/BamDecoder.java b/src/org/infinity/resource/graphics/BamDecoder.java
index b7efbbd95..ea60b2ce4 100644
--- a/src/org/infinity/resource/graphics/BamDecoder.java
+++ b/src/org/infinity/resource/graphics/BamDecoder.java
@@ -17,6 +17,7 @@
import org.infinity.resource.key.ResourceEntry;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* Common base class for handling BAM resources.
@@ -60,7 +61,7 @@ public static Type getType(ResourceEntry bamEntry) {
}
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
return retVal;
diff --git a/src/org/infinity/resource/graphics/BamResource.java b/src/org/infinity/resource/graphics/BamResource.java
index 7c1be00d9..ced009edf 100644
--- a/src/org/infinity/resource/graphics/BamResource.java
+++ b/src/org/infinity/resource/graphics/BamResource.java
@@ -80,6 +80,7 @@
import org.infinity.util.IntegerHashMap;
import org.infinity.util.io.FileManager;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
import tv.porst.jhexview.DataChangedEvent;
import tv.porst.jhexview.IDataChangedListener;
@@ -155,7 +156,7 @@ public BamResource(ResourceEntry entry) {
((BamV1Decoder.BamV1Control) bamControl).setTransparencyEnabled(transparencyEnabled);
}
} catch (Throwable t) {
- t.printStackTrace();
+ Logger.error(t);
decoder = null;
}
WindowBlocker.blockWindow(false);
@@ -274,7 +275,7 @@ public void actionPerformed(ActionEvent event) {
ByteBuffer buffer = Compressor.decompress(entry.getResourceBuffer());
ResourceFactory.exportResource(entry, buffer, entry.getResourceName(), panelMain.getTopLevelAncestor());
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
@@ -293,7 +294,7 @@ public void actionPerformed(ActionEvent event) {
ByteBuffer buffer = Compressor.compress(entry.getResourceBuffer(), "BAMC", "V1 ");
ResourceFactory.exportResource(entry, buffer, entry.getResourceName(), panelMain.getTopLevelAncestor());
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
@@ -357,7 +358,7 @@ public void propertyChange(PropertyChangeEvent event) {
l = null;
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
if (bamData != null) {
if (bamData.length > 0) {
@@ -398,7 +399,7 @@ public void stateChanged(ChangeEvent event) {
hexViewer.setCurrentOffset(0L);
panelRaw.add(hexViewer, BorderLayout.CENTER);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
} finally {
WindowBlocker.blockWindow(false);
}
@@ -846,13 +847,13 @@ public static String exportFrames(BamDecoder decoder, Path filePath, String file
counter++;
} catch (IOException e) {
failCounter++;
- System.err.println("Error writing frame #" + i);
+ Logger.warn("Error writing frame #{}", i);
}
image.flush();
image = null;
} else {
failCounter++;
- System.err.println("Skipping frame #" + i);
+ Logger.warn("Skipping frame #{}", i);
}
}
}
@@ -1236,7 +1237,7 @@ public List doInBackground() {
list.add(buf);
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
return list;
}
@@ -1286,7 +1287,7 @@ public boolean containsPvrzReference(int index) {
retVal = (curIndex == index);
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
return retVal;
diff --git a/src/org/infinity/resource/graphics/BamV1Decoder.java b/src/org/infinity/resource/graphics/BamV1Decoder.java
index 8a544d7ab..925cd71ae 100644
--- a/src/org/infinity/resource/graphics/BamV1Decoder.java
+++ b/src/org/infinity/resource/graphics/BamV1Decoder.java
@@ -19,6 +19,7 @@
import org.infinity.resource.Profile;
import org.infinity.resource.key.ResourceEntry;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* Handles BAM v1 resources (both BAMC and uncompressed BAM V1).
@@ -223,7 +224,7 @@ private void init() {
defaultControl.setMode(BamControl.Mode.SHARED);
defaultControl.setSharedPerCycle(false);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
close();
}
}
@@ -308,9 +309,8 @@ private void decodeFrame(BamControl control, int frameIdx, Image canvas) {
dstOfs += dstWidth - srcWidth;
}
} catch (Exception e) {
- System.err.printf("Error [%s]: input (offset=%d, size=%d), output (offset=%d, size=%d)\n",
- e.getClass().getName(), srcOfs, bamBuffer.limit(), dstOfs,
- bufferB != null ? bufferB.length : bufferI.length);
+ Logger.error("Error [{}]: input (offset={}, size={}), output (offset={}, size={})",
+ e.getClass().getName(), srcOfs, bamBuffer.limit(), dstOfs, bufferB != null ? bufferB.length : bufferI.length);
}
bufferB = null;
bufferI = null;
diff --git a/src/org/infinity/resource/graphics/BamV2Decoder.java b/src/org/infinity/resource/graphics/BamV2Decoder.java
index 459e6d9fe..95ed96639 100644
--- a/src/org/infinity/resource/graphics/BamV2Decoder.java
+++ b/src/org/infinity/resource/graphics/BamV2Decoder.java
@@ -26,6 +26,7 @@
import org.infinity.util.io.FileEx;
import org.infinity.util.io.FileManager;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* Handles BAM v2 resources.
@@ -220,7 +221,7 @@ private void init() {
defaultControl.setMode(BamControl.Mode.SHARED);
defaultControl.setSharedPerCycle(false);
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
close();
}
}
@@ -247,7 +248,7 @@ private PvrDecoder getPVR(int page) {
return PvrDecoder.loadPvr(entry);
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
return null;
}
@@ -466,7 +467,7 @@ private void decodeImage(ByteBuffer buffer, int ofsBlocks, int start, int count)
decoder = null;
srcImage = null;
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
}
diff --git a/src/org/infinity/resource/graphics/ColorConvert.java b/src/org/infinity/resource/graphics/ColorConvert.java
index 14d3673a6..4afeddf60 100644
--- a/src/org/infinity/resource/graphics/ColorConvert.java
+++ b/src/org/infinity/resource/graphics/ColorConvert.java
@@ -41,6 +41,7 @@
import org.infinity.util.io.FileEx;
import org.infinity.util.io.StreamUtils;
import org.infinity.util.tuples.Triple;
+import org.tinylog.Logger;
/**
* Contains a set of color-related static methods (little endian order only).
@@ -806,7 +807,7 @@ public static int[] loadPaletteBMP(ResourceEntry entry) throws Exception {
throw new Exception("Invalid BMP resource: " + entry.getResourceName());
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
throw new Exception("Unable to read BMP resource: " + entry.getResourceName());
}
} else {
@@ -840,7 +841,7 @@ public static int[] loadPalettePNG(Path file, boolean preserveAlpha) throws Exce
throw new Exception("Error loading palette from PNG file " + file.getFileName());
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
throw new Exception("Unable to read PNG file " + file.getFileName());
}
} else {
@@ -893,7 +894,7 @@ public static int[] loadPalettePAL(Path file) throws Exception {
throw new Exception("Invalid Windows palette file " + file.getFileName());
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
throw new Exception("Unable to read Windows palette file " + file.getFileName());
}
} else {
@@ -935,7 +936,7 @@ public static int[] loadPaletteACT(Path file) throws Exception {
throw new Exception("Invalid Adobe Photoshop palette file " + file.getFileName());
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
throw new Exception("Unable to read Adobe Photoshop palette file " + file.getFileName());
}
} else {
@@ -987,7 +988,7 @@ public static int[] loadPaletteBAM(ResourceEntry entry, boolean preserveAlpha) t
throw new Exception("Unsupport file type.");
}
} catch (IOException e) {
- e.printStackTrace();
+ Logger.error(e);
throw new Exception("Unable to read BAM resource: " + entry.getResourceName());
}
} else {
diff --git a/src/org/infinity/resource/graphics/MosDecoder.java b/src/org/infinity/resource/graphics/MosDecoder.java
index c3094e41f..00b1be05f 100644
--- a/src/org/infinity/resource/graphics/MosDecoder.java
+++ b/src/org/infinity/resource/graphics/MosDecoder.java
@@ -10,6 +10,7 @@
import org.infinity.resource.key.ResourceEntry;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* Common base class for handling MOS resources.
@@ -53,7 +54,7 @@ public static Type getType(ResourceEntry mosEntry) {
}
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
}
return retVal;
diff --git a/src/org/infinity/resource/graphics/MosResource.java b/src/org/infinity/resource/graphics/MosResource.java
index 017c6c2ea..507aa0045 100644
--- a/src/org/infinity/resource/graphics/MosResource.java
+++ b/src/org/infinity/resource/graphics/MosResource.java
@@ -61,6 +61,7 @@
import org.infinity.util.DynamicArray;
import org.infinity.util.IntegerHashMap;
import org.infinity.util.io.StreamUtils;
+import org.tinylog.Logger;
/**
* This resource describes static graphics in a tile based bitmap format. Such files are used for mini-maps and GUI
@@ -137,7 +138,7 @@ public void actionPerformed(ActionEvent event) {
buffer = Compressor.decompress(buffer);
ResourceFactory.exportResource(entry, buffer, entry.getResourceName(), panel.getTopLevelAncestor());
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
JOptionPane.showMessageDialog(panel.getTopLevelAncestor(), "Error while exporting " + entry, "Error",
JOptionPane.ERROR_MESSAGE);
}
@@ -156,7 +157,7 @@ public void actionPerformed(ActionEvent event) {
buffer = Compressor.compress(buffer, "MOSC", "V1 ");
ResourceFactory.exportResource(entry, buffer, entry.getResourceName(), panel.getTopLevelAncestor());
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
JOptionPane.showMessageDialog(panel.getTopLevelAncestor(), "Error while exporting " + entry, "Error",
JOptionPane.ERROR_MESSAGE);
}
@@ -181,7 +182,7 @@ public void actionPerformed(ActionEvent event) {
JOptionPane.ERROR_MESSAGE);
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
} else if (event.getSource() == miPvrzShow) {
if (lastBlockIndex >= 0) {
@@ -223,7 +224,7 @@ public void propertyChange(PropertyChangeEvent event) {
l = null;
}
} catch (Exception e) {
- e.printStackTrace();
+ Logger.error(e);
}
if (mosData != null) {
if (mosData.length > 0) {
@@ -439,7 +440,7 @@ private void showProperties() {
sb.append("