switched logging to log4j

This commit is contained in:
BetaSteward 2011-05-20 23:26:37 -04:00
parent 5621b8a518
commit 89f6e18c90
12 changed files with 42 additions and 74 deletions

View file

@ -38,13 +38,9 @@ import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.*;
import java.util.List;
import java.util.logging.Logger;
import mage.client.MageFrame;
import mage.client.remote.Session;
import mage.util.Logging;
import mage.view.ChatMessage.MessageColor;
import mage.view.SeatView;
import mage.view.TableView;
import javax.swing.table.AbstractTableModel;
@ -54,8 +50,6 @@ import javax.swing.table.AbstractTableModel;
*/
public class ChatPanel extends javax.swing.JPanel {
private final static Logger logger = Logging.getLogger(ChatPanel.class.getName());
private UUID chatId;
private UUID clientId;
private Session session;

View file

@ -30,12 +30,10 @@ package mage.client.deckeditor;
import java.io.File;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import mage.cards.decks.DeckCardLists;
import mage.client.MageFrame;
import mage.util.Logging;
import org.apache.log4j.Logger;
/**
*
@ -43,7 +41,7 @@ import mage.util.Logging;
*/
public abstract class DeckImporterImpl implements DeckImporter {
private final static Logger logger = Logging.getLogger(DeckImporterImpl.class.getName());
private final static Logger logger = Logger.getLogger(DeckImporterImpl.class);
protected StringBuilder sbMessage = new StringBuilder();
protected int lineCount;
@ -67,13 +65,13 @@ public abstract class DeckImporterImpl implements DeckImporter {
}
catch (Exception ex) {
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error importing deck", JOptionPane.ERROR_MESSAGE);
logger.log(Level.SEVERE, null, ex);
logger.fatal(null, ex);
}
finally {
scanner.close();
}
} catch (Exception ex) {
logger.log(Level.SEVERE, null, ex);
logger.fatal(null, ex);
}
return deckList;
}

View file

@ -37,12 +37,10 @@ package mage.client.dialog;
import mage.client.*;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import mage.client.remote.Session;
import mage.sets.Sets;
import mage.util.Logging;
import org.apache.log4j.Logger;
/**
*
@ -50,7 +48,7 @@ import mage.util.Logging;
*/
public class JoinTableDialog extends MageDialog {
private final static Logger logger = Logging.getLogger(JoinTableDialog.class.getName());
private final static Logger logger = Logger.getLogger(JoinTableDialog.class);
private UUID tableId;
private UUID roomId;
@ -153,7 +151,7 @@ public class JoinTableDialog extends MageDialog {
}
private void handleError(Exception ex) {
logger.log(Level.SEVERE, "Error loading deck", ex);
logger.fatal("Error loading deck", ex);
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error loading deck.", "Error", JOptionPane.ERROR_MESSAGE);
}

View file

@ -41,10 +41,8 @@ import java.awt.EventQueue;
import java.awt.MenuComponent;
import java.awt.event.MouseEvent;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.SwingUtilities;
import mage.util.Logging;
import org.apache.log4j.Logger;
/**
*
@ -52,7 +50,7 @@ import mage.util.Logging;
*/
public class MageDialog extends javax.swing.JInternalFrame {
private final static Logger logger = Logging.getLogger(MageDialog.class.getName());
private final static Logger logger = Logger.getLogger(MageDialog.class);
protected boolean modal = false;
@ -92,9 +90,9 @@ public class MageDialog extends javax.swing.JInternalFrame {
}
});
} catch (InterruptedException ex) {
logger.log(Level.SEVERE, null, ex);
logger.fatal("MageDialog error", ex);
} catch (InvocationTargetException ex) {
logger.log(Level.SEVERE, null, ex);
logger.fatal("MageDialog error", ex);
}
}
}
@ -127,7 +125,7 @@ public class MageDialog extends javax.swing.JInternalFrame {
} else if (source instanceof MenuComponent) {
((MenuComponent) source).dispatchEvent(event);
} else {
logger.warning("Unable to dispatch: " + event);
logger.warn("Unable to dispatch: " + event);
}
}
}

View file

@ -40,8 +40,6 @@ import mage.client.*;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.SpinnerNumberModel;
@ -54,9 +52,9 @@ import mage.client.util.Event;
import mage.client.util.Listener;
import mage.game.match.MatchOptions;
import mage.sets.Sets;
import mage.util.Logging;
import mage.view.GameTypeView;
import mage.view.TableView;
import org.apache.log4j.Logger;
/**
*
@ -64,7 +62,7 @@ import mage.view.TableView;
*/
public class NewTableDialog extends MageDialog {
private final static Logger logger = Logging.getLogger(NewTableDialog.class.getName());
private final static Logger logger = Logger.getLogger(NewTableDialog.class);
private TableView table;
private UUID playerId;
@ -406,7 +404,7 @@ public class NewTableDialog extends MageDialog {
}
private void handleError(Exception ex) {
logger.log(Level.SEVERE, "Error loading deck", ex);
logger.fatal("Error loading deck", ex);
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error loading deck.", "Error", JOptionPane.ERROR_MESSAGE);
}

View file

@ -37,7 +37,6 @@ package mage.client.dialog;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
@ -53,9 +52,9 @@ import mage.game.draft.DraftOptions.TimingOption;
import mage.game.tournament.LimitedOptions;
import mage.game.tournament.TournamentOptions;
import mage.sets.Sets;
import mage.util.Logging;
import mage.view.TableView;
import mage.view.TournamentTypeView;
import org.apache.log4j.Logger;
/**
*
@ -63,7 +62,7 @@ import mage.view.TournamentTypeView;
*/
public class NewTournamentDialog extends MageDialog {
private final static Logger logger = Logging.getLogger(NewTournamentDialog.class.getName());
private final static Logger logger = Logger.getLogger(NewTournamentDialog.class);
private TableView table;
private UUID playerId;

View file

@ -42,8 +42,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.border.Border;
@ -63,8 +61,8 @@ import mage.client.remote.Session;
import mage.client.util.Config;
import mage.client.util.GameManager;
import mage.client.util.PhaseManager;
import mage.util.Logging;
import mage.view.*;
import org.apache.log4j.Logger;
/**
*
@ -72,7 +70,7 @@ import mage.view.*;
*/
public class GamePanel extends javax.swing.JPanel {
private final static Logger logger = Logging.getLogger(GamePanel.class.getName());
private final static Logger logger = Logger.getLogger(GamePanel.class);
private Map<UUID, PlayAreaPanel> players = new HashMap<UUID, PlayAreaPanel>();
private Map<UUID, ExileZoneDialog> exiles = new HashMap<UUID, ExileZoneDialog>();
@ -204,7 +202,7 @@ public class GamePanel extends javax.swing.JPanel {
public void hideGame() {
this.chatPanel.disconnect();
this.players.clear();
logger.log(Level.FINE, "players clear.");
logger.debug("players clear.");
this.pnlBattlefield.removeAll();
combat.hideDialog();
Component c = this.getParent();
@ -216,11 +214,11 @@ public class GamePanel extends javax.swing.JPanel {
}
public synchronized void init(GameView game) {
logger.warning("init.");
logger.warn("init.");
combat.init(gameId, bigCard);
combat.setLocation(500, 300);
addPlayers(game);
logger.warning("added players.");
logger.warn("added players.");
updateGame(game);
}
@ -311,11 +309,11 @@ public class GamePanel extends javax.swing.JPanel {
if (players.containsKey(player.getPlayerId())) {
players.get(player.getPlayerId()).update(player);
} else {
logger.warning("Couldn't find player.");
logger.warning(" uuid:" + player.getPlayerId());
logger.warning(" players:");
logger.warn("Couldn't find player.");
logger.warn(" uuid:" + player.getPlayerId());
logger.warn(" players:");
for (PlayAreaPanel p : players.values()) {
logger.warning(""+p);
logger.warn(""+p);
}
}
//} else {

View file

@ -7,12 +7,9 @@ import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComponent;
import mage.cards.CardDimensions;
import mage.cards.MageCard;
import mage.cards.MagePermanent;
import mage.cards.action.impl.EmptyCallback;
@ -28,17 +25,17 @@ import mage.interfaces.PluginException;
import mage.interfaces.plugin.CardPlugin;
import mage.interfaces.plugin.CounterPlugin;
import mage.interfaces.plugin.ThemePlugin;
import mage.util.Logging;
import mage.view.CardView;
import mage.view.PermanentView;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import org.apache.log4j.Logger;
public class Plugins implements MagePlugins {
private final static MagePlugins fINSTANCE = new Plugins();
private final static Logger logger = Logging.getLogger(Plugins.class.getName());
private final static Logger logger = Logger.getLogger(Plugins.class);
private static PluginManager pm;
private ThemePlugin themePlugin = null;
@ -54,13 +51,13 @@ public class Plugins implements MagePlugins {
@Override
public void loadPlugins() {
logger.log(Level.INFO, "Loading plugins...");
logger.info("Loading plugins...");
pm = PluginManagerFactory.createPluginManager();
pm.addPluginsFrom(new File(Constants.PLUGINS_DIRECTORY).toURI());
this.cardPlugin = pm.getPlugin(CardPlugin.class);
this.counterPlugin = pm.getPlugin(CounterPlugin.class);
this.themePlugin = pm.getPlugin(ThemePlugin.class);
logger.log(Level.INFO, "Done.");
logger.info("Done.");
}
@Override
@ -129,7 +126,7 @@ public class Plugins implements MagePlugins {
try {
return this.counterPlugin.getGamePlayed();
} catch (PluginException e) {
logger.log(Level.SEVERE, e.getMessage());
logger.fatal(e.getMessage());
throw new RuntimeException(e);
}
}
@ -144,7 +141,7 @@ public class Plugins implements MagePlugins {
try {
this.counterPlugin.addGamePlayed();
} catch (PluginException e) {
logger.log(Level.SEVERE, e.getMessage());
logger.fatal(e.getMessage());
throw new RuntimeException(e);
}
}

View file

@ -37,18 +37,15 @@ package mage.client.table;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.UUID;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import mage.cards.decks.DeckCardLists;
import mage.client.MageFrame;
import mage.client.remote.Session;
import mage.client.util.Config;
import mage.client.util.Event;
import mage.client.util.Listener;
import mage.sets.Sets;
import mage.util.Logging;
/**
*
@ -56,8 +53,6 @@ import mage.util.Logging;
*/
public class TablePlayerPanel extends javax.swing.JPanel {
private final static Logger logger = Logging.getLogger(TablePlayerPanel.class.getName());
protected PlayerTypeEventSource playerTypeEventSource = new PlayerTypeEventSource();
private Session session;

View file

@ -32,11 +32,9 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import mage.cards.CardDimensions;
import mage.util.Logging;
import org.apache.log4j.Logger;
/**
*
@ -44,7 +42,7 @@ import mage.util.Logging;
*/
public class Config {
private final static Logger logger = Logging.getLogger(Config.class.getName());
private final static Logger logger = Logger.getLogger(Config.class);
public static final String remoteServer;
public static final String serverName;
@ -62,7 +60,7 @@ public class Config {
try {
p.load(new FileInputStream(new File("config/config.properties")));
} catch (IOException ex) {
logger.log(Level.SEVERE, null, ex);
logger.fatal("Config error ", ex);
}
serverName = p.getProperty("server-name");
port = Integer.parseInt(p.getProperty("port"));

View file

@ -28,11 +28,9 @@
package mage.client.util;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import mage.client.MageFrame;
import mage.util.Logging;
import org.apache.log4j.Logger;
/**
*
@ -40,7 +38,7 @@ import mage.util.Logging;
*/
public class EDTExceptionHandler implements Thread.UncaughtExceptionHandler {
private final static Logger logger = Logging.getLogger(EDTExceptionHandler.class.getName());
private final static Logger logger = Logger.getLogger(EDTExceptionHandler.class);
@Override
public void uncaughtException(Thread t, Throwable e) {
@ -49,7 +47,7 @@ public class EDTExceptionHandler implements Thread.UncaughtExceptionHandler {
public void handle(Throwable throwable) {
try {
logger.log(Level.SEVERE, null, throwable);
logger.fatal(null, throwable);
JOptionPane.showMessageDialog(MageFrame.getDesktop(), throwable, "MAGE Client UI error", JOptionPane.ERROR_MESSAGE);
} catch (Throwable t) {}
}

View file

@ -1,18 +1,15 @@
package mage.client.game;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.SwingUtilities;
import mage.client.MageFrame;
import mage.client.components.MageComponents;
import mage.client.components.MageUI;
import mage.util.Logging;
import org.apache.log4j.Logger;
public class StartMultiGamesTest {
private final static Logger logger = Logging.getLogger(StartMultiGamesTest.class.getName());
private final static Logger logger = Logger.getLogger(StartMultiGamesTest.class);
/**
* Amount of games to be started from this test.
@ -34,7 +31,7 @@ public class StartMultiGamesTest {
public void startMultiGames() throws Exception {
for (int i = 0; i < GAME_START_COUNT; i++) {
logger.log(Level.INFO, "Starting game");
logger.info("Starting game");
startGame();
}
}
@ -43,7 +40,7 @@ public class StartMultiGamesTest {
frame = null;
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
logger.log(Level.SEVERE, null, e);
logger.fatal(null, e);
}
});
SwingUtilities.invokeLater(new Runnable() {