diff --git a/.gitattributes b/.gitattributes index eeb889e0ba6..280e683f5df 100644 --- a/.gitattributes +++ b/.gitattributes @@ -336,6 +336,7 @@ src/arcane/ui/util/GlowText.java svneol=native#text/plain src/arcane/ui/util/ImageUtil.java -text svneol=native#text/plain src/arcane/ui/util/ManaSymbols.java svneol=native#text/plain src/arcane/ui/util/UI.java svneol=native#text/plain +src/arcane/util/MultiplexOutputStream.java svneol=native#text/plain src/arcane/util/Util.java svneol=native#text/plain src/com/cloudgarden/layout/AnchorConstraint.java -text svneol=native#text/plain src/com/cloudgarden/layout/AnchorLayout.java -text svneol=native#text/plain diff --git a/src/arcane/util/MultiplexOutputStream.java b/src/arcane/util/MultiplexOutputStream.java new file mode 100644 index 00000000000..e2b1f870384 --- /dev/null +++ b/src/arcane/util/MultiplexOutputStream.java @@ -0,0 +1,28 @@ + +package arcane.util; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * An OutputStream that writes to multiple other OutputStreams. + */ +public class MultiplexOutputStream extends OutputStream { + private final OutputStream[] streams; + + public MultiplexOutputStream (OutputStream... streams) { + super(); + if (streams == null) throw new IllegalArgumentException("streams cannot be null."); + this.streams = streams; + } + + public void write (int b) throws IOException { + for (int i = 0; i < streams.length; i++) + streams[i].write(b); + } + + public void write (byte[] b, int off, int len) throws IOException { + for (int i = 0; i < streams.length; i++) + streams[i].write(b, off, len); + } +} diff --git a/src/forge/CardFactory_Auras.java b/src/forge/CardFactory_Auras.java index efe2dc5d81c..f1c0be63bf0 100644 --- a/src/forge/CardFactory_Auras.java +++ b/src/forge/CardFactory_Auras.java @@ -1385,7 +1385,7 @@ class CardFactory_Auras { if(AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) { card.enchantCard(c); - System.out.println("Enchanted: " + getTargetCard()); + Log.debug("Lifelink", "Enchanted: " + getTargetCard()); } }//resolve() };//SpellAbility @@ -1500,7 +1500,7 @@ class CardFactory_Auras { if (AllZone.GameAction.isCardInPlay(c) && CardFactoryUtil.canTarget(card, c)) { card.enchantCard(c); - System.out.println("Enchanted: " + getTargetCard()); + Log.debug("Fear", "Enchanted: " + getTargetCard()); } }//resolve() };//SpellAbility @@ -1728,7 +1728,7 @@ class CardFactory_Auras { final String type = getAuraType(card); final boolean curse = isCurseAura(card); if("" == type) { - System.out.println("Problem in generic Aura code - type is null"); + Log.error("Problem in generic Aura code - type is null"); } final SpellAbility spell = new Spell(card) { private static final long serialVersionUID = 4191777361540717307L; diff --git a/src/forge/Gui_DownloadPictures.java b/src/forge/Gui_DownloadPictures.java index 3615181e7ff..414a75631ea 100644 --- a/src/forge/Gui_DownloadPictures.java +++ b/src/forge/Gui_DownloadPictures.java @@ -40,6 +40,8 @@ import javax.swing.JTextField; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import com.esotericsoftware.minlog.Log; + import forge.error.ErrorViewer; import forge.properties.ForgeProps; import forge.properties.NewConstants; @@ -286,14 +288,7 @@ public class Gui_DownloadPictures extends DefaultBoundedRangeModel implements Ru out.flush(); out.close(); } catch(Exception ex) { - ErrorViewer.showError(ex, ForgeProps.getLocalized(ERRORS.OTHER), cards[card].name, - url); -// throw new RuntimeException("Gui_DownloadPictures : error 1 - " +ex); - int more = JOptionPane.showConfirmDialog(null, "Some error occured. Continue downloading pictures?", "Error", - JOptionPane.YES_NO_OPTION); - if (more == JOptionPane.NO_OPTION) { - break; - } + Log.error("HQ Pictures", "Error downloading pictures", ex); } }//for } diff --git a/src/forge/Gui_DownloadPictures_LQ.java b/src/forge/Gui_DownloadPictures_LQ.java index 7bcaa9e718e..64e8458164b 100644 --- a/src/forge/Gui_DownloadPictures_LQ.java +++ b/src/forge/Gui_DownloadPictures_LQ.java @@ -35,6 +35,8 @@ import javax.swing.JTextField; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import com.esotericsoftware.minlog.Log; + import forge.error.ErrorViewer; import forge.properties.ForgeProps; import forge.properties.NewConstants; @@ -237,14 +239,7 @@ public class Gui_DownloadPictures_LQ extends DefaultBoundedRangeModel implements out.flush(); out.close(); } catch(Exception ex) { - ErrorViewer.showError(ex, ForgeProps.getLocalized(ERRORS.OTHER), cards[card].name, - cards[card].url); -// throw new RuntimeException("Gui_DownloadPictures : error 1 - " +ex); - int more = JOptionPane.showConfirmDialog(null, "Some error occured. Continue downloading pictures?", "Error", - JOptionPane.YES_NO_OPTION); - if (more == JOptionPane.NO_OPTION) { - break; - } + Log.error("LQ Pictures", "Error downloading pictures", ex); } }//for } diff --git a/src/forge/Gui_NewGame.java b/src/forge/Gui_NewGame.java index 3383dc383f6..67086522c98 100644 --- a/src/forge/Gui_NewGame.java +++ b/src/forge/Gui_NewGame.java @@ -10,6 +10,12 @@ import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.io.PrintStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -42,6 +48,7 @@ import javax.swing.border.TitledBorder; import com.esotericsoftware.minlog.Log; import arcane.ui.util.ManaSymbols; +import arcane.util.MultiplexOutputStream; import net.miginfocom.swing.MigLayout; @@ -117,6 +124,15 @@ public class Gui_NewGame extends JFrame implements NewConstants, NewConstants.LA static public ForgePreferences preferences; public static void main(String[] args) { ExceptionHandler.registerErrorHandling(); + File logFile = new File("forge.log"); + logFile.delete(); + try { + OutputStream logFileStream = new BufferedOutputStream(new FileOutputStream(logFile)); + System.setOut(new PrintStream(new MultiplexOutputStream(System.out, logFileStream), true)); + System.setErr(new PrintStream(new MultiplexOutputStream(System.err, logFileStream), true)); + } catch (FileNotFoundException ex) { + ErrorViewer.showError(ex); + } try { preferences = new ForgePreferences("forge.preferences"); useLAFFonts.setSelected(preferences.lafFonts);