* all console output gets saved as forge.log and is deleted at next program execution

* cleanups
* downloading pictures errors are now logged and don't pop up error messages
This commit is contained in:
jendave
2011-08-06 05:25:43 +00:00
parent bc2f1e325b
commit dd60fa151d
6 changed files with 54 additions and 19 deletions

1
.gitattributes vendored
View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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;

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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);