Switch to new logging API.

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@608 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2008-05-27 20:00:28 +00:00
parent 3b7ef57a20
commit a133c7c693
91 changed files with 486 additions and 722 deletions
+4 -43
View File
@@ -21,52 +21,13 @@
package com.threerings.micasa;
import com.samskivert.util.Logger;
/**
* A placeholder class that contains a reference to the log object used by
* the MiCasa package. This is a useful pattern to use when using the
* samskivert logging facilities. One creates a top-level class like this
* one that instantiates a log object with an name that identifies log
* messages from that package and then provides static methods that
* generate log messages using that instance. Then, classes in that
* package need only import the log wrapper class and can easily use it to
* generate log messages. For example:
*
* <pre>
* import com.threerings.micasa.Log;
* // ...
* Log.warning("All hell is breaking loose!");
* // ...
* </pre>
*
* @see com.samskivert.util.Log
* Contains a reference to the log object used by the MiCasa package.
*/
public class Log
{
/** The static log instance configured for use by this package. */
public static com.samskivert.util.Log log =
new com.samskivert.util.Log("micasa");
/** Convenience function. */
public static void debug (String message)
{
log.debug(message);
}
/** Convenience function. */
public static void info (String message)
{
log.info(message);
}
/** Convenience function. */
public static void warning (String message)
{
log.warning(message);
}
/** Convenience function. */
public static void logStackTrace (Throwable t)
{
log.logStackTrace(com.samskivert.util.Log.WARNING, t);
}
public static Logger log = Logger.getLogger("com.threerings.micasa");
}
@@ -64,7 +64,7 @@ import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.util.CrowdContext;
import com.threerings.micasa.Log;
import static com.threerings.micasa.Log.log;
public class ChatPanel extends JPanel
implements ActionListener, ChatDisplay, OccupantObserver, PlaceView
@@ -267,7 +267,7 @@ public class ChatPanel extends JPanel
return true;
} else {
Log.warning("Received unknown message type [message=" +
log.warning("Received unknown message type [message=" +
message + "].");
return false;
}
@@ -287,7 +287,7 @@ public class ChatPanel extends JPanel
try {
doc.insertString(doc.getLength(), text, style);
} catch (BadLocationException ble) {
Log.warning("Unable to insert text!? [error=" + ble + "].");
log.warning("Unable to insert text!? [error=" + ble + "].");
}
}
@@ -29,10 +29,11 @@ import com.threerings.presents.client.SessionObserver;
import com.threerings.crowd.data.BodyObject;
import com.threerings.micasa.Log;
import com.threerings.micasa.data.MiCasaBootstrapData;
import com.threerings.micasa.util.MiCasaContext;
import static com.threerings.micasa.Log.log;
/**
* Responsible for top-level control of the client user interface.
*/
@@ -68,7 +69,7 @@ public class ClientController extends Controller
return true;
}
Log.info("Unhandled action: " + action);
log.info("Unhandled action: " + action);
return false;
}
@@ -81,7 +82,7 @@ public class ClientController extends Controller
// documentation inherited
public void clientDidLogon (Client client)
{
Log.info("Client did logon [client=" + client + "].");
log.info("Client did logon [client=" + client + "].");
// keep the body object around for stuff
_body = (BodyObject)client.getClientObject();
@@ -94,14 +95,14 @@ public class ClientController extends Controller
try {
jumpOidStr = System.getProperty("jumpoid");
} catch (SecurityException se) {
Log.info("Not checking for jumpOid as we're in an applet.");
log.info("Not checking for jumpOid as we're in an applet.");
}
if (jumpOidStr != null) {
try {
moveOid = Integer.parseInt(jumpOidStr);
} catch (NumberFormatException nfe) {
Log.warning("Invalid jump oid [oid=" + jumpOidStr +
log.warning("Invalid jump oid [oid=" + jumpOidStr +
", err=" + nfe + "].");
}
@@ -131,7 +132,7 @@ public class ClientController extends Controller
// documentation inherited
public void clientDidLogoff (Client client)
{
Log.info("Client did logoff [client=" + client + "].");
log.info("Client did logoff [client=" + client + "].");
// reinstate the logon panel
_frame.setPanel(_logonPanel);
@@ -29,7 +29,7 @@ import com.threerings.util.Name;
import com.threerings.presents.client.Client;
import com.threerings.presents.net.UsernamePasswordCreds;
import com.threerings.micasa.Log;
import static com.threerings.micasa.Log.log;
/**
* The micasa app is the main point of entry for the MiCasa client
@@ -58,9 +58,8 @@ public class MiCasaApp
try {
_client = (MiCasaClient)Class.forName(cclass).newInstance();
} catch (Exception e) {
Log.warning("Unable to instantiate client class " +
"[cclass=" + cclass + "].");
Log.logStackTrace(e);
log.warning("Unable to instantiate client class " +
"[cclass=" + cclass + "].", e);
}
// initialize our client instance
@@ -76,7 +75,7 @@ public class MiCasaApp
Client client = _client.getContext().getClient();
Log.info("Using [server=" + server + ".");
log.info("Using [server=" + server + ".");
client.setServer(server, Client.DEFAULT_SERVER_PORTS);
// configure the client with some credentials and logon
@@ -102,8 +101,7 @@ public class MiCasaApp
// initialize the app
app.init();
} catch (IOException ioe) {
Log.warning("Error initializing application.");
Log.logStackTrace(ioe);
log.warning("Error initializing application.", ioe);
}
// and run it
@@ -31,7 +31,7 @@ import com.threerings.presents.client.Client;
import com.threerings.presents.client.ClientAdapter;
import com.threerings.presents.net.UsernamePasswordCreds;
import com.threerings.micasa.Log;
import static com.threerings.micasa.Log.log;
/**
* The MiCasa applet is used to make MiCasa games available via the web
@@ -74,8 +74,7 @@ public class MiCasaApplet extends Applet
});
} catch (IOException ioe) {
Log.warning("Unable to create client.");
Log.logStackTrace(ioe);
log.warning("Unable to create client.", ioe);
}
}
@@ -32,9 +32,10 @@ import com.threerings.crowd.util.CrowdContext;
import com.threerings.parlor.client.*;
import com.threerings.parlor.game.data.GameConfig;
import com.threerings.micasa.Log;
import com.threerings.micasa.util.MiCasaContext;
import static com.threerings.micasa.Log.log;
public class LobbyController extends PlaceController
implements InvitationHandler, InvitationResponseObserver
{
@@ -71,8 +72,7 @@ public class LobbyController extends PlaceController
_ctx.getParlorDirector().invite(
new Name(invitee), config, this);
} catch (Exception e) {
Log.warning("Error instantiating game config.");
Log.logStackTrace(e);
log.warning("Error instantiating game config.", e);
}
}
@@ -84,7 +84,7 @@ public class LobbyController extends PlaceController
// documentation inherited from interface
public void invitationReceived (Invitation invite)
{
Log.info("Invitation received [invite=" + invite + "].");
log.info("Invitation received [invite=" + invite + "].");
// accept the invitation. we're game...
invite.accept();
@@ -93,26 +93,26 @@ public class LobbyController extends PlaceController
// documentation inherited from interface
public void invitationCancelled (Invitation invite)
{
Log.info("Invitation cancelled " + invite + ".");
log.info("Invitation cancelled " + invite + ".");
}
// documentation inherited from interface
public void invitationAccepted (Invitation invite)
{
Log.info("Invitation accepted " + invite + ".");
log.info("Invitation accepted " + invite + ".");
}
// documentation inherited from interface
public void invitationRefused (Invitation invite, String message)
{
Log.info("Invitation refused [invite=" + invite +
log.info("Invitation refused [invite=" + invite +
", message=" + message + "].");
}
// documentation inherited from interface
public void invitationCountered (Invitation invite, GameConfig config)
{
Log.info("Invitation countered [invite=" + invite +
log.info("Invitation countered [invite=" + invite +
", config=" + config + "].");
}
@@ -26,7 +26,8 @@ import com.samskivert.util.StringUtil;
import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.PlaceManager;
import com.threerings.micasa.Log;
import static com.threerings.micasa.Log.log;
/**
* Takes care of the server side of a particular lobby.
@@ -48,7 +49,7 @@ public class LobbyManager extends PlaceManager
// let the lobby registry know that we're up and running
lobreg.lobbyReady(_plobj.getOid(), _gameIdent, _name);
Log.info("Lobby manager initialized [ident=" + _gameIdent +
log.info("Lobby manager initialized [ident=" + _gameIdent +
", name=" + _name + "].");
}
@@ -31,12 +31,13 @@ import com.threerings.presents.server.InvocationManager;
import com.threerings.crowd.data.BodyObject;
import com.threerings.micasa.Log;
import com.threerings.micasa.lobby.LobbyService.CategoriesListener;
import com.threerings.micasa.lobby.LobbyService.LobbiesListener;
import com.threerings.micasa.server.MiCasaConfig;
import com.threerings.micasa.server.MiCasaServer;
import static com.threerings.micasa.Log.log;
/**
* The lobby registry is the primary class that coordinates the lobby services on the client. It
* sets up the necessary invocation services and keeps track of the lobbies in operation on the
@@ -101,7 +102,7 @@ public class LobbyRegistry
String[] lmgrs = null;
lmgrs = MiCasaConfig.config.getValue(LOBIDS_KEY, lmgrs);
if (lmgrs == null || lmgrs.length == 0) {
Log.warning("No lobbies specified in config file (via '" +
log.warning("No lobbies specified in config file (via '" +
LOBIDS_KEY + "' parameter).");
} else {
@@ -145,7 +146,7 @@ public class LobbyRegistry
lobmgr.init(this, props);
} catch (Exception e) {
Log.warning("Unable to create lobby manager [lobbyId=" + lobbyId +
log.warning("Unable to create lobby manager [lobbyId=" + lobbyId +
", error=" + e + "].");
}
}
@@ -239,7 +240,7 @@ public class LobbyRegistry
_lobbies.put(category, catlist);
}
catlist.add(record);
Log.info("Registered lobby [cat=" + category + ", record=" + record + "].");
log.info("Registered lobby [cat=" + category + ", record=" + record + "].");
}
/** A table containing references to all of our lobby records (in the form of category
@@ -31,9 +31,10 @@ import javax.swing.*;
import com.threerings.crowd.data.PlaceObject;
import com.threerings.micasa.Log;
import com.threerings.micasa.util.MiCasaContext;
import static com.threerings.micasa.Log.log;
/**
* The lobby selector displays a drop-down box listing the categories of
* lobbies available on this server and when a category is selected, it
@@ -141,7 +142,7 @@ public class LobbySelector extends JPanel
// documentation inherited from interface
public void requestFailed (String reason)
{
Log.info("Request failed [reason=" + reason + "].");
log.info("Request failed [reason=" + reason + "].");
// clear out our pending category indicator in case this was a
// failed getLobbies() request
@@ -166,7 +167,7 @@ public class LobbySelector extends JPanel
_lservice.getLobbies(_ctx.getClient(), category, this);
} else {
Log.info("Ignoring category select request because " +
log.info("Ignoring category select request because " +
"one is outstanding [pcat=" + _pendingCategory +
", newcat=" + category + "].");
}
@@ -184,7 +185,7 @@ public class LobbySelector extends JPanel
// otherwise request that we go there
_ctx.getLocationDirector().moveTo(lobby.placeOid);
Log.info("Entering lobby " + lobby + ".");
log.info("Entering lobby " + lobby + ".");
}
@@ -42,9 +42,10 @@ import com.threerings.parlor.client.TableDirector;
import com.threerings.parlor.client.SeatednessObserver;
import com.threerings.parlor.data.Table;
import com.threerings.micasa.Log;
import com.threerings.micasa.util.MiCasaContext;
import static com.threerings.micasa.Log.log;
/**
* A table item displays the user interface for a single table (whether it
* be in-play or still being matchmade).
@@ -195,7 +196,7 @@ public class TableItem
// sanity check
if (position == -1) {
Log.warning("Unable to figure out what position a <join> " +
log.warning("Unable to figure out what position a <join> " +
"click came from [event=" + event + "].");
} else {
// otherwise, request to join the table at this position
@@ -211,7 +212,7 @@ public class TableItem
_ctx.getLocationDirector().moveTo(table.gameOid);
} else {
Log.warning("Received unknown action [event=" + event + "].");
log.warning("Received unknown action [event=" + event + "].");
}
}
@@ -36,7 +36,6 @@ import com.samskivert.swing.HGroupLayout;
import com.samskivert.swing.VGroupLayout;
import com.samskivert.swing.util.SwingUtil;
import com.threerings.micasa.Log;
import com.threerings.micasa.lobby.LobbyConfig;
import com.threerings.micasa.util.MiCasaContext;
@@ -52,6 +51,8 @@ import com.threerings.parlor.game.data.GameConfig;
import com.threerings.crowd.client.PlaceView;
import com.threerings.crowd.data.PlaceObject;
import static com.threerings.micasa.Log.log;
/**
* A view that displays the tables in a table lobby. It displays two
* separate lists, one of tables being matchmade and another of games in
@@ -103,7 +104,7 @@ public class TableListView extends JPanel
_tableFigger = gconfig.createTableConfigurator();
if (_tableFigger == null) {
Log.warning("Game config has not been set up to work with " +
log.warning("Game config has not been set up to work with " +
"tables: it needs to return non-null from " +
"createTableConfigurator().");
// let's just wait until we throw an NPE below
@@ -123,9 +124,8 @@ public class TableListView extends JPanel
panel.add(_create, VGroupLayout.FIXED);
} catch (Exception e) {
Log.warning("Unable to create configurator interface " +
"[config=" + gconfig + "].");
Log.logStackTrace(e);
log.warning("Unable to create configurator interface " +
"[config=" + gconfig + "].", e);
// stick something in the UI to let them know we're hosed
panel.add(new JLabel("Aiya! Can't create tables. " +
@@ -174,7 +174,7 @@ public class TableListView extends JPanel
// documentation inherited
public void tableAdded (Table table)
{
Log.info("Table added [table=" + table + "].");
log.info("Table added [table=" + table + "].");
// create a table item for this table and insert it into the
// appropriate list
@@ -186,12 +186,12 @@ public class TableListView extends JPanel
// documentation inherited
public void tableUpdated (Table table)
{
Log.info("Table updated [table=" + table + "].");
log.info("Table updated [table=" + table + "].");
// locate the table item associated with this table
TableItem item = getTableItem(table.tableId);
if (item == null) {
Log.warning("Received table updated notification for " +
log.warning("Received table updated notification for " +
"unknown table [table=" + table + "].");
return;
}
@@ -212,12 +212,12 @@ public class TableListView extends JPanel
// documentation inherited
public void tableRemoved (int tableId)
{
Log.info("Table removed [tableId=" + tableId + "].");
log.info("Table removed [tableId=" + tableId + "].");
// locate the table item associated with this table
TableItem item = getTableItem(tableId);
if (item == null) {
Log.warning("Received table removed notification for " +
log.warning("Received table removed notification for " +
"unknown table [tableId=" + tableId + "].");
return;
}
@@ -32,9 +32,10 @@ import com.threerings.crowd.server.CrowdServer;
import com.threerings.parlor.server.ParlorManager;
import com.threerings.micasa.Log;
import com.threerings.micasa.lobby.LobbyRegistry;
import static com.threerings.micasa.Log.log;
/**
* This class is the main entry point and general organizer of everything
* that goes on in the MiCasa game server process.
@@ -72,7 +73,7 @@ public class MiCasaServer extends CrowdServer
// initialize the lobby registry
lobreg.init(invmgr);
Log.info("MiCasa server initialized.");
log.info("MiCasa server initialized.");
}
public static void main (String[] args)
@@ -82,8 +83,7 @@ public class MiCasaServer extends CrowdServer
server.init();
server.run();
} catch (Exception e) {
Log.warning("Unable to initialize server.");
Log.logStackTrace(e);
log.warning("Unable to initialize server.", e);
}
}
}
@@ -34,11 +34,12 @@ import com.threerings.presents.client.Client;
import com.threerings.presents.client.ClientAdapter;
import com.threerings.presents.net.UsernamePasswordCreds;
import com.threerings.micasa.Log;
import com.threerings.micasa.simulator.data.SimulatorInfo;
import com.threerings.micasa.simulator.server.SimpleServer;
import com.threerings.micasa.simulator.server.SimulatorServer;
import static com.threerings.micasa.Log.log;
/**
* The simulator application is a test harness to facilitate development
* and debugging of games.
@@ -71,12 +72,12 @@ public class SimulatorApp
try {
run();
} catch (Exception e) {
Log.warning("Simulator initialization failed " +
log.warning("Simulator initialization failed " +
"[e=" + e + "].");
}
}
public void requestFailed (Exception e) {
Log.warning("Simulator initialization failed [e=" + e + "].");
log.warning("Simulator initialization failed [e=" + e + "].");
}
});
@@ -119,13 +120,13 @@ public class SimulatorApp
// start up the client
Client client = _client.getParlorContext().getClient();
Log.info("Connecting to localhost.");
log.info("Connecting to localhost.");
client.setServer("localhost", Client.DEFAULT_SERVER_PORTS);
// we want to exit when we logged off or failed to log on
client.addClientObserver(new ClientAdapter() {
public void clientFailedToLogon (Client c, Exception cause) {
Log.info("Client failed to logon: " + cause);
log.info("Client failed to logon: " + cause);
System.exit(0);
}
public void clientDidLogoff (Client c) {
@@ -171,8 +172,7 @@ public class SimulatorApp
try {
app.start(args);
} catch (Exception e) {
Log.warning("Error starting up application.");
Log.logStackTrace(e);
log.warning("Error starting up application.", e);
}
}
@@ -32,9 +32,10 @@ import com.threerings.crowd.data.BodyObject;
import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.util.ParlorContext;
import com.threerings.micasa.Log;
import com.threerings.micasa.simulator.data.SimulatorInfo;
import static com.threerings.micasa.Log.log;
/**
* Responsible for top-level control of the simulator client user interface.
*/
@@ -73,7 +74,7 @@ public class SimulatorController extends Controller
return true;
}
Log.info("Unhandled action: " + action);
log.info("Unhandled action: " + action);
return false;
}
@@ -86,7 +87,7 @@ public class SimulatorController extends Controller
// documentation inherited
public void clientDidLogon (Client client)
{
Log.info("Client did logon [client=" + client + "].");
log.info("Client did logon [client=" + client + "].");
// keep the body object around for stuff
_body = (BodyObject)client.getClientObject();
@@ -110,7 +111,7 @@ public class SimulatorController extends Controller
// straightaway
} catch (Exception e) {
Log.warning("Failed to instantiate game config [class=" + _info.gameConfigClass +
log.warning("Failed to instantiate game config [class=" + _info.gameConfigClass +
", error=" + e + "].");
}
}
@@ -125,7 +126,7 @@ public class SimulatorController extends Controller
// documentation inherited
public void clientDidLogoff (Client client)
{
Log.info("Client did logoff [client=" + client + "].");
log.info("Client did logoff [client=" + client + "].");
}
protected ParlorContext _ctx;
@@ -42,7 +42,7 @@ import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.game.data.GameObject;
import com.threerings.parlor.game.server.GameManager;
import com.threerings.micasa.Log;
import static com.threerings.micasa.Log.log;
/**
* The simulator manager is responsible for handling the simulator services on the server side.
@@ -103,8 +103,7 @@ public class SimulatorManager
_gmgr = (GameManager)_plreg.createPlace(config);
} catch (Exception e) {
Log.warning("Unable to create game manager [e=" + e + "].");
Log.logStackTrace(e);
log.warning("Unable to create game manager [e=" + e + "].", e);
return;
}
@@ -136,7 +135,7 @@ public class SimulatorManager
}
}
public void resolutionFailed (Name username, Exception cause) {
Log.warning("Unable to create simulant body object [error=" + cause + "].");
log.warning("Unable to create simulant body object [error=" + cause + "].");
}
};
@@ -160,7 +159,7 @@ public class SimulatorManager
try {
sim = (Simulant)Class.forName(_simClass).newInstance();
} catch (Exception e) {
Log.warning("Unable to create simulant " +
log.warning("Unable to create simulant " +
"[class=" + _simClass + "].");
return;
}
@@ -177,7 +176,7 @@ public class SimulatorManager
try {
_plreg.locprov.moveTo(bobj, _gobj.getOid());
} catch (Exception e) {
Log.warning("Failed to move simulant into room " +
log.warning("Failed to move simulant into room " +
"[e=" + e + "].");
return;
}
@@ -27,7 +27,7 @@ import com.threerings.presents.server.InvocationProvider;
import com.threerings.crowd.data.BodyObject;
import com.threerings.parlor.game.data.GameConfig;
import com.threerings.micasa.Log;
import static com.threerings.micasa.Log.log;
/**
* The simulator provider handles game creation requests on the server
@@ -50,7 +50,7 @@ public class SimulatorProvider
public void createGame (ClientObject caller, GameConfig config,
String simClass, int playerCount)
{
Log.info("handleCreateGameRequest [caller=" + caller.who() +
log.info("handleCreateGameRequest [caller=" + caller.who() +
", config=" + config + ", simClass=" + simClass +
", playerCount=" + playerCount + "].");