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; package com.threerings.micasa;
import com.samskivert.util.Logger;
/** /**
* A placeholder class that contains a reference to the log object used by * Contains a reference to the log object used by the MiCasa package.
* 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
*/ */
public class Log public class Log
{ {
/** The static log instance configured for use by this package. */ /** The static log instance configured for use by this package. */
public static com.samskivert.util.Log log = public static Logger log = Logger.getLogger("com.threerings.micasa");
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);
}
} }
@@ -64,7 +64,7 @@ import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.util.CrowdContext; import com.threerings.crowd.util.CrowdContext;
import com.threerings.micasa.Log; import static com.threerings.micasa.Log.log;
public class ChatPanel extends JPanel public class ChatPanel extends JPanel
implements ActionListener, ChatDisplay, OccupantObserver, PlaceView implements ActionListener, ChatDisplay, OccupantObserver, PlaceView
@@ -267,7 +267,7 @@ public class ChatPanel extends JPanel
return true; return true;
} else { } else {
Log.warning("Received unknown message type [message=" + log.warning("Received unknown message type [message=" +
message + "]."); message + "].");
return false; return false;
} }
@@ -287,7 +287,7 @@ public class ChatPanel extends JPanel
try { try {
doc.insertString(doc.getLength(), text, style); doc.insertString(doc.getLength(), text, style);
} catch (BadLocationException ble) { } 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.crowd.data.BodyObject;
import com.threerings.micasa.Log;
import com.threerings.micasa.data.MiCasaBootstrapData; import com.threerings.micasa.data.MiCasaBootstrapData;
import com.threerings.micasa.util.MiCasaContext; import com.threerings.micasa.util.MiCasaContext;
import static com.threerings.micasa.Log.log;
/** /**
* Responsible for top-level control of the client user interface. * Responsible for top-level control of the client user interface.
*/ */
@@ -68,7 +69,7 @@ public class ClientController extends Controller
return true; return true;
} }
Log.info("Unhandled action: " + action); log.info("Unhandled action: " + action);
return false; return false;
} }
@@ -81,7 +82,7 @@ public class ClientController extends Controller
// documentation inherited // documentation inherited
public void clientDidLogon (Client client) 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 // keep the body object around for stuff
_body = (BodyObject)client.getClientObject(); _body = (BodyObject)client.getClientObject();
@@ -94,14 +95,14 @@ public class ClientController extends Controller
try { try {
jumpOidStr = System.getProperty("jumpoid"); jumpOidStr = System.getProperty("jumpoid");
} catch (SecurityException se) { } 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) { if (jumpOidStr != null) {
try { try {
moveOid = Integer.parseInt(jumpOidStr); moveOid = Integer.parseInt(jumpOidStr);
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
Log.warning("Invalid jump oid [oid=" + jumpOidStr + log.warning("Invalid jump oid [oid=" + jumpOidStr +
", err=" + nfe + "]."); ", err=" + nfe + "].");
} }
@@ -131,7 +132,7 @@ public class ClientController extends Controller
// documentation inherited // documentation inherited
public void clientDidLogoff (Client client) public void clientDidLogoff (Client client)
{ {
Log.info("Client did logoff [client=" + client + "]."); log.info("Client did logoff [client=" + client + "].");
// reinstate the logon panel // reinstate the logon panel
_frame.setPanel(_logonPanel); _frame.setPanel(_logonPanel);
@@ -29,7 +29,7 @@ import com.threerings.util.Name;
import com.threerings.presents.client.Client; import com.threerings.presents.client.Client;
import com.threerings.presents.net.UsernamePasswordCreds; 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 * The micasa app is the main point of entry for the MiCasa client
@@ -58,9 +58,8 @@ public class MiCasaApp
try { try {
_client = (MiCasaClient)Class.forName(cclass).newInstance(); _client = (MiCasaClient)Class.forName(cclass).newInstance();
} catch (Exception e) { } catch (Exception e) {
Log.warning("Unable to instantiate client class " + log.warning("Unable to instantiate client class " +
"[cclass=" + cclass + "]."); "[cclass=" + cclass + "].", e);
Log.logStackTrace(e);
} }
// initialize our client instance // initialize our client instance
@@ -76,7 +75,7 @@ public class MiCasaApp
Client client = _client.getContext().getClient(); Client client = _client.getContext().getClient();
Log.info("Using [server=" + server + "."); log.info("Using [server=" + server + ".");
client.setServer(server, Client.DEFAULT_SERVER_PORTS); client.setServer(server, Client.DEFAULT_SERVER_PORTS);
// configure the client with some credentials and logon // configure the client with some credentials and logon
@@ -102,8 +101,7 @@ public class MiCasaApp
// initialize the app // initialize the app
app.init(); app.init();
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Error initializing application."); log.warning("Error initializing application.", ioe);
Log.logStackTrace(ioe);
} }
// and run it // and run it
@@ -31,7 +31,7 @@ import com.threerings.presents.client.Client;
import com.threerings.presents.client.ClientAdapter; import com.threerings.presents.client.ClientAdapter;
import com.threerings.presents.net.UsernamePasswordCreds; 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 * 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) { } catch (IOException ioe) {
Log.warning("Unable to create client."); log.warning("Unable to create client.", ioe);
Log.logStackTrace(ioe);
} }
} }
@@ -32,9 +32,10 @@ import com.threerings.crowd.util.CrowdContext;
import com.threerings.parlor.client.*; import com.threerings.parlor.client.*;
import com.threerings.parlor.game.data.GameConfig; import com.threerings.parlor.game.data.GameConfig;
import com.threerings.micasa.Log;
import com.threerings.micasa.util.MiCasaContext; import com.threerings.micasa.util.MiCasaContext;
import static com.threerings.micasa.Log.log;
public class LobbyController extends PlaceController public class LobbyController extends PlaceController
implements InvitationHandler, InvitationResponseObserver implements InvitationHandler, InvitationResponseObserver
{ {
@@ -71,8 +72,7 @@ public class LobbyController extends PlaceController
_ctx.getParlorDirector().invite( _ctx.getParlorDirector().invite(
new Name(invitee), config, this); new Name(invitee), config, this);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Error instantiating game config."); log.warning("Error instantiating game config.", e);
Log.logStackTrace(e);
} }
} }
@@ -84,7 +84,7 @@ public class LobbyController extends PlaceController
// documentation inherited from interface // documentation inherited from interface
public void invitationReceived (Invitation invite) public void invitationReceived (Invitation invite)
{ {
Log.info("Invitation received [invite=" + invite + "]."); log.info("Invitation received [invite=" + invite + "].");
// accept the invitation. we're game... // accept the invitation. we're game...
invite.accept(); invite.accept();
@@ -93,26 +93,26 @@ public class LobbyController extends PlaceController
// documentation inherited from interface // documentation inherited from interface
public void invitationCancelled (Invitation invite) public void invitationCancelled (Invitation invite)
{ {
Log.info("Invitation cancelled " + invite + "."); log.info("Invitation cancelled " + invite + ".");
} }
// documentation inherited from interface // documentation inherited from interface
public void invitationAccepted (Invitation invite) public void invitationAccepted (Invitation invite)
{ {
Log.info("Invitation accepted " + invite + "."); log.info("Invitation accepted " + invite + ".");
} }
// documentation inherited from interface // documentation inherited from interface
public void invitationRefused (Invitation invite, String message) public void invitationRefused (Invitation invite, String message)
{ {
Log.info("Invitation refused [invite=" + invite + log.info("Invitation refused [invite=" + invite +
", message=" + message + "]."); ", message=" + message + "].");
} }
// documentation inherited from interface // documentation inherited from interface
public void invitationCountered (Invitation invite, GameConfig config) public void invitationCountered (Invitation invite, GameConfig config)
{ {
Log.info("Invitation countered [invite=" + invite + log.info("Invitation countered [invite=" + invite +
", config=" + config + "]."); ", config=" + config + "].");
} }
@@ -26,7 +26,8 @@ import com.samskivert.util.StringUtil;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.PlaceManager; 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. * 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 // let the lobby registry know that we're up and running
lobreg.lobbyReady(_plobj.getOid(), _gameIdent, _name); lobreg.lobbyReady(_plobj.getOid(), _gameIdent, _name);
Log.info("Lobby manager initialized [ident=" + _gameIdent + log.info("Lobby manager initialized [ident=" + _gameIdent +
", name=" + _name + "]."); ", name=" + _name + "].");
} }
@@ -31,12 +31,13 @@ import com.threerings.presents.server.InvocationManager;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
import com.threerings.micasa.Log;
import com.threerings.micasa.lobby.LobbyService.CategoriesListener; import com.threerings.micasa.lobby.LobbyService.CategoriesListener;
import com.threerings.micasa.lobby.LobbyService.LobbiesListener; import com.threerings.micasa.lobby.LobbyService.LobbiesListener;
import com.threerings.micasa.server.MiCasaConfig; import com.threerings.micasa.server.MiCasaConfig;
import com.threerings.micasa.server.MiCasaServer; 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 * 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 * 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; String[] lmgrs = null;
lmgrs = MiCasaConfig.config.getValue(LOBIDS_KEY, lmgrs); lmgrs = MiCasaConfig.config.getValue(LOBIDS_KEY, lmgrs);
if (lmgrs == null || lmgrs.length == 0) { 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)."); LOBIDS_KEY + "' parameter).");
} else { } else {
@@ -145,7 +146,7 @@ public class LobbyRegistry
lobmgr.init(this, props); lobmgr.init(this, props);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Unable to create lobby manager [lobbyId=" + lobbyId + log.warning("Unable to create lobby manager [lobbyId=" + lobbyId +
", error=" + e + "]."); ", error=" + e + "].");
} }
} }
@@ -239,7 +240,7 @@ public class LobbyRegistry
_lobbies.put(category, catlist); _lobbies.put(category, catlist);
} }
catlist.add(record); 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 /** 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.crowd.data.PlaceObject;
import com.threerings.micasa.Log;
import com.threerings.micasa.util.MiCasaContext; 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 * The lobby selector displays a drop-down box listing the categories of
* lobbies available on this server and when a category is selected, it * 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 // documentation inherited from interface
public void requestFailed (String reason) 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 // clear out our pending category indicator in case this was a
// failed getLobbies() request // failed getLobbies() request
@@ -166,7 +167,7 @@ public class LobbySelector extends JPanel
_lservice.getLobbies(_ctx.getClient(), category, this); _lservice.getLobbies(_ctx.getClient(), category, this);
} else { } else {
Log.info("Ignoring category select request because " + log.info("Ignoring category select request because " +
"one is outstanding [pcat=" + _pendingCategory + "one is outstanding [pcat=" + _pendingCategory +
", newcat=" + category + "]."); ", newcat=" + category + "].");
} }
@@ -184,7 +185,7 @@ public class LobbySelector extends JPanel
// otherwise request that we go there // otherwise request that we go there
_ctx.getLocationDirector().moveTo(lobby.placeOid); _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.client.SeatednessObserver;
import com.threerings.parlor.data.Table; import com.threerings.parlor.data.Table;
import com.threerings.micasa.Log;
import com.threerings.micasa.util.MiCasaContext; 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 * A table item displays the user interface for a single table (whether it
* be in-play or still being matchmade). * be in-play or still being matchmade).
@@ -195,7 +196,7 @@ public class TableItem
// sanity check // sanity check
if (position == -1) { 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 + "]."); "click came from [event=" + event + "].");
} else { } else {
// otherwise, request to join the table at this position // otherwise, request to join the table at this position
@@ -211,7 +212,7 @@ public class TableItem
_ctx.getLocationDirector().moveTo(table.gameOid); _ctx.getLocationDirector().moveTo(table.gameOid);
} else { } 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.VGroupLayout;
import com.samskivert.swing.util.SwingUtil; import com.samskivert.swing.util.SwingUtil;
import com.threerings.micasa.Log;
import com.threerings.micasa.lobby.LobbyConfig; import com.threerings.micasa.lobby.LobbyConfig;
import com.threerings.micasa.util.MiCasaContext; 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.client.PlaceView;
import com.threerings.crowd.data.PlaceObject; 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 * 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 * separate lists, one of tables being matchmade and another of games in
@@ -103,7 +104,7 @@ public class TableListView extends JPanel
_tableFigger = gconfig.createTableConfigurator(); _tableFigger = gconfig.createTableConfigurator();
if (_tableFigger == null) { 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 " + "tables: it needs to return non-null from " +
"createTableConfigurator()."); "createTableConfigurator().");
// let's just wait until we throw an NPE below // let's just wait until we throw an NPE below
@@ -123,9 +124,8 @@ public class TableListView extends JPanel
panel.add(_create, VGroupLayout.FIXED); panel.add(_create, VGroupLayout.FIXED);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Unable to create configurator interface " + log.warning("Unable to create configurator interface " +
"[config=" + gconfig + "]."); "[config=" + gconfig + "].", e);
Log.logStackTrace(e);
// stick something in the UI to let them know we're hosed // stick something in the UI to let them know we're hosed
panel.add(new JLabel("Aiya! Can't create tables. " + panel.add(new JLabel("Aiya! Can't create tables. " +
@@ -174,7 +174,7 @@ public class TableListView extends JPanel
// documentation inherited // documentation inherited
public void tableAdded (Table table) 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 // create a table item for this table and insert it into the
// appropriate list // appropriate list
@@ -186,12 +186,12 @@ public class TableListView extends JPanel
// documentation inherited // documentation inherited
public void tableUpdated (Table table) 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 // locate the table item associated with this table
TableItem item = getTableItem(table.tableId); TableItem item = getTableItem(table.tableId);
if (item == null) { if (item == null) {
Log.warning("Received table updated notification for " + log.warning("Received table updated notification for " +
"unknown table [table=" + table + "]."); "unknown table [table=" + table + "].");
return; return;
} }
@@ -212,12 +212,12 @@ public class TableListView extends JPanel
// documentation inherited // documentation inherited
public void tableRemoved (int tableId) 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 // locate the table item associated with this table
TableItem item = getTableItem(tableId); TableItem item = getTableItem(tableId);
if (item == null) { if (item == null) {
Log.warning("Received table removed notification for " + log.warning("Received table removed notification for " +
"unknown table [tableId=" + tableId + "]."); "unknown table [tableId=" + tableId + "].");
return; return;
} }
@@ -32,9 +32,10 @@ import com.threerings.crowd.server.CrowdServer;
import com.threerings.parlor.server.ParlorManager; import com.threerings.parlor.server.ParlorManager;
import com.threerings.micasa.Log;
import com.threerings.micasa.lobby.LobbyRegistry; 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 * This class is the main entry point and general organizer of everything
* that goes on in the MiCasa game server process. * that goes on in the MiCasa game server process.
@@ -72,7 +73,7 @@ public class MiCasaServer extends CrowdServer
// initialize the lobby registry // initialize the lobby registry
lobreg.init(invmgr); lobreg.init(invmgr);
Log.info("MiCasa server initialized."); log.info("MiCasa server initialized.");
} }
public static void main (String[] args) public static void main (String[] args)
@@ -82,8 +83,7 @@ public class MiCasaServer extends CrowdServer
server.init(); server.init();
server.run(); server.run();
} catch (Exception e) { } catch (Exception e) {
Log.warning("Unable to initialize server."); log.warning("Unable to initialize server.", e);
Log.logStackTrace(e);
} }
} }
} }
@@ -34,11 +34,12 @@ import com.threerings.presents.client.Client;
import com.threerings.presents.client.ClientAdapter; import com.threerings.presents.client.ClientAdapter;
import com.threerings.presents.net.UsernamePasswordCreds; import com.threerings.presents.net.UsernamePasswordCreds;
import com.threerings.micasa.Log;
import com.threerings.micasa.simulator.data.SimulatorInfo; import com.threerings.micasa.simulator.data.SimulatorInfo;
import com.threerings.micasa.simulator.server.SimpleServer; import com.threerings.micasa.simulator.server.SimpleServer;
import com.threerings.micasa.simulator.server.SimulatorServer; import com.threerings.micasa.simulator.server.SimulatorServer;
import static com.threerings.micasa.Log.log;
/** /**
* The simulator application is a test harness to facilitate development * The simulator application is a test harness to facilitate development
* and debugging of games. * and debugging of games.
@@ -71,12 +72,12 @@ public class SimulatorApp
try { try {
run(); run();
} catch (Exception e) { } catch (Exception e) {
Log.warning("Simulator initialization failed " + log.warning("Simulator initialization failed " +
"[e=" + e + "]."); "[e=" + e + "].");
} }
} }
public void requestFailed (Exception 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 // start up the client
Client client = _client.getParlorContext().getClient(); Client client = _client.getParlorContext().getClient();
Log.info("Connecting to localhost."); log.info("Connecting to localhost.");
client.setServer("localhost", Client.DEFAULT_SERVER_PORTS); client.setServer("localhost", Client.DEFAULT_SERVER_PORTS);
// we want to exit when we logged off or failed to log on // we want to exit when we logged off or failed to log on
client.addClientObserver(new ClientAdapter() { client.addClientObserver(new ClientAdapter() {
public void clientFailedToLogon (Client c, Exception cause) { public void clientFailedToLogon (Client c, Exception cause) {
Log.info("Client failed to logon: " + cause); log.info("Client failed to logon: " + cause);
System.exit(0); System.exit(0);
} }
public void clientDidLogoff (Client c) { public void clientDidLogoff (Client c) {
@@ -171,8 +172,7 @@ public class SimulatorApp
try { try {
app.start(args); app.start(args);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Error starting up application."); log.warning("Error starting up application.", e);
Log.logStackTrace(e);
} }
} }
@@ -32,9 +32,10 @@ import com.threerings.crowd.data.BodyObject;
import com.threerings.parlor.game.data.GameConfig; import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.util.ParlorContext; import com.threerings.parlor.util.ParlorContext;
import com.threerings.micasa.Log;
import com.threerings.micasa.simulator.data.SimulatorInfo; 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. * Responsible for top-level control of the simulator client user interface.
*/ */
@@ -73,7 +74,7 @@ public class SimulatorController extends Controller
return true; return true;
} }
Log.info("Unhandled action: " + action); log.info("Unhandled action: " + action);
return false; return false;
} }
@@ -86,7 +87,7 @@ public class SimulatorController extends Controller
// documentation inherited // documentation inherited
public void clientDidLogon (Client client) 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 // keep the body object around for stuff
_body = (BodyObject)client.getClientObject(); _body = (BodyObject)client.getClientObject();
@@ -110,7 +111,7 @@ public class SimulatorController extends Controller
// straightaway // straightaway
} catch (Exception e) { } 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 + "]."); ", error=" + e + "].");
} }
} }
@@ -125,7 +126,7 @@ public class SimulatorController extends Controller
// documentation inherited // documentation inherited
public void clientDidLogoff (Client client) public void clientDidLogoff (Client client)
{ {
Log.info("Client did logoff [client=" + client + "]."); log.info("Client did logoff [client=" + client + "].");
} }
protected ParlorContext _ctx; 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.data.GameObject;
import com.threerings.parlor.game.server.GameManager; 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. * 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); _gmgr = (GameManager)_plreg.createPlace(config);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Unable to create game manager [e=" + e + "]."); log.warning("Unable to create game manager [e=" + e + "].", e);
Log.logStackTrace(e);
return; return;
} }
@@ -136,7 +135,7 @@ public class SimulatorManager
} }
} }
public void resolutionFailed (Name username, Exception cause) { 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 { try {
sim = (Simulant)Class.forName(_simClass).newInstance(); sim = (Simulant)Class.forName(_simClass).newInstance();
} catch (Exception e) { } catch (Exception e) {
Log.warning("Unable to create simulant " + log.warning("Unable to create simulant " +
"[class=" + _simClass + "]."); "[class=" + _simClass + "].");
return; return;
} }
@@ -177,7 +176,7 @@ public class SimulatorManager
try { try {
_plreg.locprov.moveTo(bobj, _gobj.getOid()); _plreg.locprov.moveTo(bobj, _gobj.getOid());
} catch (Exception e) { } catch (Exception e) {
Log.warning("Failed to move simulant into room " + log.warning("Failed to move simulant into room " +
"[e=" + e + "]."); "[e=" + e + "].");
return; return;
} }
@@ -27,7 +27,7 @@ import com.threerings.presents.server.InvocationProvider;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
import com.threerings.parlor.game.data.GameConfig; 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 * The simulator provider handles game creation requests on the server
@@ -50,7 +50,7 @@ public class SimulatorProvider
public void createGame (ClientObject caller, GameConfig config, public void createGame (ClientObject caller, GameConfig config,
String simClass, int playerCount) String simClass, int playerCount)
{ {
Log.info("handleCreateGameRequest [caller=" + caller.who() + log.info("handleCreateGameRequest [caller=" + caller.who() +
", config=" + config + ", simClass=" + simClass + ", config=" + config + ", simClass=" + simClass +
", playerCount=" + playerCount + "]."); ", playerCount=" + playerCount + "].");
+2 -28
View File
@@ -21,8 +21,7 @@
package com.threerings.parlor; package com.threerings.parlor;
import java.util.logging.Level; import com.samskivert.util.Logger;
import java.util.logging.Logger;
/** /**
* Contains a reference to the log object used by the Parlor services. * Contains a reference to the log object used by the Parlor services.
@@ -30,30 +29,5 @@ import java.util.logging.Logger;
public class Log public class Log
{ {
/** We dispatch our log messages through this logger. */ /** We dispatch our log messages through this logger. */
public static Logger log = public static Logger log = Logger.getLogger("com.threerings.parlor");
Logger.getLogger("com.threerings.vilya.parlor");
/** Convenience function. */
public static void debug (String message)
{
log.fine(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.log(Level.WARNING, t.getMessage(), t);
}
} }
+4 -28
View File
@@ -21,36 +21,12 @@
package com.threerings.parlor.card; package com.threerings.parlor.card;
import com.samskivert.util.Logger;
/** /**
* A placeholder class that contains a reference to the log object used by * Contains a reference to the log object used by the Card services.
* the Card services.
*/ */
public class Log public class Log
{ {
public static com.samskivert.util.Log log = public static Logger log = Logger.getLogger("com.threerings.parlor.card");
new com.samskivert.util.Log("card");
/** 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);
}
} }
@@ -25,13 +25,14 @@ import com.threerings.util.Name;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
import com.threerings.parlor.card.Log;
import com.threerings.parlor.card.data.Card; import com.threerings.parlor.card.data.Card;
import com.threerings.parlor.card.data.CardCodes; import com.threerings.parlor.card.data.CardCodes;
import com.threerings.parlor.card.data.Hand; import com.threerings.parlor.card.data.Hand;
import com.threerings.parlor.game.client.GameController; import com.threerings.parlor.game.client.GameController;
import com.threerings.parlor.turn.client.TurnGameController; import com.threerings.parlor.turn.client.TurnGameController;
import static com.threerings.parlor.card.Log.log;
/** /**
* A controller class for card games. Handles common functions like * A controller class for card games. Handles common functions like
* accepting dealt hands. * accepting dealt hands.
@@ -44,7 +45,7 @@ public abstract class CardGameController extends GameController
{ {
if (_ctx.getClient().getClientObject().receivers.containsKey( if (_ctx.getClient().getClientObject().receivers.containsKey(
CardGameDecoder.RECEIVER_CODE)) { CardGameDecoder.RECEIVER_CODE)) {
Log.warning("Yuh oh, we already have a card game receiver " + log.warning("Yuh oh, we already have a card game receiver " +
"registered and are trying for another...!"); "registered and are trying for another...!");
Thread.dumpStack(); Thread.dumpStack();
} }
@@ -47,12 +47,13 @@ import com.threerings.media.util.Path;
import com.threerings.media.util.PathSequence; import com.threerings.media.util.PathSequence;
import com.threerings.media.util.Pathable; import com.threerings.media.util.Pathable;
import com.threerings.parlor.card.Log;
import com.threerings.parlor.card.data.Card; import com.threerings.parlor.card.data.Card;
import com.threerings.parlor.card.data.CardCodes; import com.threerings.parlor.card.data.CardCodes;
import com.threerings.parlor.card.data.Deck; import com.threerings.parlor.card.data.Deck;
import com.threerings.parlor.card.data.Hand; import com.threerings.parlor.card.data.Hand;
import static com.threerings.parlor.card.Log.log;
/** /**
* Extends VirtualMediaPanel to provide services specific to rendering and manipulating playing * Extends VirtualMediaPanel to provide services specific to rendering and manipulating playing
* cards. * cards.
@@ -25,8 +25,6 @@ import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.OccupantInfo; import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.server.OccupantOp; import com.threerings.crowd.server.OccupantOp;
import com.threerings.parlor.card.Log;
import com.threerings.parlor.card.data.Card; import com.threerings.parlor.card.data.Card;
import com.threerings.parlor.card.data.CardCodes; import com.threerings.parlor.card.data.CardCodes;
import com.threerings.parlor.card.data.CardGameObject; import com.threerings.parlor.card.data.CardGameObject;
@@ -42,6 +40,8 @@ import com.threerings.presents.dobj.MessageEvent;
import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.PresentsServer; import com.threerings.presents.server.PresentsServer;
import static com.threerings.parlor.card.Log.log;
/** /**
* A manager class for card games. Handles common functions like dealing * A manager class for card games. Handles common functions like dealing
* hands of cards to all players. * hands of cards to all players.
@@ -41,7 +41,6 @@ import com.threerings.crowd.server.PlaceManager;
import com.threerings.parlor.turn.server.TurnGameManagerDelegate; import com.threerings.parlor.turn.server.TurnGameManagerDelegate;
import com.threerings.parlor.card.Log;
import com.threerings.parlor.card.data.Card; import com.threerings.parlor.card.data.Card;
import com.threerings.parlor.card.data.CardGameObject; import com.threerings.parlor.card.data.CardGameObject;
import com.threerings.parlor.card.data.Deck; import com.threerings.parlor.card.data.Deck;
@@ -51,6 +50,8 @@ import com.threerings.parlor.card.server.CardGameManager;
import com.threerings.parlor.card.trick.data.TrickCardGameMarshaller; import com.threerings.parlor.card.trick.data.TrickCardGameMarshaller;
import com.threerings.parlor.card.trick.data.TrickCardGameObject; import com.threerings.parlor.card.trick.data.TrickCardGameObject;
import static com.threerings.parlor.card.Log.log;
/** /**
* A card game manager delegate for trick-based card games, such as Spades and Hearts. * A card game manager delegate for trick-based card games, such as Spades and Hearts.
*/ */
@@ -216,14 +217,14 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
// make sure they're actually a player // make sure they're actually a player
int fromidx = _cgmgr.getPlayerIndex(client); int fromidx = _cgmgr.getPlayerIndex(client);
if (fromidx == -1) { if (fromidx == -1) {
Log.warning("Send request from non-player [username=" + log.warning("Send request from non-player [username=" +
((BodyObject)client).who() + ", cards=" + StringUtil.toString(cards) + "]."); ((BodyObject)client).who() + ", cards=" + StringUtil.toString(cards) + "].");
return; return;
} }
// make sure they have the cards // make sure they have the cards
if (!_hands[fromidx].containsAll(cards)) { if (!_hands[fromidx].containsAll(cards)) {
Log.warning("Tried to send cards not held [username=" + log.warning("Tried to send cards not held [username=" +
((BodyObject)client).who() + ", cards=" + StringUtil.toString(cards) + "]."); ((BodyObject)client).who() + ", cards=" + StringUtil.toString(cards) + "].");
return; return;
} }
@@ -254,14 +255,14 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
// make sure their hand contains the specified card // make sure their hand contains the specified card
if (!_hands[pidx].contains(card)) { if (!_hands[pidx].contains(card)) {
Log.warning("Tried to play card not held [username=" + username + log.warning("Tried to play card not held [username=" + username +
", card=" + card + "]."); ", card=" + card + "].");
return; return;
} }
// make sure the card is legal to play // make sure the card is legal to play
if (!_trickCardGame.isCardPlayable(_hands[pidx], card)) { if (!_trickCardGame.isCardPlayable(_hands[pidx], card)) {
Log.warning("Tried to play illegal card [username=" + username + log.warning("Tried to play illegal card [username=" + username +
", card=" + card + "]."); ", card=" + card + "].");
return; return;
} }
@@ -274,7 +275,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
{ {
// make sure the game is over // make sure the game is over
if (_cardGame.state != CardGameObject.GAME_OVER) { if (_cardGame.state != CardGameObject.GAME_OVER) {
Log.warning("Tried to request rematch when game wasn't over " + log.warning("Tried to request rematch when game wasn't over " +
"[username=" + ((BodyObject)client).who() + "]."); "[username=" + ((BodyObject)client).who() + "].");
return; return;
} }
@@ -282,14 +283,14 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
// make sure the requester is one of the players // make sure the requester is one of the players
int pidx = _cgmgr.getPlayerIndex(client); int pidx = _cgmgr.getPlayerIndex(client);
if (pidx == -1) { if (pidx == -1) {
Log.warning("Rematch request from non-player [username=" + log.warning("Rematch request from non-player [username=" +
((BodyObject)client).who() + "]."); ((BodyObject)client).who() + "].");
return; return;
} }
// make sure the player hasn't already requested // make sure the player hasn't already requested
if (_trickCardGame.getRematchRequests()[pidx] != TrickCardGameObject.NO_REQUEST) { if (_trickCardGame.getRematchRequests()[pidx] != TrickCardGameObject.NO_REQUEST) {
Log.warning("Repeated rematch request [username=" + ((BodyObject)client).who() + "]."); log.warning("Repeated rematch request [username=" + ((BodyObject)client).who() + "].");
return; return;
} }
@@ -23,11 +23,12 @@ package com.threerings.parlor.client;
import com.threerings.util.Name; import com.threerings.util.Name;
import com.threerings.parlor.Log;
import com.threerings.parlor.data.ParlorCodes; import com.threerings.parlor.data.ParlorCodes;
import com.threerings.parlor.game.data.GameConfig; import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.util.ParlorContext; import com.threerings.parlor.util.ParlorContext;
import static com.threerings.parlor.Log.log;
/** /**
* The invitation class is used to track information related to * The invitation class is used to track information related to
* outstanding invitations generated by or targeted to this client. * outstanding invitations generated by or targeted to this client.
@@ -151,7 +152,7 @@ public class Invitation
{ {
// make sure we have an observer to notify // make sure we have an observer to notify
if (_observer == null) { if (_observer == null) {
Log.warning("No observer registered for invitation " + log.warning("No observer registered for invitation " +
this + "."); this + ".");
return; return;
} }
@@ -173,10 +174,9 @@ public class Invitation
} }
} catch (Exception e) { } catch (Exception e) {
Log.warning("Invitation response observer choked on response " + log.warning("Invitation response observer choked on response " +
"[code=" + code + ", arg=" + arg + "[code=" + code + ", arg=" + arg +
", invite=" + this + "]."); ", invite=" + this + "].", e);
Log.logStackTrace(e);
} }
// unless the invitation was countered, we can remove it from the // unless the invitation was countered, we can remove it from the
@@ -30,11 +30,12 @@ import com.threerings.presents.client.BasicDirector;
import com.threerings.presents.client.Client; import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.InvocationService;
import com.threerings.parlor.Log;
import com.threerings.parlor.data.ParlorCodes; import com.threerings.parlor.data.ParlorCodes;
import com.threerings.parlor.game.data.GameConfig; import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.util.ParlorContext; import com.threerings.parlor.util.ParlorContext;
import static com.threerings.parlor.Log.log;
/** /**
* The parlor director manages the client side of the game configuration and matchmaking * The parlor director manages the client side of the game configuration and matchmaking
* processes. It is also the entity that is listening for game start notifications which it then * processes. It is also the entity that is listening for game start notifications which it then
@@ -132,7 +133,7 @@ public class ParlorDirector extends BasicDirector
// documentation inherited from interface // documentation inherited from interface
public void gameIsReady (int gameOid) public void gameIsReady (int gameOid)
{ {
Log.info("Handling game ready [goid=" + gameOid + "]."); log.info("Handling game ready [goid=" + gameOid + "].");
// see what our observers have to say about it // see what our observers have to say about it
boolean handled = false; boolean handled = false;
@@ -163,8 +164,7 @@ public class ParlorDirector extends BasicDirector
_handler.invitationReceived(invite); _handler.invitationReceived(invite);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Invitation handler choked on invite notification " + invite + "."); log.warning("Invitation handler choked on invite notification " + invite + ".", e);
Log.logStackTrace(e);
} }
} }
@@ -174,7 +174,7 @@ public class ParlorDirector extends BasicDirector
// look up the invitation record for this invitation // look up the invitation record for this invitation
Invitation invite = (Invitation)_pendingInvites.get(remoteId); Invitation invite = (Invitation)_pendingInvites.get(remoteId);
if (invite == null) { if (invite == null) {
Log.warning("Have no record of invitation for which we received a response?! " + log.warning("Have no record of invitation for which we received a response?! " +
"[remoteId=" + remoteId + ", code=" + code + ", arg=" + arg + "]."); "[remoteId=" + remoteId + ", code=" + code + ", arg=" + arg + "].");
} else { } else {
@@ -35,13 +35,14 @@ import com.threerings.presents.dobj.SetListener;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
import com.threerings.parlor.Log;
import com.threerings.parlor.data.Table; import com.threerings.parlor.data.Table;
import com.threerings.parlor.data.TableConfig; import com.threerings.parlor.data.TableConfig;
import com.threerings.parlor.data.TableLobbyObject; import com.threerings.parlor.data.TableLobbyObject;
import com.threerings.parlor.game.data.GameConfig; import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.util.ParlorContext; import com.threerings.parlor.util.ParlorContext;
import static com.threerings.parlor.Log.log;
/** /**
* As tables are created and managed within the scope of a place (a lobby), we want to fold the * As tables are created and managed within the scope of a place (a lobby), we want to fold the
* table management functionality into the standard hierarchy of place controllers that deal with * table management functionality into the standard hierarchy of place controllers that deal with
@@ -146,14 +147,14 @@ public class TableDirector extends BasicDirector
{ {
// if we're already in a table, refuse the request // if we're already in a table, refuse the request
if (_ourTable != null) { if (_ourTable != null) {
Log.warning("Ignoring request to create table as we're already in a table " + log.warning("Ignoring request to create table as we're already in a table " +
"[table=" + _ourTable + "]."); "[table=" + _ourTable + "].");
return; return;
} }
// make sure we're currently in a place // make sure we're currently in a place
if (_tlobj == null) { if (_tlobj == null) {
Log.warning("Requested to create a table but we're not currently in a place " + log.warning("Requested to create a table but we're not currently in a place " +
"[config=" + config + "]."); "[config=" + config + "].");
return; return;
} }
@@ -170,14 +171,14 @@ public class TableDirector extends BasicDirector
{ {
// if we're already in a table, refuse the request // if we're already in a table, refuse the request
if (_ourTable != null) { if (_ourTable != null) {
Log.warning("Ignoring request to join table as we're already in a table " + log.warning("Ignoring request to join table as we're already in a table " +
"[table=" + _ourTable + "]."); "[table=" + _ourTable + "].");
return; return;
} }
// make sure we're currently in a place // make sure we're currently in a place
if (_tlobj == null) { if (_tlobj == null) {
Log.warning("Requested to join a table but we're not currently in a place " + log.warning("Requested to join a table but we're not currently in a place " +
"[tableId=" + tableId + "]."); "[tableId=" + tableId + "].");
return; return;
} }
@@ -194,7 +195,7 @@ public class TableDirector extends BasicDirector
{ {
// make sure we're currently in a place // make sure we're currently in a place
if (_tlobj == null) { if (_tlobj == null) {
Log.warning("Requested to leave a table but we're not currently in a place " + log.warning("Requested to leave a table but we're not currently in a place " +
"[tableId=" + tableId + "]."); "[tableId=" + tableId + "].");
return; return;
} }
@@ -210,7 +211,7 @@ public class TableDirector extends BasicDirector
public void startTableNow (int tableId) public void startTableNow (int tableId)
{ {
if (_tlobj == null) { if (_tlobj == null) {
Log.warning("Requested to start a table but we're not currently in a place " + log.warning("Requested to start a table but we're not currently in a place " +
"[tableId=" + tableId + "]."); "[tableId=" + tableId + "].");
return; return;
} }
@@ -270,13 +271,13 @@ public class TableDirector extends BasicDirector
int tableId = (Integer)result; int tableId = (Integer)result;
if (_tlobj == null) { if (_tlobj == null) {
// we've left, it's none of our concern anymore // we've left, it's none of our concern anymore
Log.info("Table created, but no lobby. [tableId=" + tableId + "]."); log.info("Table created, but no lobby. [tableId=" + tableId + "].");
return; return;
} }
Table table = (Table) _tlobj.getTables().get(tableId); Table table = (Table) _tlobj.getTables().get(tableId);
if (table == null) { if (table == null) {
Log.warning("Table created, but where is it? [tableId=" + tableId + "]"); log.warning("Table created, but where is it? [tableId=" + tableId + "]");
return; return;
} }
@@ -289,7 +290,7 @@ public class TableDirector extends BasicDirector
// from interface TableService.ResultListener // from interface TableService.ResultListener
public void requestFailed (String reason) public void requestFailed (String reason)
{ {
Log.warning("Table action failed [reason=" + reason + "]."); log.warning("Table action failed [reason=" + reason + "].");
} }
/** /**
@@ -33,12 +33,13 @@ import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.util.CrowdContext; import com.threerings.crowd.util.CrowdContext;
import com.threerings.parlor.Log;
import com.threerings.parlor.game.data.GameCodes; import com.threerings.parlor.game.data.GameCodes;
import com.threerings.parlor.game.data.GameConfig; import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.game.data.GameObject; import com.threerings.parlor.game.data.GameObject;
import com.threerings.parlor.util.ParlorContext; import com.threerings.parlor.util.ParlorContext;
import static com.threerings.parlor.Log.log;
/** /**
* The game controller manages the flow and control of a game on the client side. This class serves * The game controller manages the flow and control of a game on the client side. This class serves
* as the root of a hierarchy of controller classes that aim to provide functionality shared * as the root of a hierarchy of controller classes that aim to provide functionality shared
@@ -94,7 +95,7 @@ public abstract class GameController extends PlaceController
// we don't want to claim to be finished until any derived classes that overrode this // we don't want to claim to be finished until any derived classes that overrode this
// method have executed, so we'll queue up a runnable here that will let the game manager // method have executed, so we'll queue up a runnable here that will let the game manager
// know that we're ready on the next pass through the distributed event loop // know that we're ready on the next pass through the distributed event loop
Log.info("Entering game " + _gobj.which() + "."); log.info("Entering game " + _gobj.which() + ".");
if (_gobj.getPlayerIndex(bobj.getVisibleName()) != -1) { if (_gobj.getPlayerIndex(bobj.getVisibleName()) != -1) {
_ctx.getClient().getRunQueue().postRunnable(new Runnable() { _ctx.getClient().getRunQueue().postRunnable(new Runnable() {
public void run () { public void run () {
@@ -193,7 +194,7 @@ public abstract class GameController extends PlaceController
if (event.getName().equals(GameObject.STATE)) { if (event.getName().equals(GameObject.STATE)) {
int newState = event.getIntValue(); int newState = event.getIntValue();
if (!stateDidChange(newState)) { if (!stateDidChange(newState)) {
Log.warning("Game transitioned to unknown state [gobj=" + _gobj + log.warning("Game transitioned to unknown state [gobj=" + _gobj +
", state=" + newState + "]."); ", state=" + newState + "].");
} }
} }
@@ -228,7 +229,7 @@ public abstract class GameController extends PlaceController
*/ */
protected void playerReady () protected void playerReady ()
{ {
Log.info("Reporting ready " + _gobj.which() + "."); log.info("Reporting ready " + _gobj.which() + ".");
_gobj.manager.invoke("playerReady"); _gobj.manager.invoke("playerReady");
} }
@@ -239,7 +240,7 @@ public abstract class GameController extends PlaceController
protected void gameDidStart () protected void gameDidStart ()
{ {
if (_gobj == null) { if (_gobj == null) {
Log.info("Received gameDidStart() after leaving game room."); log.info("Received gameDidStart() after leaving game room.");
return; return;
} }
@@ -454,7 +454,7 @@ public class GameManager extends PlaceManager
boolean result = startGame(); boolean result = startGame();
// TEMP: track down weirdness // TEMP: track down weirdness
if (!result && !_postponedStart) { if (!result && !_postponedStart) {
log.log(Level.WARNING, "First call to startGame: ", firstCall); log.warning("First call to startGame: ", firstCall);
} }
// End: temp // End: temp
} }
@@ -1286,7 +1286,7 @@ public class GameManager extends PlaceManager
try { try {
gmgr.tick(now); gmgr.tick(now);
} catch (Exception e) { } catch (Exception e) {
log.log(Level.WARNING, "Game manager choked during tick [gmgr=" + gmgr + "].", e); log.warning("Game manager choked during tick [gmgr=" + gmgr + "].", e);
} }
} }
} }
@@ -32,12 +32,13 @@ import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.server.CrowdServer; import com.threerings.crowd.server.CrowdServer;
import com.threerings.crowd.server.PlaceRegistry; import com.threerings.crowd.server.PlaceRegistry;
import com.threerings.parlor.Log;
import com.threerings.parlor.client.ParlorService; import com.threerings.parlor.client.ParlorService;
import com.threerings.parlor.data.ParlorCodes; import com.threerings.parlor.data.ParlorCodes;
import com.threerings.parlor.data.TableConfig; import com.threerings.parlor.data.TableConfig;
import com.threerings.parlor.game.data.GameConfig; import com.threerings.parlor.game.data.GameConfig;
import static com.threerings.parlor.Log.log;
/** /**
* The parlor manager is responsible for the parlor services in aggregate. This includes * The parlor manager is responsible for the parlor services in aggregate. This includes
* maintaining the registry of active games, handling the necessary coordination for the * maintaining the registry of active games, handling the necessary coordination for the
@@ -107,7 +108,7 @@ public class ParlorManager
{ {
BodyObject user = (BodyObject)caller; BodyObject user = (BodyObject)caller;
Log.debug("Processing start solitaire [caller=" + user.who() + ", config=" + config + "]."); log.debug("Processing start solitaire [caller=" + user.who() + ", config=" + config + "].");
try { try {
// just this fellow will be playing // just this fellow will be playing
@@ -123,9 +124,8 @@ public class ParlorManager
listener.requestProcessed(); listener.requestProcessed();
} catch (InstantiationException ie) { } catch (InstantiationException ie) {
Log.warning("Error instantiating game manager " + log.warning("Error instantiating game manager " +
"[for=" + caller.who() + ", config=" + config + "]."); "[for=" + caller.who() + ", config=" + config + "].", ie);
Log.logStackTrace(ie);
throw new InvocationException(INTERNAL_ERROR); throw new InvocationException(INTERNAL_ERROR);
} }
} }
@@ -183,7 +183,7 @@ public class ParlorManager
// look up the invitation // look up the invitation
Invitation invite = (Invitation)_invites.get(inviteId); Invitation invite = (Invitation)_invites.get(inviteId);
if (invite == null) { if (invite == null) {
Log.warning("Requested to respond to non-existent invitation " + log.warning("Requested to respond to non-existent invitation " +
"[source=" + source + ", inviteId=" + inviteId + "[source=" + source + ", inviteId=" + inviteId +
", code=" + code + ", arg=" + arg + "]."); ", code=" + code + ", arg=" + arg + "].");
return; return;
@@ -191,7 +191,7 @@ public class ParlorManager
// make sure this response came from the proper person // make sure this response came from the proper person
if (source != invite.invitee) { if (source != invite.invitee) {
Log.warning("Got response from non-invitee [source=" + source + log.warning("Got response from non-invitee [source=" + source +
", invite=" + invite + ", code=" + code + ", invite=" + invite + ", code=" + code +
", arg=" + arg + "]."); ", arg=" + arg + "].");
return; return;
@@ -221,7 +221,7 @@ public class ParlorManager
break; break;
default: default:
Log.warning("Requested to respond to invitation with unknown response code " + log.warning("Requested to respond to invitation with unknown response code " +
"[source=" + source + ", invite=" + invite + ", code=" + code + "[source=" + source + ", invite=" + invite + ", code=" + code +
", arg=" + arg + "]."); ", arg=" + arg + "].");
break; break;
@@ -245,7 +245,7 @@ public class ParlorManager
protected void processAcceptedInvitation (Invitation invite) protected void processAcceptedInvitation (Invitation invite)
{ {
try { try {
Log.info("Creating game manager [invite=" + invite + "]."); log.info("Creating game manager [invite=" + invite + "].");
// configure the game config with the player info // configure the game config with the player info
invite.config.players = new Name[] { invite.invitee.getVisibleName(), invite.config.players = new Name[] { invite.invitee.getVisibleName(),
@@ -256,8 +256,7 @@ public class ParlorManager
createGameManager(invite.config); createGameManager(invite.config);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Unable to create game manager [invite=" + invite + ", error=" + e + "]."); log.warning("Unable to create game manager [invite=" + invite + "].", e);
Log.logStackTrace(e);
} }
} }
@@ -47,7 +47,6 @@ import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.CrowdServer; import com.threerings.crowd.server.CrowdServer;
import com.threerings.parlor.Log;
import com.threerings.parlor.client.TableService; import com.threerings.parlor.client.TableService;
import com.threerings.parlor.data.ParlorCodes; import com.threerings.parlor.data.ParlorCodes;
import com.threerings.parlor.data.Table; import com.threerings.parlor.data.Table;
@@ -58,6 +57,8 @@ import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.game.data.GameObject; import com.threerings.parlor.game.data.GameObject;
import com.threerings.parlor.game.server.GameManager; import com.threerings.parlor.game.server.GameManager;
import static com.threerings.parlor.Log.log;
/** /**
* A table manager can be used by a place manager (or other entity) to take care of the management * A table manager can be used by a place manager (or other entity) to take care of the management
* of a table matchmaking service on a particular distributed object. * of a table matchmaking service on a particular distributed object.
@@ -126,7 +127,7 @@ public class TableManager
try { try {
table = _tableClass.newInstance(); table = _tableClass.newInstance();
} catch (Exception e) { } catch (Exception e) {
Log.warning("Table.newInstance() failde [class=" + _tableClass + ", e=" + e + "]."); log.warning("Table.newInstance() failde [class=" + _tableClass + ", e=" + e + "].");
throw new InvocationException(INTERNAL_ERROR); throw new InvocationException(INTERNAL_ERROR);
} }
table.init(_dobj.getOid(), tableConfig, config); table.init(_dobj.getOid(), tableConfig, config);
@@ -136,7 +137,7 @@ public class TableManager
int cpos = (config.ais == null) ? 0 : config.ais.length; int cpos = (config.ais == null) ? 0 : config.ais.length;
String error = table.setPlayer(cpos, creator); String error = table.setPlayer(cpos, creator);
if (error != null) { if (error != null) {
Log.warning("Unable to add creator to position zero of table!? [table=" + table + log.warning("Unable to add creator to position zero of table!? [table=" + table +
", creator=" + creator + ", error=" + error + "]."); ", creator=" + creator + ", error=" + error + "].");
// bail out now and abort the table creation process // bail out now and abort the table creation process
throw new InvocationException(error); throw new InvocationException(error);
@@ -171,7 +172,7 @@ public class TableManager
// in which they are requesting to create a table // in which they are requesting to create a table
if (_dobj instanceof PlaceObject && if (_dobj instanceof PlaceObject &&
!((PlaceObject)_dobj).occupants.contains(creator.getOid())) { !((PlaceObject)_dobj).occupants.contains(creator.getOid())) {
Log.warning("Requested to create a table in a place not occupied by the creator " + log.warning("Requested to create a table in a place not occupied by the creator " +
"[creator=" + creator + ", ploid=" + _dobj.getOid() + "]."); "[creator=" + creator + ", ploid=" + _dobj.getOid() + "].");
throw new InvocationException(INTERNAL_ERROR); throw new InvocationException(INTERNAL_ERROR);
} }
@@ -240,7 +241,7 @@ public class TableManager
// remove the mapping from this user to the table // remove the mapping from this user to the table
if (null == notePlayerRemoved(leaver.getOid(), leaver)) { if (null == notePlayerRemoved(leaver.getOid(), leaver)) {
Log.warning("No body to table mapping to clear? [leaver=" + leaver.who() + log.warning("No body to table mapping to clear? [leaver=" + leaver.who() +
", table=" + table + "]."); ", table=" + table + "].");
} }
@@ -343,7 +344,7 @@ public class TableManager
return gobj.getOid(); return gobj.getOid();
} catch (Throwable t) { } catch (Throwable t) {
Log.warning("Failed to create manager for game [config=" + table.config + "]: " + t); log.warning("Failed to create manager for game [config=" + table.config + "]: " + t);
throw new InvocationException(INTERNAL_ERROR); throw new InvocationException(INTERNAL_ERROR);
} }
} }
@@ -416,7 +417,7 @@ public class TableManager
if (table != null) { if (table != null) {
purgeTable(table); purgeTable(table);
} else { } else {
Log.warning("Requested to unmap table that wasn't mapped [gameOid=" + gameOid + "]."); log.warning("Requested to unmap table that wasn't mapped [gameOid=" + gameOid + "].");
} }
} }
@@ -432,7 +433,7 @@ public class TableManager
Table table = _goidMap.get(gameOid); Table table = _goidMap.get(gameOid);
if (table == null) { if (table == null) {
Log.warning("Unable to find table for running game [gameOid=" + gameOid + "]."); log.warning("Unable to find table for running game [gameOid=" + gameOid + "].");
return; return;
} }
@@ -456,7 +457,7 @@ public class TableManager
// remove this player from the table // remove this player from the table
if (!pender.clearPlayerByOid(bodyOid)) { if (!pender.clearPlayerByOid(bodyOid)) {
Log.warning("Attempt to remove body from mapped table failed [table=" + pender + log.warning("Attempt to remove body from mapped table failed [table=" + pender +
", bodyOid=" + bodyOid + "]."); ", bodyOid=" + bodyOid + "].");
return; return;
} }
@@ -27,12 +27,13 @@ import com.threerings.util.Name;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.PlaceManager; import com.threerings.crowd.server.PlaceManager;
import com.threerings.parlor.Log;
import com.threerings.parlor.game.server.GameManager; import com.threerings.parlor.game.server.GameManager;
import com.threerings.parlor.game.server.GameManagerDelegate; import com.threerings.parlor.game.server.GameManagerDelegate;
import com.threerings.parlor.turn.data.TurnGameObject; import com.threerings.parlor.turn.data.TurnGameObject;
import static com.threerings.parlor.Log.log;
/** /**
* Performs the server-side turn-based game processing for a turn based game. Game managers which * Performs the server-side turn-based game processing for a turn based game. Game managers which
* wish to make use of the turn services must implement {@link TurnGameManager} and either create * wish to make use of the turn services must implement {@link TurnGameManager} and either create
@@ -96,7 +97,7 @@ public class TurnGameManagerDelegate extends GameManagerDelegate
{ {
// sanity check // sanity check
if (_turnIdx < 0 || _turnIdx >= _turnGame.getPlayers().length) { if (_turnIdx < 0 || _turnIdx >= _turnGame.getPlayers().length) {
Log.warning("startTurn() called with invalid turn index [game=" + where() + log.warning("startTurn() called with invalid turn index [game=" + where() +
", turnIdx=" + _turnIdx + "]."); ", turnIdx=" + _turnIdx + "].");
// abort, abort // abort, abort
return; return;
@@ -105,7 +106,7 @@ public class TurnGameManagerDelegate extends GameManagerDelegate
// get the player name and sanity-check again // get the player name and sanity-check again
Name name = _tgmgr.getPlayerName(_turnIdx); Name name = _tgmgr.getPlayerName(_turnIdx);
if (name == null) { if (name == null) {
Log.warning("startTurn() called with invalid player [game=" + where() + log.warning("startTurn() called with invalid player [game=" + where() +
", turnIdx=" + _turnIdx + "]."); ", turnIdx=" + _turnIdx + "].");
return; return;
} }
@@ -218,7 +219,7 @@ public class TurnGameManagerDelegate extends GameManagerDelegate
if (_turnIdx == oturnIdx) { if (_turnIdx == oturnIdx) {
// if we've wrapped all the way around, stop where we are even if the current // if we've wrapped all the way around, stop where we are even if the current
// player is not active. // player is not active.
Log.warning("1 or less active players. Unable to properly change turn. " + log.warning("1 or less active players. Unable to properly change turn. " +
"[game=" + where() + "]."); "[game=" + where() + "].");
break; break;
} }
@@ -236,7 +237,7 @@ public class TurnGameManagerDelegate extends GameManagerDelegate
while (!_tgmgr.isActivePlayer(_turnIdx)) { while (!_tgmgr.isActivePlayer(_turnIdx)) {
_turnIdx = (_turnIdx + 1) % size; _turnIdx = (_turnIdx + 1) % size;
if (_turnIdx == firstPick) { if (_turnIdx == firstPick) {
Log.warning("No players eligible for randomly-assigned turn. Choking. " + log.warning("No players eligible for randomly-assigned turn. Choking. " +
"[game=" + where() + "]."); "[game=" + where() + "].");
return; return;
} }
+4 -28
View File
@@ -21,36 +21,12 @@
package com.threerings.puzzle; package com.threerings.puzzle;
import com.samskivert.util.Logger;
/** /**
* A placeholder class that contains a reference to the log object used by * Contains a reference to the log object used by this package.
* this package.
*/ */
public class Log public class Log
{ {
public static com.samskivert.util.Log log = public static Logger log = Logger.getLogger("com.threerings.puzzle");
new com.samskivert.util.Log("puzzle");
/** 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);
}
} }
@@ -46,11 +46,12 @@ import com.threerings.media.sprite.Sprite;
import com.threerings.parlor.game.data.GameConfig; import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.media.ScoreAnimation; import com.threerings.parlor.media.ScoreAnimation;
import com.threerings.puzzle.Log;
import com.threerings.puzzle.data.Board; import com.threerings.puzzle.data.Board;
import com.threerings.puzzle.data.PuzzleCodes; import com.threerings.puzzle.data.PuzzleCodes;
import com.threerings.puzzle.util.PuzzleContext; import com.threerings.puzzle.util.PuzzleContext;
import static com.threerings.puzzle.Log.log;
/** /**
* The puzzle board view displays a view of a puzzle game. * The puzzle board view displays a view of a puzzle game.
*/ */
@@ -160,7 +161,7 @@ public abstract class PuzzleBoardView extends VirtualMediaPanel
protected void animationFinished (Animation anim) protected void animationFinished (Animation anim)
{ {
if (DEBUG_ACTION) { if (DEBUG_ACTION) {
Log.info("Animation cleared " + StringUtil.shortClassName(anim) + log.info("Animation cleared " + StringUtil.shortClassName(anim) +
":" + _actionAnims.contains(anim)); ":" + _actionAnims.contains(anim));
} }
@@ -194,7 +195,7 @@ public abstract class PuzzleBoardView extends VirtualMediaPanel
super.removeSprite(sprite); super.removeSprite(sprite);
if (DEBUG_ACTION) { if (DEBUG_ACTION) {
Log.info("Sprite cleared " + StringUtil.shortClassName(sprite) + log.info("Sprite cleared " + StringUtil.shortClassName(sprite) +
":" + _actionSprites.contains(sprite)); ":" + _actionSprites.contains(sprite));
} }
@@ -253,7 +254,7 @@ public abstract class PuzzleBoardView extends VirtualMediaPanel
return StringUtil.shortClassName(obj); return StringUtil.shortClassName(obj);
} }
}; };
Log.info("Board contents [board=" + StringUtil.shortClassName(this) + log.info("Board contents [board=" + StringUtil.shortClassName(this) +
", sprites=" + StringUtil.listToString(_actionSprites, fmt) + ", sprites=" + StringUtil.listToString(_actionSprites, fmt) +
", anims=" + StringUtil.listToString(_actionAnims, fmt) + ", anims=" + StringUtil.listToString(_actionAnims, fmt) +
"]."); "].");
@@ -348,7 +349,7 @@ public abstract class PuzzleBoardView extends VirtualMediaPanel
protected void maybeFireCleared () protected void maybeFireCleared ()
{ {
if (DEBUG_ACTION) { if (DEBUG_ACTION) {
Log.info("Maybe firing cleared " + log.info("Maybe firing cleared " +
getActionCount() + ":" + isShowing()); getActionCount() + ":" + isShowing());
} }
if (getActionCount() == 0) { if (getActionCount() == 0) {
@@ -50,12 +50,13 @@ import com.threerings.crowd.data.PlaceObject;
import com.threerings.parlor.game.client.GameController; import com.threerings.parlor.game.client.GameController;
import com.threerings.parlor.game.data.GameObject; import com.threerings.parlor.game.data.GameObject;
import com.threerings.puzzle.Log;
import com.threerings.puzzle.data.Board; import com.threerings.puzzle.data.Board;
import com.threerings.puzzle.data.PuzzleCodes; import com.threerings.puzzle.data.PuzzleCodes;
import com.threerings.puzzle.data.PuzzleObject; import com.threerings.puzzle.data.PuzzleObject;
import com.threerings.puzzle.util.PuzzleContext; import com.threerings.puzzle.util.PuzzleContext;
import static com.threerings.puzzle.Log.log;
/** /**
* The puzzle game controller handles logical actions for a puzzle game. * The puzzle game controller handles logical actions for a puzzle game.
*/ */
@@ -163,7 +164,7 @@ public abstract class PuzzleController extends GameController
// if we're moving focus to chat.. // if we're moving focus to chat..
if (chatting) { if (chatting) {
if (_unpauser != null) { if (_unpauser != null) {
Log.warning("Huh? Already have a mouse unpauser?"); log.warning("Huh? Already have a mouse unpauser?");
_unpauser.release(); _unpauser.release();
} }
_unpauser = new Unpauser(_panel); _unpauser = new Unpauser(_panel);
@@ -407,26 +408,26 @@ public abstract class PuzzleController extends GameController
// refuse to start the action if our puzzle view is hidden // refuse to start the action if our puzzle view is hidden
if (_pidx != -1 && !_panel.getBoardView().isShowing()) { if (_pidx != -1 && !_panel.getBoardView().isShowing()) {
Log.warning("Refusing to start action on hidden puzzle."); log.warning("Refusing to start action on hidden puzzle.");
Thread.dumpStack(); Thread.dumpStack();
return; return;
} }
// refuse to start the action if it's already going // refuse to start the action if it's already going
if (_astate != ACTION_CLEARED) { if (_astate != ACTION_CLEARED) {
Log.warning("Action state inappropriate for startAction() " + log.warning("Action state inappropriate for startAction() " +
"[astate=" + _astate + "]."); "[astate=" + _astate + "].");
Thread.dumpStack(); Thread.dumpStack();
return; return;
} }
if (isChatting() && supportsActionPause()) { if (isChatting() && supportsActionPause()) {
Log.info("Not starting action, player is chatting in a puzzle " + log.info("Not starting action, player is chatting in a puzzle " +
"that supports pausing the action."); "that supports pausing the action.");
return; return;
} }
Log.debug("Starting puzzle action."); log.debug("Starting puzzle action.");
// register the game progress updater; it may already be updated // register the game progress updater; it may already be updated
// because we can cycle through clearing the action and starting // because we can cycle through clearing the action and starting
@@ -498,7 +499,7 @@ public abstract class PuzzleController extends GameController
return; return;
} }
Log.debug("Attempting to clear puzzle action."); log.debug("Attempting to clear puzzle action.");
// put ourselves into a pending clear state and attempt to clear // put ourselves into a pending clear state and attempt to clear
// the action // the action
@@ -527,13 +528,13 @@ public abstract class PuzzleController extends GameController
// if the action is already ended, fire this pender immediately // if the action is already ended, fire this pender immediately
if (_astate == ACTION_CLEARED) { if (_astate == ACTION_CLEARED) {
if (pender.actionCleared() == ClearPender.RESTART_ACTION) { if (pender.actionCleared() == ClearPender.RESTART_ACTION) {
Log.debug("Restarting action at behest of pender " + log.debug("Restarting action at behest of pender " +
pender + "."); pender + ".");
startAction(); startAction();
} }
} else { } else {
Log.debug("Queueing action pender " + pender + "."); log.debug("Queueing action pender " + pender + ".");
_clearPenders.add(pender); _clearPenders.add(pender);
} }
} }
@@ -593,7 +594,7 @@ public abstract class PuzzleController extends GameController
*/ */
protected void actuallyClearAction () protected void actuallyClearAction ()
{ {
Log.debug("Actually clearing action."); log.debug("Actually clearing action.");
// make a note that we've cleared the action // make a note that we've cleared the action
_astate = ACTION_CLEARED; _astate = ACTION_CLEARED;
@@ -617,8 +618,7 @@ public abstract class PuzzleController extends GameController
try { try {
actionWasCleared(); actionWasCleared();
} catch (Exception e) { } catch (Exception e) {
Log.warning("Choked in actionWasCleared"); log.warning("Choked in actionWasCleared", e);
Log.logStackTrace(e);
} }
// notify any penders that the action has cleared // notify any penders that the action has cleared
@@ -734,7 +734,7 @@ public abstract class PuzzleController extends GameController
{ {
// make sure they don't queue things up at strange times // make sure they don't queue things up at strange times
if (_puzobj.state != PuzzleObject.IN_PLAY) { if (_puzobj.state != PuzzleObject.IN_PLAY) {
Log.warning("Rejecting progress event; game not in play " + log.warning("Rejecting progress event; game not in play " +
"[puzobj=" + _puzobj.which() + "[puzobj=" + _puzobj.which() +
", event=" + event + "]."); ", event=" + event + "].");
return; return;
@@ -744,7 +744,7 @@ public abstract class PuzzleController extends GameController
if (isSyncingBoards()) { if (isSyncingBoards()) {
_states.add((board == null) ? null : board.clone()); _states.add((board == null) ? null : board.clone());
if (board == null) { if (board == null) {
Log.warning("Added progress event with no associated board " + log.warning("Added progress event with no associated board " +
"state, server will not be able to ensure " + "state, server will not be able to ensure " +
"board state synchronization."); "board state synchronization.");
} }
@@ -37,11 +37,12 @@ import com.threerings.crowd.data.PlaceObject;
import com.threerings.parlor.game.data.GameConfig; import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.util.RobotPlayer; import com.threerings.parlor.util.RobotPlayer;
import com.threerings.puzzle.Log;
import com.threerings.puzzle.data.PuzzleCodes; import com.threerings.puzzle.data.PuzzleCodes;
import com.threerings.puzzle.data.PuzzleGameCodes; import com.threerings.puzzle.data.PuzzleGameCodes;
import com.threerings.puzzle.util.PuzzleContext; import com.threerings.puzzle.util.PuzzleContext;
import static com.threerings.puzzle.Log.log;
/** /**
* The puzzle panel class should be extended by classes that provide a * The puzzle panel class should be extended by classes that provide a
* view for a puzzle game. The {@link PuzzleController} calls these * view for a puzzle game. The {@link PuzzleController} calls these
@@ -108,7 +109,7 @@ public abstract class PuzzlePanel extends JPanel
{ {
// bail if we've already got an overlay // bail if we've already got an overlay
if (_opanel != null) { if (_opanel != null) {
Log.info("Refusing to push overlay panel, we've already got one " + log.info("Refusing to push overlay panel, we've already got one " +
"[opanel=" + _opanel + ", npanel=" + opanel + "]."); "[opanel=" + _opanel + ", npanel=" + opanel + "].");
return false; return false;
} }
@@ -40,7 +40,6 @@ import com.threerings.media.util.Path;
import com.threerings.parlor.game.data.GameConfig; import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.media.ScoreAnimation; import com.threerings.parlor.media.ScoreAnimation;
import com.threerings.puzzle.Log;
import com.threerings.puzzle.client.PuzzleBoardView; import com.threerings.puzzle.client.PuzzleBoardView;
import com.threerings.puzzle.data.Board; import com.threerings.puzzle.data.Board;
import com.threerings.puzzle.util.PuzzleContext; import com.threerings.puzzle.util.PuzzleContext;
@@ -49,6 +48,8 @@ import com.threerings.puzzle.drop.data.DropBoard;
import com.threerings.puzzle.drop.data.DropConfig; import com.threerings.puzzle.drop.data.DropConfig;
import com.threerings.puzzle.drop.data.DropPieceCodes; import com.threerings.puzzle.drop.data.DropPieceCodes;
import static com.threerings.puzzle.Log.log;
/** /**
* The drop board view displays a drop puzzle game in progress for a * The drop board view displays a drop puzzle game in progress for a
* single player. * single player.
@@ -141,7 +142,7 @@ public abstract class DropBoardView extends PuzzleBoardView
public void createPiece (int piece, int sx, int sy) public void createPiece (int piece, int sx, int sy)
{ {
if (sx < 0 || sy < 0 || sx >= _bwid || sy >= _bhei) { if (sx < 0 || sy < 0 || sx >= _bwid || sy >= _bhei) {
Log.warning("Requested to create piece in invalid location " + log.warning("Requested to create piece in invalid location " +
"[sx=" + sx + ", sy=" + sy + "]."); "[sx=" + sx + ", sy=" + sy + "].");
Thread.dumpStack(); Thread.dumpStack();
return; return;
@@ -171,7 +172,7 @@ public abstract class DropBoardView extends PuzzleBoardView
public void updatePiece (int piece, int sx, int sy) public void updatePiece (int piece, int sx, int sy)
{ {
if (sx < 0 || sy < 0 || sx >= _bwid || sy >= _bhei) { if (sx < 0 || sy < 0 || sx >= _bwid || sy >= _bhei) {
Log.warning("Requested to update piece in invalid location " + log.warning("Requested to update piece in invalid location " +
"[sx=" + sx + ", sy=" + sy + "]."); "[sx=" + sx + ", sy=" + sy + "].");
Thread.dumpStack(); Thread.dumpStack();
return; return;
@@ -192,7 +193,7 @@ public abstract class DropBoardView extends PuzzleBoardView
long duration) long duration)
{ {
if (tx < 0 || ty < 0 || tx >= _bwid || ty >= _bhei) { if (tx < 0 || ty < 0 || tx >= _bwid || ty >= _bhei) {
Log.warning("Requested to create and move piece to invalid " + log.warning("Requested to create and move piece to invalid " +
"location [tx=" + tx + ", ty=" + ty + "]."); "location [tx=" + tx + ", ty=" + ty + "].");
Thread.dumpStack(); Thread.dumpStack();
return; return;
@@ -224,7 +225,7 @@ public abstract class DropBoardView extends PuzzleBoardView
int spos = sy * _bwid + sx; int spos = sy * _bwid + sx;
Sprite piece = _pieces[spos]; Sprite piece = _pieces[spos];
if (piece == null) { if (piece == null) {
Log.warning("Missing source sprite for drop [sx=" + sx + log.warning("Missing source sprite for drop [sx=" + sx +
", sy=" + sy + ", tx=" + tx + ", ty=" + ty + "]."); ", sy=" + sy + ", tx=" + tx + ", ty=" + ty + "].");
return null; return null;
} }
@@ -247,11 +248,9 @@ public abstract class DropBoardView extends PuzzleBoardView
if (sx == tx && sy == ty) { if (sx == tx && sy == ty) {
int tpos = ty * _bwid + tx; int tpos = ty * _bwid + tx;
if (_pieces[tpos] != null) { if (_pieces[tpos] != null) {
Log.warning("Zoiks! Asked to add a piece where we already " + log.warning("Zoiks! Asked to add a piece where we already " +
"have one [sx=" + sx + ", sy=" + sy + "have one [sx=" + sx + ", sy=" + sy +
", tx=" + tx + ", ty=" + ty + "]."); ", tx=" + tx + ", ty=" + ty + "].", where);
Log.logStackTrace(where);
return;
} }
_pieces[tpos] = piece; _pieces[tpos] = piece;
piece.setLocation(start.x, start.y); piece.setLocation(start.x, start.y);
@@ -269,10 +268,9 @@ public abstract class DropBoardView extends PuzzleBoardView
public void pathCompleted (Sprite sprite, Path path, long when) { public void pathCompleted (Sprite sprite, Path path, long when) {
sprite.removeSpriteObserver(this); sprite.removeSpriteObserver(this);
if (_pieces[tpos] != null) { if (_pieces[tpos] != null) {
Log.warning("Oh god, we're dropping onto another piece " + log.warning("Oh god, we're dropping onto another piece " +
"[sx=" + sx + ", sy=" + sy + "[sx=" + sx + ", sy=" + sy +
", tx=" + tx + ", ty=" + ty + "]."); ", tx=" + tx + ", ty=" + ty + "].", where);
Log.logStackTrace(where);
return; return;
} }
_pieces[tpos] = sprite; _pieces[tpos] = sprite;
@@ -39,7 +39,6 @@ import com.threerings.crowd.util.CrowdContext;
import com.threerings.puzzle.util.PuzzleContext; import com.threerings.puzzle.util.PuzzleContext;
import com.threerings.puzzle.Log;
import com.threerings.puzzle.client.PuzzleController; import com.threerings.puzzle.client.PuzzleController;
import com.threerings.puzzle.client.PuzzleControllerDelegate; import com.threerings.puzzle.client.PuzzleControllerDelegate;
import com.threerings.puzzle.client.PuzzlePanel; import com.threerings.puzzle.client.PuzzlePanel;
@@ -55,6 +54,8 @@ import com.threerings.puzzle.drop.util.PieceDropLogic;
import com.threerings.puzzle.drop.util.PieceDropper.PieceDropInfo; import com.threerings.puzzle.drop.util.PieceDropper.PieceDropInfo;
import com.threerings.puzzle.drop.util.PieceDropper; import com.threerings.puzzle.drop.util.PieceDropper;
import static com.threerings.puzzle.Log.log;
/** /**
* Games that wish to make use of the drop puzzle services will need to * Games that wish to make use of the drop puzzle services will need to
* create an extension of this delegate class, customizing it for their * create an extension of this delegate class, customizing it for their
@@ -187,7 +188,7 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
// it on its merry way once more // it on its merry way once more
if (_blocksprite != null) { if (_blocksprite != null) {
long delta = _dview.getTimeStamp() - _blockStamp; long delta = _dview.getTimeStamp() - _blockStamp;
Log.info("Restarting drop sprite [delta=" + delta + "]."); log.info("Restarting drop sprite [delta=" + delta + "].");
_blocksprite.fastForward(delta); _blocksprite.fastForward(delta);
_blockStamp = 0L; _blockStamp = 0L;
_dview.addSprite(_blocksprite); _dview.addSprite(_blocksprite);
@@ -196,7 +197,7 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
// bouncing, we need to land the block to get things going // bouncing, we need to land the block to get things going
// again // again
if (_blocksprite.isBouncing()) { if (_blocksprite.isBouncing()) {
Log.info("Ended on a bounce, landing the block and " + log.info("Ended on a bounce, landing the block and " +
"starting things up."); "starting things up.");
checkBlockLanded("bounced", true, true); checkBlockLanded("bounced", true, true);
} }
@@ -210,7 +211,7 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
protected boolean canClearAction () protected boolean canClearAction ()
{ {
if (!_stable) { if (!_stable) {
Log.info("Rejecting canClear() request because not stable."); log.info("Rejecting canClear() request because not stable.");
} }
return _stable && super.canClearAction(); return _stable && super.canClearAction();
} }
@@ -442,7 +443,7 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
protected void dropNextBlock () protected void dropNextBlock ()
{ {
if (_blocksprite != null || !_ctrl.hasAction()) { if (_blocksprite != null || !_ctrl.hasAction()) {
Log.info("Not dropping block [bs=" + (_blocksprite != null) + log.info("Not dropping block [bs=" + (_blocksprite != null) +
", action=" + _ctrl.hasAction() + "]."); ", action=" + _ctrl.hasAction() + "].");
return; return;
} }
@@ -674,7 +675,7 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
if (_dboard.isValidDrop(rows, cols, pctdone)) { if (_dboard.isValidDrop(rows, cols, pctdone)) {
if (commit) { if (commit) {
Log.info("Not valid drop [source=" + source + log.info("Not valid drop [source=" + source +
", commit=" + commit + ", atTop=" + atTop + ", commit=" + commit + ", atTop=" + atTop +
", pctdone=" + pctdone + "]."); ", pctdone=" + pctdone + "].");
} }
@@ -698,7 +699,7 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
// a valid position, and that we aren't somehow // a valid position, and that we aren't somehow
// overwriting an existing piece // overwriting an existing piece
if (col < 0 || col >= _bwid || row >= _bhei) { if (col < 0 || col >= _bwid || row >= _bhei) {
Log.warning("Placing drop block piece outside board " + log.warning("Placing drop block piece outside board " +
"bounds!? [x=" + col + ", y=" + row + "bounds!? [x=" + col + ", y=" + row +
", pidx=" + ii + ", pidx=" + ii +
", blocksprite=" + _blocksprite + "]."); ", blocksprite=" + _blocksprite + "].");
@@ -707,7 +708,7 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
} else { } else {
int cpiece = _dboard.getPiece(col, row); int cpiece = _dboard.getPiece(col, row);
if (cpiece != PIECE_NONE) { if (cpiece != PIECE_NONE) {
Log.warning("Placing drop block piece onto " + log.warning("Placing drop block piece onto " +
"occupied board position!? [x=" + col + "occupied board position!? [x=" + col +
", y=" + row + ", pidx=" + ii + ", y=" + row + ", pidx=" + ii +
", blocksprite=" + _blocksprite + "]."); ", blocksprite=" + _blocksprite + "].");
@@ -724,7 +725,7 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
if (DEBUG_PUZZLE && error) { if (DEBUG_PUZZLE && error) {
_dboard.dump(); _dboard.dump();
Log.warning("Bailing out in a flaming pyre of glory."); log.warning("Bailing out in a flaming pyre of glory.");
System.exit(0); System.exit(0);
} }
} }
@@ -910,7 +911,7 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
boolean evolving = evolveBoard(); boolean evolving = evolveBoard();
boolean debug = false; boolean debug = false;
if (debug) { if (debug) {
Log.info("Evolved board [evolving=" + evolving + "]."); log.info("Evolved board [evolving=" + evolving + "].");
} }
// if we're no longer evolving and the action has not ended, go // if we're no longer evolving and the action has not ended, go
@@ -922,7 +923,7 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
// this will trigger further puzzle activity // this will trigger further puzzle activity
if (debug) { if (debug) {
Log.info("Board did stabilize"); log.info("Board did stabilize");
} }
boardDidStabilize(); boardDidStabilize();
@@ -930,7 +931,7 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
// evolution, that it will now be cleared // evolution, that it will now be cleared
if (!_ctrl.hasAction()) { if (!_ctrl.hasAction()) {
if (debug) { if (debug) {
Log.info("Maybe clearing action."); log.info("Maybe clearing action.");
} }
maybeClearAction(); maybeClearAction();
} }
@@ -1067,7 +1068,7 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
unstabilizeBoard(); unstabilizeBoard();
} else { } else {
Log.debug("Sticking fork in it [risers=" + log.debug("Sticking fork in it [risers=" +
StringUtil.toString(pieces) + "."); StringUtil.toString(pieces) + ".");
// let the controller know that we're done for // let the controller know that we're done for
@@ -32,7 +32,7 @@ import com.threerings.util.DirectionUtil;
import com.threerings.media.image.Mirage; import com.threerings.media.image.Mirage;
import com.threerings.media.sprite.Sprite; import com.threerings.media.sprite.Sprite;
import com.threerings.puzzle.Log; import static com.threerings.puzzle.Log.log;
/** /**
* The drop sprite is a sprite that displays one or more pieces falling * The drop sprite is a sprite that displays one or more pieces falling
@@ -29,11 +29,12 @@ import org.apache.commons.lang.StringUtils;
import com.threerings.util.DirectionUtil; import com.threerings.util.DirectionUtil;
import com.threerings.puzzle.Log;
import com.threerings.puzzle.data.Board; import com.threerings.puzzle.data.Board;
import com.threerings.puzzle.drop.client.DropControllerDelegate; import com.threerings.puzzle.drop.client.DropControllerDelegate;
import com.threerings.puzzle.drop.util.DropBoardUtil; import com.threerings.puzzle.drop.util.DropBoardUtil;
import static com.threerings.puzzle.Log.log;
/** /**
* A class that provides for various useful logical operations to be enacted on a two-dimensional * A class that provides for various useful logical operations to be enacted on a two-dimensional
* board and provides an easier mechanism for referencing pieces by position. * board and provides an easier mechanism for referencing pieces by position.
@@ -132,8 +133,7 @@ public class DropBoard extends Board
try { try {
return _board[(row*_bwid) + col]; return _board[(row*_bwid) + col];
} catch (Exception e) { } catch (Exception e) {
Log.warning("Failed getting piece [col=" + col + ", row=" + row + ", error=" + e + "]."); log.warning("Failed getting piece [col=" + col + ", row=" + row + "].", e);
Log.logStackTrace(e);
return -1; return -1;
} }
} }
@@ -319,7 +319,7 @@ public class DropBoard extends Board
// this should never happen since even in the most tightly constrained case where the block // this should never happen since even in the most tightly constrained case where the block
// is entirely surrounded by other pieces there are always two valid orientations. // is entirely surrounded by other pieces there are always two valid orientations.
Log.warning("**** We're horked and couldn't rotate at all!"); log.warning("**** We're horked and couldn't rotate at all!");
// System.exit(0); // System.exit(0);
return null; return null;
} }
@@ -425,7 +425,7 @@ public class DropBoard extends Board
return true; return true;
} else { } else {
Log.warning("Attempt to set piece outside board bounds " + log.warning("Attempt to set piece outside board bounds " +
"[col=" + col + ", row=" + row + ", p=" + piece + "]."); "[col=" + col + ", row=" + row + ", p=" + piece + "].");
return false; return false;
} }
@@ -649,7 +649,7 @@ public class DropBoard extends Board
{ {
// make sure the target board is a valid target // make sure the target board is a valid target
if (board.getWidth() != _bwid || board.getHeight() != _bhei) { if (board.getWidth() != _bwid || board.getHeight() != _bhei) {
Log.warning("Can't copy board into destination board with different dimensions " + log.warning("Can't copy board into destination board with different dimensions " +
"[src=" + this + ", dest=" + board + "]."); "[src=" + this + ", dest=" + board + "].");
return; return;
} }
@@ -686,7 +686,7 @@ public class DropBoard extends Board
{ {
int size = (_bwid*_bhei); int size = (_bwid*_bhei);
if (board.length < size) { if (board.length < size) {
Log.warning("Attempt to set board with invalid data size " + log.warning("Attempt to set board with invalid data size " +
"[len=" + board.length + ", expected=" + size + "]."); "[len=" + board.length + ", expected=" + size + "].");
return; return;
} }
@@ -24,7 +24,6 @@ package com.threerings.puzzle.drop.server;
import com.threerings.crowd.data.PlaceConfig; import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
import com.threerings.puzzle.Log;
import com.threerings.puzzle.data.Board; import com.threerings.puzzle.data.Board;
import com.threerings.puzzle.data.PuzzleCodes; import com.threerings.puzzle.data.PuzzleCodes;
import com.threerings.puzzle.server.PuzzleManager; import com.threerings.puzzle.server.PuzzleManager;
@@ -37,6 +36,8 @@ import com.threerings.puzzle.drop.data.DropLogic;
import com.threerings.puzzle.drop.util.PieceDropLogic; import com.threerings.puzzle.drop.util.PieceDropLogic;
import com.threerings.puzzle.drop.util.PieceDropper; import com.threerings.puzzle.drop.util.PieceDropper;
import static com.threerings.puzzle.Log.log;
/** /**
* Provides the necessary support for a puzzle game that involves a * Provides the necessary support for a puzzle game that involves a
* two-dimensional board containing pieces, with new pieces either falling * two-dimensional board containing pieces, with new pieces either falling
@@ -81,7 +82,7 @@ public abstract class DropManagerDelegate extends PuzzleManagerDelegate
_usedrop = logic.useBlockDropping(); _usedrop = logic.useBlockDropping();
_userise = logic.useBoardRising(); _userise = logic.useBoardRising();
if (_usedrop && _userise) { if (_usedrop && _userise) {
Log.warning("Can't use dropping blocks and board rising "+ log.warning("Can't use dropping blocks and board rising "+
"functionality simultaneously in a drop puzzle game! " + "functionality simultaneously in a drop puzzle game! " +
"Falling back to straight dropping."); "Falling back to straight dropping.");
_userise = false; _userise = false;
@@ -27,10 +27,11 @@ import java.util.List;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import com.threerings.puzzle.Log;
import com.threerings.puzzle.drop.data.DropBoard; import com.threerings.puzzle.drop.data.DropBoard;
import com.threerings.puzzle.drop.data.DropPieceCodes; import com.threerings.puzzle.drop.data.DropPieceCodes;
import static com.threerings.puzzle.Log.log;
/** /**
* Handles dropping pieces in a board. * Handles dropping pieces in a board.
*/ */
@@ -156,7 +157,7 @@ public class PieceDropper
int end = _logic.getConstrainedEdge(board, xx, yy, RIGHT); int end = _logic.getConstrainedEdge(board, xx, yy, RIGHT);
int bwid = board.getWidth(); int bwid = board.getWidth();
if (start < 0 || end >= bwid) { if (start < 0 || end >= bwid) {
Log.warning("Board reported bogus constrained edge " + log.warning("Board reported bogus constrained edge " +
"[x=" + xx + ", y=" + yy + ", start=" + start + ", end=" + end + "]."); "[x=" + xx + ", y=" + yy + ", start=" + start + ", end=" + end + "].");
board.dump(); board.dump();
start = Math.max(start, 0); start = Math.max(start, 0);
@@ -42,13 +42,14 @@ import com.threerings.parlor.game.server.GameManager;
import com.threerings.util.MessageBundle; import com.threerings.util.MessageBundle;
import com.threerings.util.Name; import com.threerings.util.Name;
import com.threerings.puzzle.Log;
import com.threerings.puzzle.data.Board; import com.threerings.puzzle.data.Board;
import com.threerings.puzzle.data.BoardSummary; import com.threerings.puzzle.data.BoardSummary;
import com.threerings.puzzle.data.PuzzleCodes; import com.threerings.puzzle.data.PuzzleCodes;
import com.threerings.puzzle.data.PuzzleGameMarshaller; import com.threerings.puzzle.data.PuzzleGameMarshaller;
import com.threerings.puzzle.data.PuzzleObject; import com.threerings.puzzle.data.PuzzleObject;
import static com.threerings.puzzle.Log.log;
/** /**
* Extends the {@link GameManager} with facilities for the puzzle games * Extends the {@link GameManager} with facilities for the puzzle games
* that are used in Yohoho. Only features generic to all of our games are * that are used in Yohoho. Only features generic to all of our games are
@@ -263,7 +264,7 @@ public abstract class PuzzleManager extends GameManager
// log the AI skill levels for games involving AIs as it's useful // log the AI skill levels for games involving AIs as it's useful
// when tuning AI algorithms // when tuning AI algorithms
if (_AIs != null) { if (_AIs != null) {
Log.info("AIs on the job [game=" + _puzobj.which() + log.info("AIs on the job [game=" + _puzobj.which() +
", skillz=" + StringUtil.toString(_AIs) + "]."); ", skillz=" + StringUtil.toString(_AIs) + "].");
} }
} }
@@ -411,7 +412,7 @@ public abstract class PuzzleManager extends GameManager
// apply the event to the player's board // apply the event to the player's board
if (!applyProgressEvent(pidx, gevent, cboard)) { if (!applyProgressEvent(pidx, gevent, cboard)) {
Log.warning("Unknown event [puzzle=" + where() + log.warning("Unknown event [puzzle=" + where() +
", pidx=" + pidx + ", event=" + gevent + "]."); ", pidx=" + pidx + ", event=" + gevent + "].");
} }
@@ -429,19 +430,19 @@ public abstract class PuzzleManager extends GameManager
int gevent, boolean before) int gevent, boolean before)
{ {
if (DEBUG_PUZZLE) { if (DEBUG_PUZZLE) {
Log.info((before ? "About to apply " : "Just applied ") + log.info((before ? "About to apply " : "Just applied ") +
"[game=" + _puzobj.which() + ", pidx=" + pidx + "[game=" + _puzobj.which() + ", pidx=" + pidx +
", event=" + gevent + "]."); ", event=" + gevent + "].");
} }
if (boardstate == null) { if (boardstate == null) {
if (DEBUG_PUZZLE) { if (DEBUG_PUZZLE) {
Log.info("No board state provided. Can't compare."); log.info("No board state provided. Can't compare.");
} }
return; return;
} }
boolean equal = _boards[pidx].equals(boardstate); boolean equal = _boards[pidx].equals(boardstate);
if (!equal) { if (!equal) {
Log.warning("Client and server board states not equal! " + log.warning("Client and server board states not equal! " +
"[game=" + _puzobj.which() + "[game=" + _puzobj.which() +
", type=" + _puzobj.getClass().getName() + "]."); ", type=" + _puzobj.getClass().getName() + "].");
} }
@@ -524,7 +525,7 @@ public abstract class PuzzleManager extends GameManager
// only warn if this isn't a straggling update from the // only warn if this isn't a straggling update from the
// previous round // previous round
if (roundId != _puzobj.roundId-1) { if (roundId != _puzobj.roundId-1) {
Log.warning("Received progress update for invalid round, " + log.warning("Received progress update for invalid round, " +
"not applying [game=" + _puzobj.which() + "not applying [game=" + _puzobj.which() +
", invalidRoundId=" + roundId + ", invalidRoundId=" + roundId +
", roundId=" + _puzobj.roundId + "]."); ", roundId=" + _puzobj.roundId + "].");
@@ -534,7 +535,7 @@ public abstract class PuzzleManager extends GameManager
// if the game is over, we wing straggling updates // if the game is over, we wing straggling updates
if (!_puzobj.isInPlay()) { if (!_puzobj.isInPlay()) {
Log.debug("Ignoring straggling events " + log.debug("Ignoring straggling events " +
"[game=" + _puzobj.which() + "[game=" + _puzobj.which() +
", who=" + caller.who() + ", who=" + caller.who() +
", events=" + StringUtil.toString(events) + "]."); ", events=" + StringUtil.toString(events) + "].");
@@ -544,7 +545,7 @@ public abstract class PuzzleManager extends GameManager
// determine the caller's player index in the game // determine the caller's player index in the game
int pidx = IntListUtil.indexOf(_playerOids, caller.getOid()); int pidx = IntListUtil.indexOf(_playerOids, caller.getOid());
if (pidx == -1) { if (pidx == -1) {
Log.warning("Received progress update for non-player?! " + log.warning("Received progress update for non-player?! " +
"[game=" + _puzobj.which() + ", who=" + caller.who() + "[game=" + _puzobj.which() + ", who=" + caller.who() +
", ploids=" + StringUtil.toString(_playerOids) + "]."); ", ploids=" + StringUtil.toString(_playerOids) + "].");
return; return;
@@ -24,7 +24,7 @@ package com.threerings.puzzle.util;
import java.awt.Point; import java.awt.Point;
import java.util.Iterator; import java.util.Iterator;
import com.threerings.puzzle.Log; import static com.threerings.puzzle.Log.log;
/** /**
* The point set class provides an efficient implementation of a set * The point set class provides an efficient implementation of a set
@@ -224,7 +224,7 @@ public class PointSet
} }
if (_curY >= _rangeY) { if (_curY >= _rangeY) {
Log.warning("Advanced past point range."); log.warning("Advanced past point range.");
_curY = 0; _curY = 0;
} }
} }
+4 -28
View File
@@ -21,36 +21,12 @@
package com.threerings.stage; package com.threerings.stage;
import com.samskivert.util.Logger;
/** /**
* A placeholder class that contains a reference to the log object used by * Contains a reference to the log object used by this package.
* this package.
*/ */
public class Log public class Log
{ {
public static com.samskivert.util.Log log = public static Logger log = Logger.getLogger("com.threerings.stage");
new com.samskivert.util.Log("stage");
/** 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);
}
} }
@@ -30,9 +30,10 @@ import com.threerings.media.tile.TileSet;
import com.threerings.miso.data.ObjectInfo; import com.threerings.miso.data.ObjectInfo;
import com.threerings.stage.Log;
import com.threerings.stage.data.StageScene; import com.threerings.stage.data.StageScene;
import static com.threerings.stage.Log.log;
/** /**
* Handles colorization of object tiles in a scene. * Handles colorization of object tiles in a scene.
*/ */
@@ -123,7 +124,7 @@ public class SceneColorizer implements TileSet.Colorizer
// 3. If there are no defaults whatsoever, just hash on the sceneId. // 3. If there are no defaults whatsoever, just hash on the sceneId.
int[] cids = (int[])_cids.get(zation); int[] cids = (int[])_cids.get(zation);
if (cids == null) { if (cids == null) {
Log.warning("Zoiks, have no colorizations for '" + log.warning("Zoiks, have no colorizations for '" +
zation + "'."); zation + "'.");
return -1; return -1;
} else { } else {
@@ -29,10 +29,11 @@ import com.threerings.crowd.util.CrowdContext;
import com.threerings.whirled.data.SceneUpdate; import com.threerings.whirled.data.SceneUpdate;
import com.threerings.whirled.spot.client.SpotSceneController; import com.threerings.whirled.spot.client.SpotSceneController;
import com.threerings.stage.Log;
import com.threerings.stage.data.StageLocation; import com.threerings.stage.data.StageLocation;
import com.threerings.stage.util.StageContext; import com.threerings.stage.util.StageContext;
import static com.threerings.stage.Log.log;
/** /**
* Extends the {@link SpotSceneController} with functionality specific to * Extends the {@link SpotSceneController} with functionality specific to
* displaying Stage scenes. * displaying Stage scenes.
@@ -44,7 +45,7 @@ public class StageSceneController extends SpotSceneController
*/ */
public void handleLocationClicked (Object source, StageLocation loc) public void handleLocationClicked (Object source, StageLocation loc)
{ {
Log.warning("handleLocationClicked(" + source + ", " + loc + ")"); log.warning("handleLocationClicked(" + source + ", " + loc + ")");
} }
/** /**
@@ -55,7 +56,7 @@ public class StageSceneController extends SpotSceneController
*/ */
public void handleClusterClicked (Object source, Tuple tuple) public void handleClusterClicked (Object source, Tuple tuple)
{ {
Log.warning("handleClusterClicked(" + source + ", " + tuple + ")"); log.warning("handleClusterClicked(" + source + ", " + tuple + ")");
} }
// documentation inherited // documentation inherited
@@ -70,7 +70,6 @@ import com.threerings.whirled.spot.data.Location;
import com.threerings.whirled.spot.data.Portal; import com.threerings.whirled.spot.data.Portal;
import com.threerings.whirled.spot.data.SceneLocation; import com.threerings.whirled.spot.data.SceneLocation;
import com.threerings.stage.Log;
import com.threerings.stage.data.StageLocation; import com.threerings.stage.data.StageLocation;
import com.threerings.stage.data.StageMisoSceneModel; import com.threerings.stage.data.StageMisoSceneModel;
import com.threerings.stage.data.StageScene; import com.threerings.stage.data.StageScene;
@@ -78,6 +77,8 @@ import com.threerings.stage.data.StageSceneModel;
import com.threerings.stage.util.StageContext; import com.threerings.stage.util.StageContext;
import com.threerings.stage.util.StageSceneUtil; import com.threerings.stage.util.StageSceneUtil;
import static com.threerings.stage.Log.log;
/** /**
* Extends the basic Miso scene panel with Stage fun stuff like portals, * Extends the basic Miso scene panel with Stage fun stuff like portals,
* clusters and locations. * clusters and locations.
@@ -149,7 +150,7 @@ public class StageScenePanel extends MisoScenePanel
setSceneModel(StageMisoSceneModel.getSceneModel( setSceneModel(StageMisoSceneModel.getSceneModel(
scene.getSceneModel())); scene.getSceneModel()));
} else { } else {
Log.warning("Zoiks! We can't display a null scene!"); log.warning("Zoiks! We can't display a null scene!");
// TODO: display something to the user letting them know that // TODO: display something to the user letting them know that
// we're so hosed that we don't even know what time it is // we're so hosed that we don't even know what time it is
} }
@@ -38,7 +38,7 @@ import com.threerings.whirled.spot.data.SpotScene;
import com.threerings.whirled.spot.data.SpotSceneImpl; import com.threerings.whirled.spot.data.SpotSceneImpl;
import com.threerings.whirled.spot.data.SpotSceneModel; import com.threerings.whirled.spot.data.SpotSceneModel;
import com.threerings.stage.Log; import static com.threerings.stage.Log.log;
/** /**
* The implementation of the Stage scene interface. * The implementation of the Stage scene interface.
@@ -119,7 +119,7 @@ public class StageScene extends SceneImpl
StageMisoSceneModel mmodel = StageMisoSceneModel.getSceneModel(_model); StageMisoSceneModel mmodel = StageMisoSceneModel.getSceneModel(_model);
if (mmodel != null) { if (mmodel != null) {
if (!mmodel.addObject(info)) { if (!mmodel.addObject(info)) {
Log.warning("Scene model rejected object add " + log.warning("Scene model rejected object add " +
"[scene=" + this + ", object=" + info + "]."); "[scene=" + this + ", object=" + info + "].");
} }
} }
@@ -47,7 +47,6 @@ import com.threerings.whirled.spot.data.Portal;
import com.threerings.whirled.spot.data.SceneLocation; import com.threerings.whirled.spot.data.SceneLocation;
import com.threerings.whirled.spot.server.SpotSceneManager; import com.threerings.whirled.spot.server.SpotSceneManager;
import com.threerings.stage.Log;
import com.threerings.stage.client.StageSceneService; import com.threerings.stage.client.StageSceneService;
import com.threerings.stage.data.DefaultColorUpdate; import com.threerings.stage.data.DefaultColorUpdate;
import com.threerings.stage.data.ModifyObjectsUpdate; import com.threerings.stage.data.ModifyObjectsUpdate;
@@ -61,6 +60,8 @@ import com.threerings.stage.data.StageSceneModel;
import com.threerings.stage.data.StageSceneObject; import com.threerings.stage.data.StageSceneObject;
import com.threerings.stage.util.StageSceneUtil; import com.threerings.stage.util.StageSceneUtil;
import static com.threerings.stage.Log.log;
/** /**
* Defines extensions to the basic Stage scene manager specific to * Defines extensions to the basic Stage scene manager specific to
* displaying isometric "stage" scenes (these may be indoor, outdoor or * displaying isometric "stage" scenes (these may be indoor, outdoor or
@@ -111,7 +112,7 @@ public class StageSceneManager extends SpotSceneManager
Rectangle foot = StageSceneUtil.getObjectFootprint( Rectangle foot = StageSceneUtil.getObjectFootprint(
StageServer.tilemgr, info.tileId, info.x, info.y); StageServer.tilemgr, info.tileId, info.x, info.y);
if (foot == null) { if (foot == null) {
Log.warning("Aiya! Unable to compute object footprint! " + log.warning("Aiya! Unable to compute object footprint! " +
"[where=" + where() + ", info=" + info + "]."); "[where=" + where() + ", info=" + info + "].");
return false; return false;
} }
@@ -130,7 +131,7 @@ public class StageSceneManager extends SpotSceneManager
update.init(_sscene.getId(), _sscene.getVersion(), update.init(_sscene.getId(), _sscene.getVersion(),
new ObjectInfo[] { info }, killOverlap ? lappers : null); new ObjectInfo[] { info }, killOverlap ? lappers : null);
Log.info("Modifying objects '" + update + "."); log.info("Modifying objects '" + update + ".");
recordUpdate(update, true); recordUpdate(update, true);
return true; return true;
@@ -197,7 +198,7 @@ public class StageSceneManager extends SpotSceneManager
ModifyObjectsUpdate update = new ModifyObjectsUpdate(); ModifyObjectsUpdate update = new ModifyObjectsUpdate();
update.init(_sscene.getId(), _sscene.getVersion(), null, info); update.init(_sscene.getId(), _sscene.getVersion(), null, info);
Log.info("Modifying objects '" + update + "."); log.info("Modifying objects '" + update + ".");
recordUpdate(update, true); recordUpdate(update, true);
listener.requestProcessed(); listener.requestProcessed();
@@ -393,7 +394,7 @@ public class StageSceneManager extends SpotSceneManager
{ {
// sanity check // sanity check
if (entry == null) { if (entry == null) {
Log.warning("Requested to compute entering location for " + log.warning("Requested to compute entering location for " +
"non-existent portal [where=" + where() + "non-existent portal [where=" + where() +
", who=" + body.who() + "]."); ", who=" + body.who() + "].");
entry = _sscene.getDefaultEntrance(); entry = _sscene.getDefaultEntrance();
@@ -553,7 +554,7 @@ public class StageSceneManager extends SpotSceneManager
// make sure this person isn't already in our cluster // make sure this person isn't already in our cluster
ClusterObject clobj = clrec.getClusterObject(); ClusterObject clobj = clrec.getClusterObject();
if (clobj != null && clobj.occupants.contains(bodyOid)) { if (clobj != null && clobj.occupants.contains(bodyOid)) {
Log.warning("Ignoring stale occupant [where=" + where() + log.warning("Ignoring stale occupant [where=" + where() +
", cluster=" + cl + ", occ=" + bodyOid + "]."); ", cluster=" + cl + ", occ=" + bodyOid + "].");
continue; continue;
} }
@@ -561,7 +562,7 @@ public class StageSceneManager extends SpotSceneManager
// make sure the subsumee exists // make sure the subsumee exists
final BodyObject bobj = (BodyObject)StageServer.omgr.getObject(bodyOid); final BodyObject bobj = (BodyObject)StageServer.omgr.getObject(bodyOid);
if (bobj == null) { if (bobj == null) {
Log.warning("Can't subsume disappeared body " + log.warning("Can't subsume disappeared body " +
"[where=" + where() + ", cluster=" + cl + "[where=" + where() + ", cluster=" + cl +
", boid=" + bodyOid + "]."); ", boid=" + bodyOid + "].");
continue; continue;
@@ -574,12 +575,12 @@ public class StageSceneManager extends SpotSceneManager
StageServer.omgr.postRunnable(new Runnable() { StageServer.omgr.postRunnable(new Runnable() {
public void run () { public void run () {
try { try {
Log.info("Subsuming " + bobj.who() + log.info("Subsuming " + bobj.who() +
" into " + fclrec.getCluster() + "."); " into " + fclrec.getCluster() + ".");
fclrec.addBody(bobj); fclrec.addBody(bobj);
} catch (InvocationException ie) { } catch (InvocationException ie) {
Log.info("Unable to subsume neighbor " + log.info("Unable to subsume neighbor " +
"[cluster=" + fclrec.getCluster() + "[cluster=" + fclrec.getCluster() +
", neighbor=" + bobj.who() + ", neighbor=" + bobj.who() +
", cause=" + ie.getMessage() + "]."); ", cause=" + ie.getMessage() + "].");
@@ -672,7 +673,7 @@ public class StageSceneManager extends SpotSceneManager
cl.width = 1; cl.height = 1; cl.width = 1; cl.height = 1;
SceneLocation loc = locationForBody(bodyOid); SceneLocation loc = locationForBody(bodyOid);
if (loc == null) { if (loc == null) {
Log.warning("Foreign body added to cluster [clrec=" + clrec + log.warning("Foreign body added to cluster [clrec=" + clrec +
", body=" + body.who() + "]."); ", body=" + body.who() + "].");
cl.x = 10; cl.y = 10; cl.x = 10; cl.y = 10;
} else { } else {
@@ -710,7 +711,7 @@ public class StageSceneManager extends SpotSceneManager
if (sloc == null) { if (sloc == null) {
BodyObject user = (BodyObject)StageServer.omgr.getObject(bodyOid); BodyObject user = (BodyObject)StageServer.omgr.getObject(bodyOid);
String who = (user == null) ? ("" + bodyOid) : user.who(); String who = (user == null) ? ("" + bodyOid) : user.who();
Log.warning("Can't position locationless user " + log.warning("Can't position locationless user " +
"[where=" + where() + ", cluster=" + cl + "[where=" + where() + ", cluster=" + cl +
", boid=" + who + "]."); ", boid=" + who + "].");
return; return;
@@ -772,7 +773,7 @@ public class StageSceneManager extends SpotSceneManager
StageOccupantInfo info = (StageOccupantInfo)_ssobj.occupantInfo.get( StageOccupantInfo info = (StageOccupantInfo)_ssobj.occupantInfo.get(
Integer.valueOf(target.getOid())); Integer.valueOf(target.getOid()));
if (info == null) { if (info == null) {
Log.warning("Have no occinfo for cluster target " + log.warning("Have no occinfo for cluster target " +
"[where=" + where() + ", init=" + initiator.who() + "[where=" + where() + ", init=" + initiator.who() +
", target=" + target.who() + "]."); ", target=" + target.who() + "].");
throw new InvocationException(INTERNAL_ERROR); throw new InvocationException(INTERNAL_ERROR);
@@ -28,9 +28,10 @@ import com.threerings.media.tile.bundle.BundledTileSetRepository;
import com.threerings.whirled.server.WhirledServer; import com.threerings.whirled.server.WhirledServer;
import com.threerings.stage.Log;
import com.threerings.stage.data.StageCodes; import com.threerings.stage.data.StageCodes;
import static com.threerings.stage.Log.log;
/** /**
* Extends the Whirled server to provide services needed by the Stage * Extends the Whirled server to provide services needed by the Stage
* system. * system.
@@ -62,7 +63,7 @@ public abstract class StageServer extends WhirledServer
new BundledTileSetRepository(rsrcmgr, null, new BundledTileSetRepository(rsrcmgr, null,
StageCodes.TILESET_RSRC_SET)); StageCodes.TILESET_RSRC_SET));
Log.info("Stage server initialized."); log.info("Stage server initialized.");
} }
/** /**
@@ -69,6 +69,8 @@ import com.threerings.stage.data.StageSceneModel;
import com.threerings.stage.tools.editor.util.EditorContext; import com.threerings.stage.tools.editor.util.EditorContext;
import com.threerings.stage.tools.xml.StageSceneWriter; import com.threerings.stage.tools.xml.StageSceneWriter;
import static com.threerings.stage.Log.log;
/** /**
* A scene editor application that provides facilities for viewing, * A scene editor application that provides facilities for viewing,
* editing, and saving the scene templates that comprise a game. * editing, and saving the scene templates that comprise a game.
@@ -84,7 +86,7 @@ public class EditorApp implements Runnable
final String target = (args.length > 0) ? args[0] : null; final String target = (args.length > 0) ? args[0] : null;
if (System.getProperty("no_log_redir") != null) { if (System.getProperty("no_log_redir") != null) {
Log.info("Logging to console only."); log.info("Logging to console only.");
} else { } else {
String dlog = localDataDir("editor.log"); String dlog = localDataDir("editor.log");
@@ -93,10 +95,10 @@ public class EditorApp implements Runnable
new BufferedOutputStream(new FileOutputStream(dlog)), true); new BufferedOutputStream(new FileOutputStream(dlog)), true);
System.setOut(logOut); System.setOut(logOut);
System.setErr(logOut); System.setErr(logOut);
Log.info("Opened debug log '" + dlog + "'."); log.info("Opened debug log '" + dlog + "'.");
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Failed to open debug log [path=" + dlog + log.warning("Failed to open debug log [path=" + dlog +
", error=" + ioe + "]."); ", error=" + ioe + "].");
} }
} }
@@ -145,8 +147,7 @@ public class EditorApp implements Runnable
} }
public void initializationFailed (Exception e) { public void initializationFailed (Exception e) {
Log.warning("Failed unpacking bundles [e=" + e + "]."); log.warning("Failed unpacking bundles [e=" + e + "].", e);
Log.logStackTrace(e);
} }
}; };
// we want our methods called on the AWT thread // we want our methods called on the AWT thread
@@ -166,7 +167,7 @@ public class EditorApp implements Runnable
_crepo = new BundledComponentRepository( _crepo = new BundledComponentRepository(
_rmgr, _imgr, "components"); _rmgr, _imgr, "components");
} catch (IOException e) { } catch (IOException e) {
Log.warning("Exception loading tilesets and and icon manager " + log.warning("Exception loading tilesets and and icon manager " +
"[Exception=" + e + "]."); "[Exception=" + e + "].");
return; return;
} }
@@ -224,13 +225,12 @@ public class EditorApp implements Runnable
} catch (Throwable t) { } catch (Throwable t) {
// Win98 seems to choke on it's own vomit when we attempt to // Win98 seems to choke on it's own vomit when we attempt to
// enumerate the available display modes; yay! // enumerate the available display modes; yay!
Log.warning("Failed to probe display mode."); log.warning("Failed to probe display mode.", t);
Log.logStackTrace(t);
} }
if (_viewFullScreen.getValue() && gd.isFullScreenSupported() && if (_viewFullScreen.getValue() && gd.isFullScreenSupported() &&
pmode != null) { pmode != null) {
Log.info("Switching to screen mode " + log.info("Switching to screen mode " +
"[mode=" + ModeUtil.toString(pmode) + "]."); "[mode=" + ModeUtil.toString(pmode) + "].");
// set the frame to undecorated, full-screen // set the frame to undecorated, full-screen
_frame.setUndecorated(true); _frame.setUndecorated(true);
@@ -277,8 +277,7 @@ public class EditorApp implements Runnable
EventQueue.invokeLater(app); EventQueue.invokeLater(app);
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Unable to initialize editor."); log.warning("Unable to initialize editor.", ioe);
Log.logStackTrace(ioe);
} }
} }
@@ -328,7 +327,7 @@ public class EditorApp implements Runnable
public String xlate (String bundle, String message) { public String xlate (String bundle, String message) {
MessageBundle mbundle = _msgmgr.getBundle(bundle); MessageBundle mbundle = _msgmgr.getBundle(bundle);
if (mbundle == null) { if (mbundle == null) {
Log.warning("Requested to translate message with " + log.warning("Requested to translate message with " +
"non-existent bundle [bundle=" + bundle + "non-existent bundle [bundle=" + bundle +
", message=" + message + "]."); ", message=" + message + "].");
return message; return message;
@@ -52,6 +52,7 @@ import com.samskivert.swing.util.SwingUtil;
import com.threerings.media.ManagedJFrame; import com.threerings.media.ManagedJFrame;
import com.threerings.miso.tile.BaseTileSet; import com.threerings.miso.tile.BaseTileSet;
import com.threerings.miso.util.MisoSceneMetrics; import com.threerings.miso.util.MisoSceneMetrics;
import com.threerings.stage.data.StageScene; import com.threerings.stage.data.StageScene;
import com.threerings.stage.data.StageSceneModel; import com.threerings.stage.data.StageSceneModel;
import com.threerings.stage.tools.editor.util.EditorContext; import com.threerings.stage.tools.editor.util.EditorContext;
@@ -60,6 +61,8 @@ import com.threerings.stage.tools.xml.StageSceneParser;
import com.threerings.stage.tools.xml.StageSceneWriter; import com.threerings.stage.tools.xml.StageSceneWriter;
import com.threerings.whirled.tools.xml.SceneParser; import com.threerings.whirled.tools.xml.SceneParser;
import static com.threerings.stage.Log.log;
public class EditorFrame extends ManagedJFrame public class EditorFrame extends ManagedJFrame
{ {
public EditorFrame (StageSceneWriter writer) public EditorFrame (StageSceneWriter writer)
@@ -171,8 +174,7 @@ public class EditorFrame extends ManagedJFrame
try { try {
loaded = loadScene(lastFile); loaded = loadScene(lastFile);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Unable to load last scene, creating new one [file=" + lastFile + "]"); log.warning("Unable to load last scene, creating new one", "file", lastFile, e);
Log.logStackTrace(e);
} }
} }
if (!loaded) { if (!loaded) {
@@ -290,8 +292,7 @@ public class EditorFrame extends ManagedJFrame
setScene(new StageScene(model, null)); setScene(new StageScene(model, null));
} catch (Exception e) { } catch (Exception e) {
Log.warning("Unable to set blank scene."); log.warning("Unable to set blank scene.", e);
Log.logStackTrace(e);
} }
} }
@@ -337,7 +338,7 @@ public class EditorFrame extends ManagedJFrame
} catch (Exception e) { } catch (Exception e) {
errmsg = "Parse error: " + e; errmsg = "Parse error: " + e;
Log.logStackTrace(e); log.warning(e);
} }
if (errmsg != null) { if (errmsg != null) {
@@ -387,14 +388,14 @@ public class EditorFrame extends ManagedJFrame
// the old file // the old file
File sfile = new File(_filepath); File sfile = new File(_filepath);
if (!sfile.delete()) { if (!sfile.delete()) {
Log.warning("Aiya! Not able to remove " + _filepath + log.warning("Aiya! Not able to remove " + _filepath +
" so that we can replace it with " + " so that we can replace it with " +
tmpfile.getPath() + "."); tmpfile.getPath() + ".");
} }
// now rename the new save file into place // now rename the new save file into place
if (!tmpfile.renameTo(sfile)) { if (!tmpfile.renameTo(sfile)) {
Log.warning("Fork! Not able to rename " + tmpfile.getPath() + log.warning("Fork! Not able to rename " + tmpfile.getPath() +
" to " + _filepath + "."); " to " + _filepath + ".");
} }
@@ -402,9 +403,7 @@ public class EditorFrame extends ManagedJFrame
String errmsg = "Unable to save scene to " + _filepath + ":\n" + e; String errmsg = "Unable to save scene to " + _filepath + ":\n" + e;
JOptionPane.showMessageDialog( JOptionPane.showMessageDialog(
this, errmsg, "Save error", JOptionPane.ERROR_MESSAGE); this, errmsg, "Save error", JOptionPane.ERROR_MESSAGE);
Log.warning("Error writing scene " + log.warning("Error writing scene [fname=" + _filepath + "].", e);
"[fname=" + _filepath + ", e=" + e + "].");
Log.logStackTrace(e);
} }
} }
@@ -514,7 +513,7 @@ public class EditorFrame extends ManagedJFrame
if (_model.getTileSet() instanceof BaseTileSet) { if (_model.getTileSet() instanceof BaseTileSet) {
_svpanel.updateDefaultTileSet(_model.getTileSetId()); _svpanel.updateDefaultTileSet(_model.getTileSetId());
} else { } else {
Log.warning("Not making non-base tileset into default " + log.warning("Not making non-base tileset into default " +
_model.getTileSet() + "."); _model.getTileSet() + ".");
} }
} }
@@ -545,7 +544,7 @@ public class EditorFrame extends ManagedJFrame
break; break;
default: default:
Log.warning("Wha? Weird dialog type " + _chooser.getDialogType() + "."); log.warning("Wha? Weird dialog type " + _chooser.getDialogType() + ".");
break; break;
} }
} }
@@ -30,6 +30,8 @@ import com.threerings.media.tile.TileUtil;
import com.threerings.util.DirectionCodes; import com.threerings.util.DirectionCodes;
import static com.threerings.stage.Log.log;
/** /**
* The EditorModel class provides a holding place for storing, * The EditorModel class provides a holding place for storing,
* modifying and retrieving data that is shared across the Editor * modifying and retrieving data that is shared across the Editor
@@ -183,7 +185,7 @@ public class EditorModel
} }
} }
Log.warning("Attempt to set to unknown mode [cmd=" + cmd + "]."); log.warning("Attempt to set to unknown mode [cmd=" + cmd + "].");
} }
/** /**
@@ -75,6 +75,8 @@ import com.threerings.stage.tools.editor.util.EditorContext;
import com.threerings.stage.tools.editor.util.EditorDialogUtil; import com.threerings.stage.tools.editor.util.EditorDialogUtil;
import com.threerings.stage.tools.editor.util.ExtrasPainter; import com.threerings.stage.tools.editor.util.ExtrasPainter;
import static com.threerings.stage.Log.log;
/** /**
* Displays the scene view and handles UI events on the scene. Various * Displays the scene view and handles UI events on the scene. Various
* actions may be performed on the scene depending on the selected action * actions may be performed on the scene depending on the selected action
@@ -204,7 +206,7 @@ public class EditorScenePanel extends StageScenePanel
_vertRange.setRangeProperties( _vertRange.setRangeProperties(
vval, _vbounds.height, _area.y, vmax, false); vval, _vbounds.height, _area.y, vmax, false);
// Log.info("Updated extents area:" + StringUtil.toString(_area) + // log.info("Updated extents area:" + StringUtil.toString(_area) +
// " vb:" + StringUtil.toString(_vbounds) + "."); // " vb:" + StringUtil.toString(_vbounds) + ".");
// update the dimensions of the scrollbox // update the dimensions of the scrollbox
@@ -251,7 +253,7 @@ public class EditorScenePanel extends StageScenePanel
protected void deleteTile (int x, int y) protected void deleteTile (int x, int y)
{ {
Rectangle drag = clearTileSelectRegion(x, y); Rectangle drag = clearTileSelectRegion(x, y);
Log.info("Deleting " + drag); log.info("Deleting " + drag);
switch (_emodel.getLayerIndex()) { switch (_emodel.getLayerIndex()) {
case EditorModel.BASE_LAYER: case EditorModel.BASE_LAYER:
@@ -658,7 +660,7 @@ public class EditorScenePanel extends StageScenePanel
} }
return true; return true;
} }
Log.warning("Requested to remove unknown object " + scobj + "."); log.warning("Requested to remove unknown object " + scobj + ".");
return false; return false;
} }
@@ -32,6 +32,8 @@ import com.threerings.media.tile.TileIcon;
import com.threerings.media.tile.TileManager; import com.threerings.media.tile.TileManager;
import com.threerings.media.tile.UniformTileSet; import com.threerings.media.tile.UniformTileSet;
import static com.threerings.stage.Log.log;
public class EditorToolBarPanel extends JPanel implements ActionListener public class EditorToolBarPanel extends JPanel implements ActionListener
{ {
public EditorToolBarPanel (TileManager tilemgr, EditorModel model) public EditorToolBarPanel (TileManager tilemgr, EditorModel model)
@@ -63,7 +65,7 @@ public class EditorToolBarPanel extends JPanel implements ActionListener
_buttons.add(b); _buttons.add(b);
} else { } else {
Log.warning("Unable to load toolbar icon " + log.warning("Unable to load toolbar icon " +
"[index=" + ii + "]."); "[index=" + ii + "].");
} }
} }
@@ -113,7 +115,7 @@ public class EditorToolBarPanel extends JPanel implements ActionListener
_model.setActionMode(cmd.substring(5)); _model.setActionMode(cmd.substring(5));
} else { } else {
Log.warning("Unknown action command [cmd=" + cmd + "]."); log.warning("Unknown action command [cmd=" + cmd + "].");
} }
} }
@@ -1,56 +0,0 @@
//
// $Id$
//
// Vilya library - tools for developing networked games
// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/vilya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.stage.tools.editor;
/**
* A placeholder class that contains a reference to the log object used by
* this package.
*/
public class Log
{
public static com.samskivert.util.Log log =
new com.samskivert.util.Log("stage.tools.editor");
/** 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);
}
}
@@ -38,6 +38,8 @@ import com.samskivert.swing.VGroupLayout;
import com.threerings.stage.tools.editor.util.EditorDialogUtil; import com.threerings.stage.tools.editor.util.EditorDialogUtil;
import static com.threerings.stage.Log.log;
/** /**
* A dialog for editing preferences. * A dialog for editing preferences.
*/ */
@@ -87,7 +89,7 @@ public class PreferencesDialog extends JInternalFrame
EditorDialogUtil.dispose(this); EditorDialogUtil.dispose(this);
} else { } else {
Log.warning("Unknown action command [cmd=" + cmd + "]."); log.warning("Unknown action command [cmd=" + cmd + "].");
} }
} }
@@ -42,6 +42,8 @@ import com.threerings.media.tile.tools.xml.ObjectTileSetRuleSet;
import com.threerings.media.tile.tools.xml.SwissArmyTileSetRuleSet; import com.threerings.media.tile.tools.xml.SwissArmyTileSetRuleSet;
import com.threerings.media.tile.tools.xml.XMLTileSetParser; import com.threerings.media.tile.tools.xml.XMLTileSetParser;
import static com.threerings.stage.Log.log;
/** /**
* The TestTileLoader handles test tiles. Test tiles are tiles that an * The TestTileLoader handles test tiles. Test tiles are tiles that an
* artist can load in on-the-fly to see how things look in the scene editor. * artist can load in on-the-fly to see how things look in the scene editor.
@@ -83,7 +85,7 @@ public class TestTileLoader implements TileSetIDBroker
File testdir = new File(directory); File testdir = new File(directory);
// make sure it's a directory // make sure it's a directory
if (!testdir.isDirectory()) { if (!testdir.isDirectory()) {
Log.warning("Test tileset directory is not actually a directory: " + log.warning("Test tileset directory is not actually a directory: " +
directory); directory);
return map; return map;
} }
@@ -124,8 +126,7 @@ public class TestTileLoader implements TileSetIDBroker
try { try {
_parser.loadTileSets(xmlfile, tiles); _parser.loadTileSets(xmlfile, tiles);
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Error while parsing " + xmlfile.getPath()); log.warning("Error while parsing " + xmlfile.getPath(), ioe);
Log.logStackTrace(ioe);
continue; continue;
} }
@@ -67,6 +67,8 @@ import com.threerings.media.tile.TileSetRepository;
import com.threerings.stage.tools.editor.util.EditorContext; import com.threerings.stage.tools.editor.util.EditorContext;
import com.threerings.stage.tools.editor.util.TileSetUtil; import com.threerings.stage.tools.editor.util.TileSetUtil;
import static com.threerings.stage.Log.log;
/** /**
* The tile info panel presents the user with options to select the * The tile info panel presents the user with options to select the
* tile to be applied to the scene. * tile to be applied to the scene.
@@ -114,8 +116,7 @@ public class TileInfoPanel extends JSplitPane
} }
} catch (Exception e) { } catch (Exception e) {
Log.warning("Error enumerating tilesets."); log.warning("Error enumerating tilesets.", e);
Log.logStackTrace(e);
} }
// set up a border denoting our contents // set up a border denoting our contents
@@ -271,7 +272,7 @@ public class TileInfoPanel extends JSplitPane
Object uobj = node.getUserObject(); Object uobj = node.getUserObject();
if (!(uobj instanceof TileSetRecord)) { if (!(uobj instanceof TileSetRecord)) {
Log.info("Eh? Non-TileSetRecord leaf [obj=" + uobj + log.info("Eh? Non-TileSetRecord leaf [obj=" + uobj +
", class=" + StringUtil.shortClassName(uobj) + "]."); ", class=" + StringUtil.shortClassName(uobj) + "].");
return; return;
} }
@@ -24,7 +24,6 @@ package com.threerings.stage.tools.editor.util;
import com.threerings.media.tile.TileSet; import com.threerings.media.tile.TileSet;
import com.threerings.miso.tile.BaseTileSet; import com.threerings.miso.tile.BaseTileSet;
import com.threerings.stage.tools.editor.Log;
import com.threerings.stage.tools.editor.EditorModel; import com.threerings.stage.tools.editor.EditorModel;
/** /**
@@ -50,9 +50,10 @@ import com.threerings.cast.ComponentRepository;
import com.threerings.miso.tile.MisoTileManager; import com.threerings.miso.tile.MisoTileManager;
import com.threerings.stage.Log;
import com.threerings.stage.util.StageContext; import com.threerings.stage.util.StageContext;
import static com.threerings.stage.Log.log;
/** /**
* The ViewerApp is a scene viewing application that allows for trying out * The ViewerApp is a scene viewing application that allows for trying out
* Stage scenes in a pseudo-runtime environment. * Stage scenes in a pseudo-runtime environment.
@@ -71,7 +72,7 @@ public class ViewerApp
// get the target graphics device // get the target graphics device
GraphicsDevice gd = env.getDefaultScreenDevice(); GraphicsDevice gd = env.getDefaultScreenDevice();
Log.info("Graphics device [dev=" + gd + log.info("Graphics device [dev=" + gd +
", mem=" + gd.getAvailableAcceleratedMemory() + ", mem=" + gd.getAvailableAcceleratedMemory() +
", displayChange=" + gd.isDisplayChangeSupported() + ", displayChange=" + gd.isDisplayChangeSupported() +
", fullScreen=" + gd.isFullScreenSupported() + "]."); ", fullScreen=" + gd.isFullScreenSupported() + "].");
@@ -79,7 +80,7 @@ public class ViewerApp
// get the graphics configuration and display mode information // get the graphics configuration and display mode information
GraphicsConfiguration gc = gd.getDefaultConfiguration(); GraphicsConfiguration gc = gd.getDefaultConfiguration();
DisplayMode dm = gd.getDisplayMode(); DisplayMode dm = gd.getDisplayMode();
Log.info("Display mode [bits=" + dm.getBitDepth() + log.info("Display mode [bits=" + dm.getBitDepth() +
", wid=" + dm.getWidth() + ", hei=" + dm.getHeight() + ", wid=" + dm.getWidth() + ", hei=" + dm.getHeight() +
", refresh=" + dm.getRefreshRate() + "]."); ", refresh=" + dm.getRefreshRate() + "].");
@@ -105,7 +106,7 @@ public class ViewerApp
// size and position the window, entering full-screen exclusive // size and position the window, entering full-screen exclusive
// mode if available and desired // mode if available and desired
if (gd.isFullScreenSupported() /* && _viewFullScreen.getValue() */) { if (gd.isFullScreenSupported() /* && _viewFullScreen.getValue() */) {
Log.info("Entering full-screen exclusive mode."); log.info("Entering full-screen exclusive mode.");
gd.setFullScreenWindow(_frame); gd.setFullScreenWindow(_frame);
} else { } else {
_frame.setSize(640, 575); _frame.setSize(640, 575);
@@ -46,12 +46,13 @@ import com.threerings.whirled.spot.data.Location;
import com.threerings.whirled.spot.data.Portal; import com.threerings.whirled.spot.data.Portal;
import com.threerings.whirled.spot.data.SpotSceneModel; import com.threerings.whirled.spot.data.SpotSceneModel;
import com.threerings.stage.Log;
import com.threerings.stage.data.StageScene; import com.threerings.stage.data.StageScene;
import com.threerings.stage.data.StageSceneModel; import com.threerings.stage.data.StageSceneModel;
import com.threerings.stage.tools.xml.StageSceneParser; import com.threerings.stage.tools.xml.StageSceneParser;
import com.threerings.stage.util.StageContext; import com.threerings.stage.util.StageContext;
import static com.threerings.stage.Log.log;
/** /**
* The viewer frame is the main application window. * The viewer frame is the main application window.
*/ */
@@ -167,7 +168,7 @@ public class ViewerFrame extends ManagedJFrame
} }
} }
if (defloc == null) { if (defloc == null) {
Log.warning("Scene has no def. entrance '" + path + "'."); log.warning("Scene has no def. entrance '" + path + "'.");
} }
_panel.setScene(new StageScene(model, null), defloc); _panel.setScene(new StageScene(model, null), defloc);
@@ -175,7 +176,7 @@ public class ViewerFrame extends ManagedJFrame
} catch (Exception e) { } catch (Exception e) {
errmsg = "Error parsing scene file '" + path + "'."; errmsg = "Error parsing scene file '" + path + "'.";
Log.logStackTrace(e); log.warning(e);
} }
if (errmsg != null) { if (errmsg != null) {
@@ -48,11 +48,12 @@ import com.threerings.media.util.Path;
import com.threerings.stage.client.StageScenePanel; import com.threerings.stage.client.StageScenePanel;
import com.threerings.whirled.spot.data.Location; import com.threerings.whirled.spot.data.Location;
import com.threerings.stage.Log;
import com.threerings.stage.data.StageLocation; import com.threerings.stage.data.StageLocation;
import com.threerings.stage.data.StageScene; import com.threerings.stage.data.StageScene;
import com.threerings.stage.util.StageContext; import com.threerings.stage.util.StageContext;
import static com.threerings.stage.Log.log;
public class ViewerScenePanel extends StageScenePanel public class ViewerScenePanel extends StageScenePanel
implements PerformanceObserver, PathObserver implements PerformanceObserver, PathObserver
{ {
@@ -165,7 +166,7 @@ public class ViewerScenePanel extends StageScenePanel
// documentation inherited // documentation inherited
public void checkpoint (String name, int ticks) public void checkpoint (String name, int ticks)
{ {
Log.info(name + " [ticks=" + ticks + "]."); log.info(name + " [ticks=" + ticks + "].");
} }
/** MouseListener interface methods */ /** MouseListener interface methods */
@@ -40,11 +40,12 @@ import com.threerings.media.tile.TileManager;
import com.threerings.miso.data.ObjectInfo; import com.threerings.miso.data.ObjectInfo;
import com.threerings.stage.Log;
import com.threerings.stage.data.StageCodes; import com.threerings.stage.data.StageCodes;
import com.threerings.stage.data.StageMisoSceneModel; import com.threerings.stage.data.StageMisoSceneModel;
import com.threerings.stage.data.StageScene; import com.threerings.stage.data.StageScene;
import static com.threerings.stage.Log.log;
/** /**
* Maintains extra information on objects in a scene and checks proposed * Maintains extra information on objects in a scene and checks proposed
* placement operations for constraint violations. When the constraints * placement operations for constraint violations. When the constraints
@@ -169,7 +170,7 @@ public class PlacementConstraints
for (int ii = 0; ii < info.length; ii++) { for (int ii = 0; ii < info.length; ii++) {
data[ii] = _objectData.get(info[ii]); data[ii] = _objectData.get(info[ii]);
if (data[ii] == null) { if (data[ii] == null) {
Log.warning("Couldn't match object info up to data [info=" + log.warning("Couldn't match object info up to data [info=" +
info[ii] + "]."); info[ii] + "].");
return null; return null;
} }
@@ -532,9 +533,7 @@ public class PlacementConstraints
return new ObjectData(bounds, tile); return new ObjectData(bounds, tile);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Error retrieving tile for object [info=" + log.warning("Error retrieving tile for object [info=" + info + "].", e);
info + ", error=" + e + "].");
Log.logStackTrace(e);
return null; return null;
} }
} }
@@ -46,11 +46,12 @@ import com.threerings.miso.util.ObjectSet;
import com.threerings.whirled.spot.data.Cluster; import com.threerings.whirled.spot.data.Cluster;
import com.threerings.whirled.spot.data.SceneLocation; import com.threerings.whirled.spot.data.SceneLocation;
import com.threerings.stage.Log;
import com.threerings.stage.data.StageLocation; import com.threerings.stage.data.StageLocation;
import com.threerings.stage.data.StageMisoSceneModel; import com.threerings.stage.data.StageMisoSceneModel;
import com.threerings.stage.data.StageSceneModel; import com.threerings.stage.data.StageSceneModel;
import static com.threerings.stage.Log.log;
/** /**
* Provides scene related utility functions. * Provides scene related utility functions.
*/ */
@@ -144,7 +145,7 @@ public class StageSceneUtil
return new StageLocation(opos.x, opos.y, (byte)orient); return new StageLocation(opos.x, opos.y, (byte)orient);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Unable to look up object tile for scene object " + log.warning("Unable to look up object tile for scene object " +
"[tileId=" + tileId + ", error=" + e + "]."); "[tileId=" + tileId + ", error=" + e + "].");
} }
return null; return null;
@@ -208,7 +209,7 @@ public class StageSceneUtil
return true; return true;
} catch (Exception e) { } catch (Exception e) {
Log.warning("Unable to look up object tile for scene object " + log.warning("Unable to look up object tile for scene object " +
"[tileId=" + tileId + ", error=" + e + "]."); "[tileId=" + tileId + ", error=" + e + "].");
return false; return false;
} }
@@ -232,7 +233,7 @@ public class StageSceneUtil
return tset.getPassability()[tidx]; return tset.getPassability()[tidx];
} catch (Exception e) { } catch (Exception e) {
Log.warning("Unable to look up base tile [tileId=" + tileId + log.warning("Unable to look up base tile [tileId=" + tileId +
", error=" + e + "]."); ", error=" + e + "].");
return true; return true;
} }
@@ -266,7 +267,7 @@ public class StageSceneUtil
double radius = (double)fwid/2; double radius = (double)fwid/2;
int clidx = cluster.width-2; int clidx = cluster.width-2;
if (clidx >= CLUSTER_METRICS.length/2 || clidx < 0) { if (clidx >= CLUSTER_METRICS.length/2 || clidx < 0) {
Log.warning("Requested locs from invalid cluster " + cluster + "."); log.warning("Requested locs from invalid cluster " + cluster + ".");
Thread.dumpStack(); Thread.dumpStack();
return list; return list;
} }
@@ -434,7 +435,7 @@ public class StageSceneUtil
objs.remove(ii--); objs.remove(ii--);
} }
} else { } else {
Log.warning("Unknown potentially intersecting object?! " + log.warning("Unknown potentially intersecting object?! " +
"[scene=" + model.name + " (" + model.sceneId + "[scene=" + model.name + " (" + model.sceneId +
"), info=" + info + "]."); "), info=" + info + "].");
} }
+1 -1
View File
@@ -3,7 +3,7 @@
package com.threerings.stats; package com.threerings.stats;
import java.util.logging.Logger; import com.samskivert.util.Logger;
/** /**
* A placeholder class that contains a reference to the log object used by this project. * A placeholder class that contains a reference to the log object used by this project.
@@ -103,7 +103,7 @@ public class StatRepository extends DepotRepository
updateStat(playerId, stats[ii]); updateStat(playerId, stats[ii]);
} }
} catch (Exception e) { } catch (Exception e) {
log.log(Level.WARNING, "Error flushing modified stat [stat=" + stats[ii] + "].", e); log.warning("Error flushing modified stat [stat=" + stats[ii] + "].", e);
} }
} }
} }
@@ -120,7 +120,7 @@ public class StatRepository extends DepotRepository
try { try {
code = assignStringCode(type, value); code = assignStringCode(type, value);
} catch (PersistenceException pe) { } catch (PersistenceException pe) {
log.log(Level.WARNING, "Failed to assign code [type=" + type + log.warning("Failed to assign code [type=" + type +
", value=" + value + "].", pe); ", value=" + value + "].", pe);
// at this point the database is probably totally hosed, so we can just punt here, // at this point the database is probably totally hosed, so we can just punt here,
// and assume that this value will never be persisted // and assume that this value will never be persisted
@@ -142,7 +142,7 @@ public class StatRepository extends DepotRepository
try { try {
loadStringCodes(type); loadStringCodes(type);
} catch (PersistenceException pe) { } catch (PersistenceException pe) {
log.log(Level.WARNING, "Failed to reload string codes " + log.warning("Failed to reload string codes " +
"[type=" + type + ", code=" + code + "].", pe); "[type=" + type + ", code=" + code + "].", pe);
} }
map = _codeToString.get(type); map = _codeToString.get(type);
@@ -200,7 +200,7 @@ public class StatRepository extends DepotRepository
errmsg = "Unable to decode stat"; errmsg = "Unable to decode stat";
} }
log.log(Level.WARNING, errmsg + " [type=" + stat.getType() + "]", error); log.warning(errmsg + " [type=" + stat.getType() + "]", error);
return null; return null;
} }
+4 -35
View File
@@ -21,43 +21,12 @@
package com.threerings.whirled; package com.threerings.whirled;
import com.samskivert.util.Logger;
/** /**
* A placeholder class that contains a reference to the log object used by * Contains a reference to the log object used by the Whirled services.
* the Whirled services.
*/ */
public class Log public class Log
{ {
public static com.samskivert.util.Log log = public static Logger log = Logger.getLogger("com.threerings.whirled");
new com.samskivert.util.Log("whirled");
/** Convenience function. */
public static boolean debug ()
{
return (com.samskivert.util.Log.getLevel() ==
com.samskivert.util.Log.DEBUG);
}
/** 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);
}
} }
@@ -34,7 +34,6 @@ import com.threerings.crowd.client.LocationDirector;
import com.threerings.crowd.client.LocationObserver; import com.threerings.crowd.client.LocationObserver;
import com.threerings.crowd.data.PlaceConfig; import com.threerings.crowd.data.PlaceConfig;
import com.threerings.whirled.Log;
import com.threerings.whirled.client.persist.SceneRepository; import com.threerings.whirled.client.persist.SceneRepository;
import com.threerings.whirled.data.Scene; import com.threerings.whirled.data.Scene;
import com.threerings.whirled.data.SceneCodes; import com.threerings.whirled.data.SceneCodes;
@@ -44,6 +43,8 @@ import com.threerings.whirled.util.SceneFactory;
import com.threerings.whirled.util.WhirledContext; import com.threerings.whirled.util.WhirledContext;
import com.threerings.whirled.data.SceneUpdate; import com.threerings.whirled.data.SceneUpdate;
import static com.threerings.whirled.Log.log;
/** /**
* The scene director is the client's interface to all things scene related. It interfaces with the * The scene director is the client's interface to all things scene related. It interfaces with the
* scene repository to ensure that scene objects are available when the client enters a particular * scene repository to ensure that scene objects are available when the client enters a particular
@@ -138,13 +139,13 @@ public class SceneDirector extends BasicDirector
{ {
// make sure the sceneId is valid // make sure the sceneId is valid
if (sceneId < 0) { if (sceneId < 0) {
Log.warning("Refusing moveTo(): invalid sceneId " + sceneId + "."); log.warning("Refusing moveTo(): invalid sceneId " + sceneId + ".");
return false; return false;
} }
// sanity-check the destination scene id // sanity-check the destination scene id
if (sceneId == _sceneId) { if (sceneId == _sceneId) {
Log.warning("Refusing request to move to the same scene [sceneId=" + sceneId + "]."); log.warning("Refusing request to move to the same scene [sceneId=" + sceneId + "].");
return false; return false;
} }
@@ -177,11 +178,11 @@ public class SceneDirector extends BasicDirector
// complain if we're over-writing a pending request // complain if we're over-writing a pending request
if (movePending()) { if (movePending()) {
if (refuse) { if (refuse) {
Log.warning("Refusing moveTo; We have a request outstanding " + log.warning("Refusing moveTo; We have a request outstanding " +
"[psid=" + _pendingSceneId + ", nsid=" + sceneId + "]."); "[psid=" + _pendingSceneId + ", nsid=" + sceneId + "].");
return false; return false;
} else { } else {
Log.warning("Overriding stale moveTo request [psid=" + _pendingSceneId + log.warning("Overriding stale moveTo request [psid=" + _pendingSceneId +
", nsid=" + sceneId + "]."); ", nsid=" + sceneId + "].");
} }
} }
@@ -232,7 +233,7 @@ public class SceneDirector extends BasicDirector
// complain if we didn't find a scene // complain if we didn't find a scene
if (_model == null) { if (_model == null) {
Log.warning("Aiya! Unable to load scene [sid=" + _sceneId + ", plid=" + placeId + "]."); log.warning("Aiya! Unable to load scene [sid=" + _sceneId + ", plid=" + placeId + "].");
return; return;
} }
@@ -243,7 +244,7 @@ public class SceneDirector extends BasicDirector
// from interface SceneService.SceneMoveListener // from interface SceneService.SceneMoveListener
public void moveSucceededWithUpdates (int placeId, PlaceConfig config, SceneUpdate[] updates) public void moveSucceededWithUpdates (int placeId, PlaceConfig config, SceneUpdate[] updates)
{ {
Log.info("Got updates [placeId=" + placeId + ", config=" + config + log.info("Got updates [placeId=" + placeId + ", config=" + config +
", updates=" + StringUtil.toString(updates) + "]."); ", updates=" + StringUtil.toString(updates) + "].");
// apply the updates to our cached scene // apply the updates to our cached scene
@@ -253,7 +254,7 @@ public class SceneDirector extends BasicDirector
try { try {
updates[ii].validate(model); updates[ii].validate(model);
} catch (IllegalStateException ise) { } catch (IllegalStateException ise) {
Log.warning("Scene update failed validation [model=" + model + log.warning("Scene update failed validation [model=" + model +
", update=" + updates[ii] + ", error=" + ise.getMessage() + "]."); ", update=" + updates[ii] + ", error=" + ise.getMessage() + "].");
failure = true; failure = true;
break; break;
@@ -262,9 +263,8 @@ public class SceneDirector extends BasicDirector
try { try {
updates[ii].apply(model); updates[ii].apply(model);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Failure applying scene update [model=" + model + log.warning("Failure applying scene update [model=" + model +
", update=" + updates[ii] + "]."); ", update=" + updates[ii] + "].", e);
Log.logStackTrace(e);
failure = true; failure = true;
break; break;
} }
@@ -275,9 +275,8 @@ public class SceneDirector extends BasicDirector
try { try {
_screp.deleteSceneModel(_pendingSceneId); _screp.deleteSceneModel(_pendingSceneId);
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Failure removing booched scene model " + log.warning("Failure removing booched scene model " +
"[sceneId=" + _pendingSceneId + "]."); "[sceneId=" + _pendingSceneId + "].", ioe);
Log.logStackTrace(ioe);
} }
// act as if the scene move failed; we'll be in a funny state because the server thinks // act as if the scene move failed; we'll be in a funny state because the server thinks
@@ -296,7 +295,7 @@ public class SceneDirector extends BasicDirector
// from interface SceneService.SceneMoveListener // from interface SceneService.SceneMoveListener
public void moveSucceededWithScene (int placeId, PlaceConfig config, SceneModel model) public void moveSucceededWithScene (int placeId, PlaceConfig config, SceneModel model)
{ {
Log.info("Got updated scene model [placeId=" + placeId + ", config=" + config + log.info("Got updated scene model [placeId=" + placeId + ", config=" + config +
", scene=" + model.sceneId + "/" + model.name + "/" + model.version + "]."); ", scene=" + model.sceneId + "/" + model.name + "/" + model.version + "].");
// update the model in the repository // update the model in the repository
@@ -358,7 +357,7 @@ public class SceneDirector extends BasicDirector
public void setMoveHandler (MoveHandler handler) public void setMoveHandler (MoveHandler handler)
{ {
if (_moveHandler != null) { if (_moveHandler != null) {
Log.warning("Requested to set move handler, but we've already got one. The " + log.warning("Requested to set move handler, but we've already got one. The " +
"conflicting entities will likely need to perform more sophisticated " + "conflicting entities will likely need to perform more sophisticated " +
"coordination to deal with failures. [old=" + _moveHandler + "coordination to deal with failures. [old=" + _moveHandler +
", new=" + handler + "]."); ", new=" + handler + "].");
@@ -375,12 +374,12 @@ public class SceneDirector extends BasicDirector
// just finish up what we're doing and assume that the repeated move request was the // just finish up what we're doing and assume that the repeated move request was the
// spurious one as it would be in the case of lag causing rapid-fire repeat requests // spurious one as it would be in the case of lag causing rapid-fire repeat requests
if (movePending()) { if (movePending()) {
Log.info("Dropping forced move because we have a move pending " + log.info("Dropping forced move because we have a move pending " +
"[pendId=" + _pendingSceneId + ", reqId=" + sceneId + "]."); "[pendId=" + _pendingSceneId + ", reqId=" + sceneId + "].");
return; return;
} }
Log.info("Moving at request of server [sceneId=" + sceneId + "]."); log.info("Moving at request of server [sceneId=" + sceneId + "].");
// clear out our old scene and place data // clear out our old scene and place data
didLeaveScene(); didLeaveScene();
// move to the new scene // move to the new scene
@@ -424,7 +423,7 @@ public class SceneDirector extends BasicDirector
} }
// issue a moveTo request // issue a moveTo request
Log.info("Issuing moveTo(" + _pendingSceneId + ", " + sceneVers + ")."); log.info("Issuing moveTo(" + _pendingSceneId + ", " + sceneVers + ").");
_sservice.moveTo(_ctx.getClient(), _pendingSceneId, sceneVers, this); _sservice.moveTo(_ctx.getClient(), _pendingSceneId, sceneVers, this);
} }
@@ -463,7 +462,7 @@ public class SceneDirector extends BasicDirector
} catch (IOException ioe) { } catch (IOException ioe) {
// complain first, then return null // complain first, then return null
Log.warning("Error loading scene [scid=" + sceneId + ", error=" + ioe + "]."); log.warning("Error loading scene [scid=" + sceneId + ", error=" + ioe + "].");
} }
} }
@@ -479,9 +478,8 @@ public class SceneDirector extends BasicDirector
try { try {
_screp.storeSceneModel(model); _screp.storeSceneModel(model);
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Failed to update repository with updated scene [sceneId=" + model.sceneId + log.warning("Failed to update repository with updated scene [sceneId=" + model.sceneId +
", nvers=" + model.version + "]."); ", nvers=" + model.version + "].", ioe);
Log.logStackTrace(ioe);
} }
} }
@@ -23,7 +23,7 @@ package com.threerings.whirled.data;
import com.threerings.crowd.data.PlaceConfig; import com.threerings.crowd.data.PlaceConfig;
import com.threerings.whirled.Log; import static com.threerings.whirled.Log.log;
/** /**
* An implementation of the {@link Scene} interface. * An implementation of the {@link Scene} interface.
@@ -99,9 +99,8 @@ public class SceneImpl implements Scene
update.validate(_model); update.validate(_model);
update.apply(_model); update.apply(_model);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Error applying update [scene=" + this + log.warning("Error applying update [scene=" + this +
", update=" + update + "]."); ", update=" + update + "].", e);
Log.logStackTrace(e);
} }
} }
@@ -30,7 +30,7 @@ import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable; import com.threerings.io.Streamable;
import com.threerings.util.ActionScript; import com.threerings.util.ActionScript;
import com.threerings.whirled.Log; import static com.threerings.whirled.Log.log;
/** /**
* Used to encapsulate updates to scenes in such a manner that updates can be stored persistently * Used to encapsulate updates to scenes in such a manner that updates can be stored persistently
@@ -109,7 +109,7 @@ public class SceneUpdate
// sanity check for the amazing two billion updates // sanity check for the amazing two billion updates
if (model.version == _targetVersion) { if (model.version == _targetVersion) {
Log.warning("Egads! This scene has been updated two billion times [model=" + model + log.warning("Egads! This scene has been updated two billion times [model=" + model +
", update=" + this + "]."); ", update=" + this + "].");
} }
} }
@@ -30,7 +30,7 @@ import com.threerings.crowd.data.BodyObject;
import com.threerings.whirled.client.SceneService; import com.threerings.whirled.client.SceneService;
import com.threerings.whirled.data.SceneCodes; import com.threerings.whirled.data.SceneCodes;
import com.threerings.whirled.Log; import static com.threerings.whirled.Log.log;
/** /**
* Handles the basics of moving a client into a new scene, which may involve resolution. Takes care * Handles the basics of moving a client into a new scene, which may involve resolution. Takes care
@@ -52,7 +52,7 @@ public abstract class AbstractSceneMoveHandler
// make sure our caller is still around; under heavy load, clients might end their session // make sure our caller is still around; under heavy load, clients might end their session
// while the scene is resolving // while the scene is resolving
if (!_body.isActive()) { if (!_body.isActive()) {
Log.info("Abandoning scene move, client gone [who=" + _body.who() + log.info("Abandoning scene move, client gone [who=" + _body.who() +
", dest=" + scmgr.where() + "]."); ", dest=" + scmgr.where() + "].");
InvocationMarshaller.setNoResponse(_listener); InvocationMarshaller.setNoResponse(_listener);
return; return;
@@ -65,7 +65,7 @@ public abstract class AbstractSceneMoveHandler
_listener.requestFailed(sfe.getMessage()); _listener.requestFailed(sfe.getMessage());
} catch (RuntimeException re) { } catch (RuntimeException re) {
Log.logStackTrace(re); log.warning(re);
_listener.requestFailed(SceneCodes.INTERNAL_ERROR); _listener.requestFailed(SceneCodes.INTERNAL_ERROR);
} }
} }
@@ -73,7 +73,7 @@ public abstract class AbstractSceneMoveHandler
// from interface SceneRegistry.ResolutionListener // from interface SceneRegistry.ResolutionListener
public void sceneFailedToResolve (int sceneId, Exception reason) public void sceneFailedToResolve (int sceneId, Exception reason)
{ {
Log.warning("Unable to resolve scene [sceneid=" + sceneId + ", reason=" + reason + "]."); log.warning("Unable to resolve scene [sceneid=" + sceneId + ", reason=" + reason + "].");
_listener.requestFailed(SceneCodes.NO_SUCH_PLACE); _listener.requestFailed(SceneCodes.NO_SUCH_PLACE);
} }
@@ -28,7 +28,6 @@ import com.threerings.crowd.data.Place;
import com.threerings.crowd.server.CrowdServer; import com.threerings.crowd.server.CrowdServer;
import com.threerings.crowd.server.PlaceManager; import com.threerings.crowd.server.PlaceManager;
import com.threerings.whirled.Log;
import com.threerings.whirled.data.Scene; import com.threerings.whirled.data.Scene;
import com.threerings.whirled.data.SceneCodes; import com.threerings.whirled.data.SceneCodes;
import com.threerings.whirled.data.ScenePlace; import com.threerings.whirled.data.ScenePlace;
@@ -36,6 +35,8 @@ import com.threerings.whirled.data.SceneUpdate;
import com.threerings.whirled.server.WhirledServer; import com.threerings.whirled.server.WhirledServer;
import com.threerings.whirled.util.UpdateList; import com.threerings.whirled.util.UpdateList;
import static com.threerings.whirled.Log.log;
/** /**
* The scene manager extends the place manager and takes care of basic scene services. Presently * The scene manager extends the place manager and takes care of basic scene services. Presently
* that is little more than registering the scene manager with the scene registry so that the * that is little more than registering the scene manager with the scene registry so that the
@@ -87,7 +88,7 @@ public class SceneManager extends PlaceManager
// make sure the list and our version of the scene are in accordance // make sure the list and our version of the scene are in accordance
if (!_updates.validate(scene.getVersion())) { if (!_updates.validate(scene.getVersion())) {
Log.warning("Provided with invalid updates; flushing [where=" + where() + log.warning("Provided with invalid updates; flushing [where=" + where() +
", sceneId=" + scene.getId() + ", version=" + scene.getVersion() + "]."); ", sceneId=" + scene.getId() + ", version=" + scene.getVersion() + "].");
// clear out the update list as it will not allow us to bring clients up to date with // clear out the update list as it will not allow us to bring clients up to date with
// our current scene version; instead they'll have to download the whole thing // our current scene version; instead they'll have to download the whole thing
@@ -37,7 +37,6 @@ import com.threerings.crowd.server.CrowdServer;
import com.threerings.crowd.server.PlaceManager; import com.threerings.crowd.server.PlaceManager;
import com.threerings.crowd.server.PlaceRegistry; import com.threerings.crowd.server.PlaceRegistry;
import com.threerings.whirled.Log;
import com.threerings.whirled.client.SceneService; import com.threerings.whirled.client.SceneService;
import com.threerings.whirled.data.Scene; import com.threerings.whirled.data.Scene;
import com.threerings.whirled.data.SceneCodes; import com.threerings.whirled.data.SceneCodes;
@@ -48,6 +47,8 @@ import com.threerings.whirled.util.NoSuchSceneException;
import com.threerings.whirled.util.SceneFactory; import com.threerings.whirled.util.SceneFactory;
import com.threerings.whirled.util.UpdateList; import com.threerings.whirled.util.UpdateList;
import static com.threerings.whirled.Log.log;
/** /**
* The scene registry is responsible for the management of all scenes. It handles interaction with * The scene registry is responsible for the management of all scenes. It handles interaction with
* the scene repository and ensures that scenes are loaded into memory when needed and flushed from * the scene repository and ensures that scenes are loaded into memory when needed and flushed from
@@ -269,8 +270,7 @@ public class SceneRegistry
{ {
// if this is not simply a missing scene, log a warning // if this is not simply a missing scene, log a warning
if (!(cause instanceof NoSuchSceneException)) { if (!(cause instanceof NoSuchSceneException)) {
Log.info("Failed to resolve scene [sceneId=" + sceneId + ", cause=" + cause + "]."); log.info("Failed to resolve scene [sceneId=" + sceneId + "].", cause);
Log.logStackTrace(cause);
} }
// alas things didn't work out, notify our penders // alas things didn't work out, notify our penders
@@ -280,8 +280,7 @@ public class SceneRegistry
try { try {
rl.sceneFailedToResolve(sceneId, cause); rl.sceneFailedToResolve(sceneId, cause);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Resolution listener choked."); log.warning("Resolution listener choked.", e);
Log.logStackTrace(e);
} }
} }
} }
@@ -297,9 +296,7 @@ public class SceneRegistry
int sceneId = scmgr.getScene().getId(); int sceneId = scmgr.getScene().getId();
_scenemgrs.put(sceneId, scmgr); _scenemgrs.put(sceneId, scmgr);
if (Log.debug()) { log.debug("Registering scene manager", "scid", sceneId, "scmgr", scmgr);
Log.debug("Registering scene manager [scid=" + sceneId + ", scmgr=" + scmgr + "].");
}
// now notify any penders // now notify any penders
ArrayList<ResolutionListener> penders = _penders.remove(sceneId); ArrayList<ResolutionListener> penders = _penders.remove(sceneId);
@@ -308,8 +305,7 @@ public class SceneRegistry
try { try {
rl.sceneWasResolved(scmgr); rl.sceneWasResolved(scmgr);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Resolution listener choked."); log.warning("Resolution listener choked.", e);
Log.logStackTrace(e);
} }
} }
} }
@@ -321,13 +317,11 @@ public class SceneRegistry
protected void unmapSceneManager (SceneManager scmgr) protected void unmapSceneManager (SceneManager scmgr)
{ {
if (_scenemgrs.remove(scmgr.getScene().getId()) == null) { if (_scenemgrs.remove(scmgr.getScene().getId()) == null) {
Log.warning("Requested to unmap unmapped scene manager [scmgr=" + scmgr + "]."); log.warning("Requested to unmap unmapped scene manager [scmgr=" + scmgr + "].");
return; return;
} }
if (Log.debug()) { log.debug("Unmapped scene manager", "scmgr", scmgr);
Log.debug("Unmapped scene manager " + scmgr + ".");
}
} }
/** The entity from which we load scene models. */ /** The entity from which we load scene models. */
@@ -30,10 +30,11 @@ import com.threerings.presents.server.PresentsClient;
import com.threerings.crowd.server.CrowdServer; import com.threerings.crowd.server.CrowdServer;
import com.threerings.whirled.Log;
import com.threerings.whirled.server.persist.SceneRepository; import com.threerings.whirled.server.persist.SceneRepository;
import com.threerings.whirled.util.SceneFactory; import com.threerings.whirled.util.SceneFactory;
import static com.threerings.whirled.Log.log;
/** /**
* The Whirled server extends the {@link CrowdServer} and provides access to managers and the like * The Whirled server extends the {@link CrowdServer} and provides access to managers and the like
* that are needed by the Whirled serviecs. * that are needed by the Whirled serviecs.
@@ -23,12 +23,13 @@ package com.threerings.whirled.server.persist;
import com.samskivert.io.PersistenceException; import com.samskivert.io.PersistenceException;
import com.threerings.whirled.Log;
import com.threerings.whirled.data.SceneModel; import com.threerings.whirled.data.SceneModel;
import com.threerings.whirled.data.SceneUpdate; import com.threerings.whirled.data.SceneUpdate;
import com.threerings.whirled.util.NoSuchSceneException; import com.threerings.whirled.util.NoSuchSceneException;
import com.threerings.whirled.util.UpdateList; import com.threerings.whirled.util.UpdateList;
import static com.threerings.whirled.Log.log;
/** /**
* The dummy scene repository just pretends to load and store scenes, but * The dummy scene repository just pretends to load and store scenes, but
* in fact it just creates new blank scenes when requested to load a scene * in fact it just creates new blank scenes when requested to load a scene
@@ -40,7 +41,7 @@ public class DummySceneRepository implements SceneRepository
public SceneModel loadSceneModel (int sceneId) public SceneModel loadSceneModel (int sceneId)
throws PersistenceException, NoSuchSceneException throws PersistenceException, NoSuchSceneException
{ {
Log.info("Creating dummy scene [id=" + sceneId + "]."); log.info("Creating dummy scene [id=" + sceneId + "].");
return SceneModel.blankSceneModel(); return SceneModel.blankSceneModel();
} }
+4 -28
View File
@@ -21,36 +21,12 @@
package com.threerings.whirled.spot; package com.threerings.whirled.spot;
import com.samskivert.util.Logger;
/** /**
* A placeholder class that contains a reference to the log object used by * Contains a reference to the log object used by the Whirled Spot services.
* the Whirled Spot services.
*/ */
public class Log public class Log
{ {
public static com.samskivert.util.Log log = public static Logger log = Logger.getLogger("com.threerings.whirled.spot");
new com.samskivert.util.Log("whirled.spot");
/** 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);
}
} }
@@ -46,13 +46,14 @@ import com.threerings.whirled.data.SceneModel;
import com.threerings.whirled.data.ScenePlace; import com.threerings.whirled.data.ScenePlace;
import com.threerings.whirled.util.WhirledContext; import com.threerings.whirled.util.WhirledContext;
import com.threerings.whirled.spot.Log;
import com.threerings.whirled.spot.data.ClusteredBodyObject; import com.threerings.whirled.spot.data.ClusteredBodyObject;
import com.threerings.whirled.spot.data.Location; import com.threerings.whirled.spot.data.Location;
import com.threerings.whirled.spot.data.Portal; import com.threerings.whirled.spot.data.Portal;
import com.threerings.whirled.spot.data.SpotCodes; import com.threerings.whirled.spot.data.SpotCodes;
import com.threerings.whirled.spot.data.SpotScene; import com.threerings.whirled.spot.data.SpotScene;
import static com.threerings.whirled.spot.Log.log;
/** /**
* Extends the standard scene director with facilities to move between locations within a scene. * Extends the standard scene director with facilities to move between locations within a scene.
*/ */
@@ -124,7 +125,7 @@ public class SpotSceneDirector extends BasicDirector
// look up the destination scene and location // look up the destination scene and location
SpotScene scene = (SpotScene)_scdir.getScene(); SpotScene scene = (SpotScene)_scdir.getScene();
if (scene == null) { if (scene == null) {
Log.warning("Requested to traverse portal when we have no scene " + log.warning("Requested to traverse portal when we have no scene " +
"[portalId=" + portalId + "]."); "[portalId=" + portalId + "].");
return false; return false;
} }
@@ -133,7 +134,7 @@ public class SpotSceneDirector extends BasicDirector
int sceneId = _scdir.getScene().getId(); int sceneId = _scdir.getScene().getId();
int clSceneId = ScenePlace.getSceneId((BodyObject)_ctx.getClient().getClientObject()); int clSceneId = ScenePlace.getSceneId((BodyObject)_ctx.getClient().getClientObject());
if (sceneId != clSceneId) { if (sceneId != clSceneId) {
Log.warning("Client and server differ in opinion of what scene we're in " + log.warning("Client and server differ in opinion of what scene we're in " +
"[sSceneId=" + clSceneId + ", cSceneId=" + sceneId + "]."); "[sSceneId=" + clSceneId + ", cSceneId=" + sceneId + "].");
return false; return false;
} }
@@ -141,14 +142,14 @@ public class SpotSceneDirector extends BasicDirector
// find the portal they're talking about // find the portal they're talking about
Portal dest = scene.getPortal(portalId); Portal dest = scene.getPortal(portalId);
if (dest == null) { if (dest == null) {
Log.warning("Requested to traverse non-existent portal [portalId=" + portalId + log.warning("Requested to traverse non-existent portal [portalId=" + portalId +
", portals=" + StringUtil.toString(scene.getPortals()) + "]."); ", portals=" + StringUtil.toString(scene.getPortals()) + "].");
return false; return false;
} }
// prepare to move to this scene (sets up pending data) // prepare to move to this scene (sets up pending data)
if (!_scdir.prepareMoveTo(dest.targetSceneId, rl)) { if (!_scdir.prepareMoveTo(dest.targetSceneId, rl)) {
Log.info("Portal traversal vetoed by scene director [portalId=" + portalId + "]."); log.info("Portal traversal vetoed by scene director [portalId=" + portalId + "].");
return false; return false;
} }
@@ -161,7 +162,7 @@ public class SpotSceneDirector extends BasicDirector
} }
// issue a traversePortal request // issue a traversePortal request
Log.info("Issuing traversePortal(" + sceneId + ", " + dest + ", " + sceneVer + ")."); log.info("Issuing traversePortal(" + sceneId + ", " + dest + ", " + sceneVer + ").");
_sservice.traversePortal(_ctx.getClient(), sceneId, portalId, sceneVer, _scdir); _sservice.traversePortal(_ctx.getClient(), sceneId, portalId, sceneVer, _scdir);
return true; return true;
} }
@@ -181,7 +182,7 @@ public class SpotSceneDirector extends BasicDirector
// refuse if there's a pending location change or if we're already at the specified // refuse if there's a pending location change or if we're already at the specified
// location // location
if (loc.equivalent(_location)) { if (loc.equivalent(_location)) {
Log.info("Not going to " + loc + "; we're at " + _location + " and we're headed to " + log.info("Not going to " + loc + "; we're at " + _location + " and we're headed to " +
_pendingLoc + "."); _pendingLoc + ".");
if (listener != null) { if (listener != null) {
// This isn't really a failure, it's just a no-op. // This isn't really a failure, it's just a no-op.
@@ -191,7 +192,7 @@ public class SpotSceneDirector extends BasicDirector
} }
if (_pendingLoc != null) { if (_pendingLoc != null) {
Log.info("Not going to " + loc + "; we're at " + _location + " and we're headed to " + log.info("Not going to " + loc + "; we're at " + _location + " and we're headed to " +
_pendingLoc + "."); _pendingLoc + ".");
if (listener != null) { if (listener != null) {
// Already moving, best thing to do is ignore it. // Already moving, best thing to do is ignore it.
@@ -202,7 +203,7 @@ public class SpotSceneDirector extends BasicDirector
SpotScene scene = (SpotScene)_scdir.getScene(); SpotScene scene = (SpotScene)_scdir.getScene();
if (scene == null) { if (scene == null) {
Log.warning("Requested to change locations, but we're not currently in any scene " + log.warning("Requested to change locations, but we're not currently in any scene " +
"[loc=" + loc + "]."); "[loc=" + loc + "].");
if (listener != null) { if (listener != null) {
listener.requestFailed(new Exception("m.cant_get_there")); listener.requestFailed(new Exception("m.cant_get_there"));
@@ -211,7 +212,7 @@ public class SpotSceneDirector extends BasicDirector
} }
int sceneId = _scdir.getScene().getId(); int sceneId = _scdir.getScene().getId();
Log.info("Sending changeLocation request [scid=" + sceneId + ", loc=" + loc + "]."); log.info("Sending changeLocation request [scid=" + sceneId + ", loc=" + loc + "].");
_pendingLoc = (Location)loc.clone(); _pendingLoc = (Location)loc.clone();
ConfirmListener clist = new ConfirmListener() { ConfirmListener clist = new ConfirmListener() {
@@ -245,7 +246,7 @@ public class SpotSceneDirector extends BasicDirector
{ {
SpotScene scene = (SpotScene)_scdir.getScene(); SpotScene scene = (SpotScene)_scdir.getScene();
if (scene == null) { if (scene == null) {
Log.warning("Requested to join cluster, but we're not currently in any scene " + log.warning("Requested to join cluster, but we're not currently in any scene " +
"[froid=" + froid + "]."); "[froid=" + froid + "].");
if (listener != null) { if (listener != null) {
listener.requestFailed(new Exception("m.cant_get_there")); listener.requestFailed(new Exception("m.cant_get_there"));
@@ -253,7 +254,7 @@ public class SpotSceneDirector extends BasicDirector
return; return;
} }
Log.info("Joining cluster [friend=" + froid + "]."); log.info("Joining cluster [friend=" + froid + "].");
_sservice.joinCluster(_ctx.getClient(), froid, new ConfirmListener() { _sservice.joinCluster(_ctx.getClient(), froid, new ConfirmListener() {
public void requestProcessed () { public void requestProcessed () {
@@ -293,14 +294,14 @@ public class SpotSceneDirector extends BasicDirector
// make sure we're currently in a scene // make sure we're currently in a scene
SpotScene scene = (SpotScene)_scdir.getScene(); SpotScene scene = (SpotScene)_scdir.getScene();
if (scene == null) { if (scene == null) {
Log.warning("Requested to speak to cluster, but we're not currently in any scene " + log.warning("Requested to speak to cluster, but we're not currently in any scene " +
"[message=" + message + "]."); "[message=" + message + "].");
return false; return false;
} }
// make sure we're part of a cluster // make sure we're part of a cluster
if (_self.getClusterOid() <= 0) { if (_self.getClusterOid() <= 0) {
Log.info("Ignoring cluster speak as we're not in a cluster " + log.info("Ignoring cluster speak as we're not in a cluster " +
"[cloid=" + _self.getClusterOid() + "]."); "[cloid=" + _self.getClusterOid() + "].");
return false; return false;
} }
@@ -333,7 +334,7 @@ public class SpotSceneDirector extends BasicDirector
// documentation inherited from interface // documentation inherited from interface
public void requestFailed (int oid, ObjectAccessException cause) public void requestFailed (int oid, ObjectAccessException cause)
{ {
Log.warning("Unable to subscribe to cluster chat object [oid=" + oid + log.warning("Unable to subscribe to cluster chat object [oid=" + oid +
", cause=" + cause + "]."); ", cause=" + cause + "].");
} }
@@ -25,7 +25,7 @@ import java.util.Iterator;
import com.samskivert.util.HashIntMap; import com.samskivert.util.HashIntMap;
import com.threerings.whirled.spot.Log; import static com.threerings.whirled.spot.Log.log;
/** /**
* An implementation of the {@link SpotScene} interface. * An implementation of the {@link SpotScene} interface.
@@ -103,7 +103,7 @@ public class SpotSceneImpl
public void addPortal (Portal portal) public void addPortal (Portal portal)
{ {
if (portal.portalId <= 0) { if (portal.portalId <= 0) {
Log.warning("Refusing to add zero-id portal " + log.warning("Refusing to add zero-id portal " +
"[scene=" + this + ", portal=" + portal + "]."); "[scene=" + this + ", portal=" + portal + "].");
return; return;
} }
@@ -37,13 +37,14 @@ import com.threerings.util.Name;
import com.threerings.whirled.client.SceneService.SceneMoveListener; import com.threerings.whirled.client.SceneService.SceneMoveListener;
import com.threerings.whirled.data.ScenePlace; import com.threerings.whirled.data.ScenePlace;
import com.threerings.whirled.server.SceneRegistry; import com.threerings.whirled.server.SceneRegistry;
import com.threerings.whirled.spot.Log;
import com.threerings.whirled.spot.client.SpotService; import com.threerings.whirled.spot.client.SpotService;
import com.threerings.whirled.spot.data.Location; import com.threerings.whirled.spot.data.Location;
import com.threerings.whirled.spot.data.Portal; import com.threerings.whirled.spot.data.Portal;
import com.threerings.whirled.spot.data.SpotCodes; import com.threerings.whirled.spot.data.SpotCodes;
import com.threerings.whirled.spot.data.SpotScene; import com.threerings.whirled.spot.data.SpotScene;
import static com.threerings.whirled.spot.Log.log;
/** /**
* Provides the server-side implementation of the spot services. * Provides the server-side implementation of the spot services.
*/ */
@@ -73,7 +74,7 @@ public class SpotProvider
BodyObject body = (BodyObject)caller; BodyObject body = (BodyObject)caller;
int cSceneId = ScenePlace.getSceneId(body); int cSceneId = ScenePlace.getSceneId(body);
if (cSceneId != sceneId) { if (cSceneId != sceneId) {
Log.info("Ignoring stale traverse portal request [caller=" + caller.who() + log.info("Ignoring stale traverse portal request [caller=" + caller.who() +
", oSceneId=" + sceneId + ", portalId=" + portalId + ", oSceneId=" + sceneId + ", portalId=" + portalId +
", cSceneId=" + cSceneId + "]."); ", cSceneId=" + cSceneId + "].");
InvocationMarshaller.setNoResponse(listener); InvocationMarshaller.setNoResponse(listener);
@@ -83,7 +84,7 @@ public class SpotProvider
// obtain the source scene // obtain the source scene
SpotSceneManager srcmgr = (SpotSceneManager)_screg.getSceneManager(sceneId); SpotSceneManager srcmgr = (SpotSceneManager)_screg.getSceneManager(sceneId);
if (srcmgr == null) { if (srcmgr == null) {
Log.warning("Traverse portal missing source scene " + log.warning("Traverse portal missing source scene " +
"[user=" + body.who() + ", sceneId=" + sceneId + "[user=" + body.who() + ", sceneId=" + sceneId +
", portalId=" + portalId + "]."); ", portalId=" + portalId + "].");
throw new InvocationException(INTERNAL_ERROR); throw new InvocationException(INTERNAL_ERROR);
@@ -101,7 +102,7 @@ public class SpotProvider
// make sure this portal has valid info // make sure this portal has valid info
if (dest == null || !dest.isValid()) { if (dest == null || !dest.isValid()) {
Log.warning("Traverse portal with invalid portal [user=" + body.who() + log.warning("Traverse portal with invalid portal [user=" + body.who() +
", scene=" + srcmgr.where() + ", pid=" + portalId + ", portal=" + dest + ", scene=" + srcmgr.where() + ", pid=" + portalId + ", portal=" + dest +
", portals=" + StringUtil.toString(rss.getPortals()) + "]."); ", portals=" + StringUtil.toString(rss.getPortals()) + "].");
throw new InvocationException(NO_SUCH_PORTAL); throw new InvocationException(NO_SUCH_PORTAL);
@@ -122,7 +123,7 @@ public class SpotProvider
BodyObject source = (BodyObject)caller; BodyObject source = (BodyObject)caller;
int cSceneId = ScenePlace.getSceneId(source); int cSceneId = ScenePlace.getSceneId(source);
if (cSceneId != sceneId) { if (cSceneId != sceneId) {
Log.info("Rejecting changeLocation for invalid scene [user=" + source.who() + log.info("Rejecting changeLocation for invalid scene [user=" + source.who() +
", insid=" + cSceneId + ", wantsid=" + sceneId + ", loc=" + loc + "]."); ", insid=" + cSceneId + ", wantsid=" + sceneId + ", loc=" + loc + "].");
throw new InvocationException(INVALID_LOCATION); throw new InvocationException(INVALID_LOCATION);
} }
@@ -130,7 +131,7 @@ public class SpotProvider
// look up the scene manager for the specified scene // look up the scene manager for the specified scene
SpotSceneManager smgr = (SpotSceneManager)_screg.getSceneManager(sceneId); SpotSceneManager smgr = (SpotSceneManager)_screg.getSceneManager(sceneId);
if (smgr == null) { if (smgr == null) {
Log.warning("User requested to change location from non-existent scene " + log.warning("User requested to change location from non-existent scene " +
"[user=" + source.who() + ", sceneId=" + sceneId + ", loc=" + loc +"]."); "[user=" + source.who() + ", sceneId=" + sceneId + ", loc=" + loc +"].");
throw new InvocationException(INTERNAL_ERROR); throw new InvocationException(INTERNAL_ERROR);
} }
@@ -155,7 +156,7 @@ public class SpotProvider
// look up the scene manager for the specified scene // look up the scene manager for the specified scene
SpotSceneManager smgr = (SpotSceneManager)_screg.getSceneManager(sceneId); SpotSceneManager smgr = (SpotSceneManager)_screg.getSceneManager(sceneId);
if (smgr == null) { if (smgr == null) {
Log.warning("User requested to join cluster from non-existent scene " + log.warning("User requested to join cluster from non-existent scene " +
"[user=" + source.who() + ", sceneId=" + sceneId + "[user=" + source.who() + ", sceneId=" + sceneId +
", foid=" + friendOid +"]."); ", foid=" + friendOid +"].");
throw new InvocationException(INTERNAL_ERROR); throw new InvocationException(INTERNAL_ERROR);
@@ -223,7 +224,7 @@ public class SpotProvider
// look up the scene manager for the specified scene // look up the scene manager for the specified scene
SpotSceneManager smgr = (SpotSceneManager)_screg.getSceneManager(sceneId); SpotSceneManager smgr = (SpotSceneManager)_screg.getSceneManager(sceneId);
if (smgr == null) { if (smgr == null) {
Log.warning("User requested cluster chat in non-existent scene " + log.warning("User requested cluster chat in non-existent scene " +
"[user=" + message.speaker + ", sceneId=" + sceneId + "[user=" + message.speaker + ", sceneId=" + sceneId +
", message=" + message + "]."); ", message=" + message + "].");
return; return;
@@ -25,16 +25,19 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import com.samskivert.util.HashIntMap; import com.samskivert.util.HashIntMap;
import com.threerings.util.Name;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.server.InvocationException;
import com.threerings.crowd.chat.data.UserMessage; import com.threerings.crowd.chat.data.UserMessage;
import com.threerings.crowd.chat.server.SpeakUtil; import com.threerings.crowd.chat.server.SpeakUtil;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.OccupantInfo; import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.server.CrowdServer; import com.threerings.crowd.server.CrowdServer;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.server.InvocationException;
import com.threerings.util.Name;
import com.threerings.whirled.server.SceneManager; import com.threerings.whirled.server.SceneManager;
import com.threerings.whirled.spot.Log;
import com.threerings.whirled.spot.data.Cluster; import com.threerings.whirled.spot.data.Cluster;
import com.threerings.whirled.spot.data.ClusterObject; import com.threerings.whirled.spot.data.ClusterObject;
import com.threerings.whirled.spot.data.ClusteredBodyObject; import com.threerings.whirled.spot.data.ClusteredBodyObject;
@@ -45,6 +48,8 @@ import com.threerings.whirled.spot.data.SpotCodes;
import com.threerings.whirled.spot.data.SpotScene; import com.threerings.whirled.spot.data.SpotScene;
import com.threerings.whirled.spot.data.SpotSceneObject; import com.threerings.whirled.spot.data.SpotSceneObject;
import static com.threerings.whirled.spot.Log.log;
/** /**
* Handles the movement of bodies between locations in the scene and creates the necessary * Handles the movement of bodies between locations in the scene and creates the necessary
* distributed objects to allow bodies in clusters to chat with one another. * distributed objects to allow bodies in clusters to chat with one another.
@@ -143,7 +148,7 @@ public class SpotSceneManager extends SceneManager
while (cliter.hasNext()) { while (cliter.hasNext()) {
ClusterRecord clrec = cliter.next(); ClusterRecord clrec = cliter.next();
if (clrec.containsKey(bodyOid)) { if (clrec.containsKey(bodyOid)) {
Log.info("Pruning departed body from cluster [boid=" + bodyOid + log.info("Pruning departed body from cluster [boid=" + bodyOid +
", cluster=" + clrec + "]."); ", cluster=" + clrec + "].");
clrec.removeBody(bodyOid); clrec.removeBody(bodyOid);
if (clrec.size() == 0) { if (clrec.size() == 0) {
@@ -176,7 +181,7 @@ public class SpotSceneManager extends SceneManager
if (from != null && from.targetPortalId != -1) { if (from != null && from.targetPortalId != -1) {
entry = _sscene.getPortal(from.targetPortalId); entry = _sscene.getPortal(from.targetPortalId);
if (entry == null) { if (entry == null) {
Log.warning("Body mapped at invalid portal [where=" + where() + log.warning("Body mapped at invalid portal [where=" + where() +
", who=" + body.who() + ", from=" + from + "]."); ", who=" + body.who() + ", from=" + from + "].");
entry = _sscene.getDefaultEntrance(); entry = _sscene.getDefaultEntrance();
} }
@@ -212,7 +217,7 @@ public class SpotSceneManager extends SceneManager
{ {
SpotScene scene = (SpotScene)getScene(); SpotScene scene = (SpotScene)getScene();
if (scene == null) { if (scene == null) {
Log.warning("No scene in moveBodyToDefaultPortal()? [who=" + body.who() + log.warning("No scene in moveBodyToDefaultPortal()? [who=" + body.who() +
", where=" + where() + "]."); ", where=" + where() + "].");
return; return;
} }
@@ -221,7 +226,7 @@ public class SpotSceneManager extends SceneManager
Location eloc = scene.getDefaultEntrance().getLocation(); Location eloc = scene.getDefaultEntrance().getLocation();
handleChangeLoc(body, eloc); handleChangeLoc(body, eloc);
} catch (InvocationException ie) { } catch (InvocationException ie) {
Log.warning("Could not move user to default portal [where=" + where() + log.warning("Could not move user to default portal [where=" + where() +
", who=" + body.who() + ", error=" + ie + "]."); ", who=" + body.who() + ", error=" + ie + "].");
} }
} }
@@ -241,7 +246,7 @@ public class SpotSceneManager extends SceneManager
{ {
// make sure they are in our scene // make sure they are in our scene
if (!_ssobj.occupants.contains(source.getOid())) { if (!_ssobj.occupants.contains(source.getOid())) {
Log.warning("Refusing change loc from non-scene occupant [where=" + where() + log.warning("Refusing change loc from non-scene occupant [where=" + where() +
", who=" + source.who() + ", loc=" + loc + "]."); ", who=" + source.who() + ", loc=" + loc + "].");
throw new InvocationException(INTERNAL_ERROR); throw new InvocationException(INTERNAL_ERROR);
} }
@@ -277,7 +282,7 @@ public class SpotSceneManager extends SceneManager
SceneLocation sloc = new SceneLocation(loc, source.getOid()); SceneLocation sloc = new SceneLocation(loc, source.getOid());
if (!_ssobj.occupantLocs.contains(sloc)) { if (!_ssobj.occupantLocs.contains(sloc)) {
// complain if they don't already have a location configured // complain if they don't already have a location configured
Log.warning("Changing loc for occupant without previous loc [where=" + where() + log.warning("Changing loc for occupant without previous loc [where=" + where() +
", who=" + source.who() + ", nloc=" + loc + "]."); ", who=" + source.who() + ", nloc=" + loc + "].");
Thread.dumpStack(); Thread.dumpStack();
_ssobj.addToOccupantLocs(sloc); _ssobj.addToOccupantLocs(sloc);
@@ -310,7 +315,7 @@ public class SpotSceneManager extends SceneManager
// otherwise see if they sent us the user's oid // otherwise see if they sent us the user's oid
DObject tobj = CrowdServer.omgr.getObject(targetOid); DObject tobj = CrowdServer.omgr.getObject(targetOid);
if (!(tobj instanceof BodyObject)) { if (!(tobj instanceof BodyObject)) {
Log.info("Can't join cluster, missing target [creator=" + joiner.who() + log.info("Can't join cluster, missing target [creator=" + joiner.who() +
", targetOid=" + targetOid + "]."); ", targetOid=" + targetOid + "].");
throw new InvocationException(NO_SUCH_CLUSTER); throw new InvocationException(NO_SUCH_CLUSTER);
} }
@@ -318,7 +323,7 @@ public class SpotSceneManager extends SceneManager
// make sure we're in the same scene as said user // make sure we're in the same scene as said user
BodyObject friend = (BodyObject)tobj; BodyObject friend = (BodyObject)tobj;
if (friend.getPlaceOid() != joiner.getPlaceOid()) { if (friend.getPlaceOid() != joiner.getPlaceOid()) {
Log.info("Refusing cluster join from non-proximate user [joiner=" + joiner.who() + log.info("Refusing cluster join from non-proximate user [joiner=" + joiner.who() +
", jloc=" + joiner.location + ", target=" + friend.who() + ", jloc=" + joiner.location + ", target=" + friend.who() +
", tloc=" + friend.location + "]."); ", tloc=" + friend.location + "].");
throw new InvocationException(NO_SUCH_CLUSTER); throw new InvocationException(NO_SUCH_CLUSTER);
@@ -405,7 +410,7 @@ public class SpotSceneManager extends SceneManager
{ {
ClusterRecord clrec = getCluster(sourceOid); ClusterRecord clrec = getCluster(sourceOid);
if (clrec == null) { if (clrec == null) {
Log.warning("Non-clustered user requested cluster speak [where=" + where() + log.warning("Non-clustered user requested cluster speak [where=" + where() +
", chatter=" + message.speaker + " (" + sourceOid + "), " + ", chatter=" + message.speaker + " (" + sourceOid + "), " +
"msg=" + message + "]."); "msg=" + message + "].");
} else { } else {
@@ -472,7 +477,7 @@ public class SpotSceneManager extends SceneManager
throws InvocationException throws InvocationException
{ {
if (!(body instanceof ClusteredBodyObject)) { if (!(body instanceof ClusteredBodyObject)) {
Log.warning("Refusing to add non-clustered body to cluster [cloid=" + log.warning("Refusing to add non-clustered body to cluster [cloid=" +
_clobj.getOid() + ", size=" + size() + ", who=" + body.who() + "]."); _clobj.getOid() + ", size=" + size() + ", who=" + body.who() + "].");
throw new InvocationException(INTERNAL_ERROR); throw new InvocationException(INTERNAL_ERROR);
} }
@@ -518,7 +523,7 @@ public class SpotSceneManager extends SceneManager
{ {
BodyObject body = (BodyObject)remove(bodyOid); BodyObject body = (BodyObject)remove(bodyOid);
if (body == null) { if (body == null) {
Log.warning("Requested to remove unknown body from cluster [cloid=" + log.warning("Requested to remove unknown body from cluster [cloid=" +
_clobj.getOid() + ", size=" + size() + ", who=" + bodyOid + "]."); _clobj.getOid() + ", size=" + size() + ", who=" + bodyOid + "].");
return; return;
} }
@@ -29,11 +29,12 @@ import org.xml.sax.helpers.AttributesImpl;
import com.megginson.sax.DataWriter; import com.megginson.sax.DataWriter;
import com.threerings.tools.xml.NestableWriter; import com.threerings.tools.xml.NestableWriter;
import com.threerings.whirled.spot.Log;
import com.threerings.whirled.spot.data.Location; import com.threerings.whirled.spot.data.Location;
import com.threerings.whirled.spot.data.SpotSceneModel; import com.threerings.whirled.spot.data.SpotSceneModel;
import com.threerings.whirled.spot.tools.EditablePortal; import com.threerings.whirled.spot.tools.EditablePortal;
import static com.threerings.whirled.spot.Log.log;
/** /**
* Generates an XML representation of a {@link SpotSceneModel}. * Generates an XML representation of a {@link SpotSceneModel}.
*/ */
@@ -93,7 +94,7 @@ public class SpotSceneWriter
attrs.addAttribute("", fields[ii].getName(), "", "", attrs.addAttribute("", fields[ii].getName(), "", "",
String.valueOf(fields[ii].get(portalLoc))); String.valueOf(fields[ii].get(portalLoc)));
} catch (IllegalAccessException iae) { } catch (IllegalAccessException iae) {
Log.warning("Unable to write portal field, skipping " + log.warning("Unable to write portal field, skipping " +
"[field=" + fields[ii].getName() + ", e=" + iae + "]."); "[field=" + fields[ii].getName() + ", e=" + iae + "].");
} }
} }
@@ -32,10 +32,11 @@ import org.xml.sax.helpers.AttributesImpl;
import com.megginson.sax.DataWriter; import com.megginson.sax.DataWriter;
import com.threerings.tools.xml.NestableWriter; import com.threerings.tools.xml.NestableWriter;
import com.threerings.whirled.Log;
import com.threerings.whirled.data.AuxModel; import com.threerings.whirled.data.AuxModel;
import com.threerings.whirled.data.SceneModel; import com.threerings.whirled.data.SceneModel;
import static com.threerings.whirled.Log.log;
/** /**
* Generates an XML representation of an {@link SceneModel}. * Generates an XML representation of an {@link SceneModel}.
*/ */
@@ -111,7 +112,7 @@ public class SceneWriter
if (awriter != null) { if (awriter != null) {
awriter.write(amodel, writer); awriter.write(amodel, writer);
} else { } else {
Log.warning("No writer registered for auxiliary scene model " + log.warning("No writer registered for auxiliary scene model " +
"[mclass=" + amodel.getClass() + "]."); "[mclass=" + amodel.getClass() + "].");
} }
} }
@@ -25,9 +25,10 @@ import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.threerings.whirled.Log;
import com.threerings.whirled.data.SceneUpdate; import com.threerings.whirled.data.SceneUpdate;
import static com.threerings.whirled.Log.log;
/** /**
* A list specialized for storing {@link SceneUpdate} objects. * A list specialized for storing {@link SceneUpdate} objects.
*/ */
@@ -51,7 +52,7 @@ public class UpdateList
int expVersion = last.getSceneVersion() + last.getVersionIncrement(); int expVersion = last.getSceneVersion() + last.getVersionIncrement();
int gotVersion = update.getSceneVersion(); int gotVersion = update.getSceneVersion();
if (gotVersion > expVersion) { if (gotVersion > expVersion) {
Log.warning("Update continuity broken, flushing list [got=" + update + log.warning("Update continuity broken, flushing list [got=" + update +
", expect=" + expVersion + ", ucount=" + _updates.size() + "]."); ", expect=" + expVersion + ", ucount=" + _updates.size() + "].");
_updates.clear(); // flush out our old updates, fall through and add this one _updates.clear(); // flush out our old updates, fall through and add this one
+4 -28
View File
@@ -21,36 +21,12 @@
package com.threerings.whirled.zone; package com.threerings.whirled.zone;
import com.samskivert.util.Logger;
/** /**
* A placeholder class that contains a reference to the log object used by * Contains a reference to the log object used by the Whirled Zone services.
* the Whirled Zone services.
*/ */
public class Log public class Log
{ {
public static com.samskivert.util.Log log = public static Logger log = Logger.getLogger("com.threerings.whirled.zone");
new com.samskivert.util.Log("whirled.zone");
/** 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);
}
} }
@@ -35,10 +35,11 @@ import com.threerings.whirled.data.SceneModel;
import com.threerings.whirled.data.SceneUpdate; import com.threerings.whirled.data.SceneUpdate;
import com.threerings.whirled.util.WhirledContext; import com.threerings.whirled.util.WhirledContext;
import com.threerings.whirled.zone.Log;
import com.threerings.whirled.zone.data.ZoneSummary; import com.threerings.whirled.zone.data.ZoneSummary;
import com.threerings.whirled.zone.util.ZoneUtil; import com.threerings.whirled.zone.util.ZoneUtil;
import static com.threerings.whirled.zone.Log.log;
/** /**
* The zone director augments the scene services with the notion of zones. Zones are * The zone director augments the scene services with the notion of zones. Zones are
* self-contained, connected groups of scenes. The normal scene director services can be used to * self-contained, connected groups of scenes. The normal scene director services can be used to
@@ -112,7 +113,7 @@ public class ZoneDirector extends BasicDirector
{ {
// make sure the zoneId and sceneId are valid // make sure the zoneId and sceneId are valid
if (zoneId < 0 || sceneId < 0) { if (zoneId < 0 || sceneId < 0) {
Log.warning("Refusing moveTo(): invalid sceneId or zoneId " + log.warning("Refusing moveTo(): invalid sceneId or zoneId " +
"[zoneId=" + zoneId + ", sceneId=" + sceneId + "]."); "[zoneId=" + zoneId + ", sceneId=" + sceneId + "].");
return false; return false;
} }
@@ -141,7 +142,7 @@ public class ZoneDirector extends BasicDirector
} }
// issue a moveTo request // issue a moveTo request
Log.info("Issuing zoned moveTo(" + ZoneUtil.toString(zoneId) + log.info("Issuing zoned moveTo(" + ZoneUtil.toString(zoneId) +
", " + sceneId + ", " + sceneVers + ")."); ", " + sceneId + ", " + sceneVers + ").");
_zservice.moveTo(_ctx.getClient(), zoneId, sceneId, sceneVers, this); _zservice.moveTo(_ctx.getClient(), zoneId, sceneId, sceneVers, this);
return true; return true;
@@ -227,13 +228,13 @@ public class ZoneDirector extends BasicDirector
// just finish up what we're doing and assume that the repeated move request was the // just finish up what we're doing and assume that the repeated move request was the
// spurious one as it would be in the case of lag causing rapid-fire repeat requests // spurious one as it would be in the case of lag causing rapid-fire repeat requests
if (_scdir.movePending()) { if (_scdir.movePending()) {
Log.info("Dropping forced move because we have a move pending " + log.info("Dropping forced move because we have a move pending " +
"[pend=" + _scdir.getPendingModel() + ", rzId=" + zoneId + "[pend=" + _scdir.getPendingModel() + ", rzId=" + zoneId +
", rsId=" + sceneId + "]."); ", rsId=" + sceneId + "].");
return; return;
} }
Log.info("Moving at request of server [zoneId=" + zoneId + ", sceneId=" + sceneId + "]."); log.info("Moving at request of server [zoneId=" + zoneId + ", sceneId=" + sceneId + "].");
// clear out our old scene and place data // clear out our old scene and place data
_scdir.didLeaveScene(); _scdir.didLeaveScene();
// move to the new zone and scene // move to the new zone and scene
@@ -272,9 +273,8 @@ public class ZoneDirector extends BasicDirector
} }
} catch (Throwable t) { } catch (Throwable t) {
Log.warning("Zone observer choked during notification [data=" + data + log.warning("Zone observer choked during notification [data=" + data +
", obs=" + obs + "]."); ", obs=" + obs + "].", t);
Log.logStackTrace(t);
} }
} }
} }
@@ -35,12 +35,13 @@ import com.threerings.whirled.server.SceneMoveHandler;
import com.threerings.whirled.server.SceneRegistry; import com.threerings.whirled.server.SceneRegistry;
import com.threerings.whirled.server.WhirledServer; import com.threerings.whirled.server.WhirledServer;
import com.threerings.whirled.zone.Log;
import com.threerings.whirled.zone.client.ZoneService; import com.threerings.whirled.zone.client.ZoneService;
import com.threerings.whirled.zone.data.ZoneCodes; import com.threerings.whirled.zone.data.ZoneCodes;
import com.threerings.whirled.zone.data.ZoneSummary; import com.threerings.whirled.zone.data.ZoneSummary;
import com.threerings.whirled.zone.data.ZonedBodyObject; import com.threerings.whirled.zone.data.ZonedBodyObject;
import static com.threerings.whirled.zone.Log.log;
/** /**
* Handles transitioning between zones. * Handles transitioning between zones.
*/ */
@@ -74,7 +75,7 @@ public class ZoneMoveHandler extends AbstractSceneMoveHandler
// from interface ZoneManager.ResolutionListener // from interface ZoneManager.ResolutionListener
public void zoneFailedToResolve (int zoneId, Exception reason) public void zoneFailedToResolve (int zoneId, Exception reason)
{ {
Log.warning("Unable to resolve zone [zoneId=" + zoneId + ", reason=" + reason + "]."); log.warning("Unable to resolve zone [zoneId=" + zoneId + ", reason=" + reason + "].");
_listener.requestFailed(ZoneCodes.NO_SUCH_ZONE); _listener.requestFailed(ZoneCodes.NO_SUCH_ZONE);
} }
@@ -36,12 +36,13 @@ import com.threerings.whirled.data.SceneUpdate;
import com.threerings.whirled.server.SceneManager; import com.threerings.whirled.server.SceneManager;
import com.threerings.whirled.server.SceneRegistry; import com.threerings.whirled.server.SceneRegistry;
import com.threerings.whirled.zone.Log;
import com.threerings.whirled.zone.client.ZoneService.ZoneMoveListener; import com.threerings.whirled.zone.client.ZoneService.ZoneMoveListener;
import com.threerings.whirled.zone.data.ZoneCodes; import com.threerings.whirled.zone.data.ZoneCodes;
import com.threerings.whirled.zone.data.ZoneSummary; import com.threerings.whirled.zone.data.ZoneSummary;
import com.threerings.whirled.zone.data.ZonedBodyObject; import com.threerings.whirled.zone.data.ZonedBodyObject;
import static com.threerings.whirled.zone.Log.log;
/** /**
* Provides zone related services which are presently the ability to move from zone to zone. * Provides zone related services which are presently the ability to move from zone to zone.
*/ */
@@ -74,7 +75,7 @@ public class ZoneProvider
throws InvocationException throws InvocationException
{ {
if (!(caller instanceof ZonedBodyObject)) { if (!(caller instanceof ZonedBodyObject)) {
Log.warning("Request to switch zones by non-ZonedBodyObject " + log.warning("Request to switch zones by non-ZonedBodyObject " +
"[clobj=" + caller.getClass() + "]."); "[clobj=" + caller.getClass() + "].");
throw new InvocationException(INTERNAL_ERROR); throw new InvocationException(INTERNAL_ERROR);
} }
@@ -93,7 +94,7 @@ public class ZoneProvider
// look up the zone manager for the zone // look up the zone manager for the zone
ZoneManager zmgr = _zonereg.getZoneManager(zoneId); ZoneManager zmgr = _zonereg.getZoneManager(zoneId);
if (zmgr == null) { if (zmgr == null) {
Log.warning("Requested to enter a zone for which we have no manager " + log.warning("Requested to enter a zone for which we have no manager " +
"[user=" + body.who() + ", zoneId=" + zoneId + "]."); "[user=" + body.who() + ", zoneId=" + zoneId + "].");
throw new InvocationException(NO_SUCH_ZONE); throw new InvocationException(NO_SUCH_ZONE);
} }
@@ -28,10 +28,11 @@ import com.threerings.presents.server.InvocationManager;
import com.threerings.crowd.server.PlaceRegistry; import com.threerings.crowd.server.PlaceRegistry;
import com.threerings.whirled.server.SceneRegistry; import com.threerings.whirled.server.SceneRegistry;
import com.threerings.whirled.zone.Log;
import com.threerings.whirled.zone.data.ZoneCodes; import com.threerings.whirled.zone.data.ZoneCodes;
import com.threerings.whirled.zone.util.ZoneUtil; import com.threerings.whirled.zone.util.ZoneUtil;
import static com.threerings.whirled.zone.Log.log;
/** /**
* The zone registry takes care of mapping zone requests to the appropriate registered zone * The zone registry takes care of mapping zone requests to the appropriate registered zone
* manager. * manager.
@@ -61,7 +62,7 @@ public class ZoneRegistry
{ {
ZoneManager old = (ZoneManager)_managers.get(zoneType); ZoneManager old = (ZoneManager)_managers.get(zoneType);
if (old != null) { if (old != null) {
Log.warning("Zone manager already registered with requested type [type=" + zoneType + log.warning("Zone manager already registered with requested type [type=" + zoneType +
", old=" + old + ", new=" + manager + "]."); ", old=" + old + ", new=" + manager + "].");
} else { } else {
_managers.put(zoneType, manager); _managers.put(zoneType, manager);
@@ -30,12 +30,13 @@ import com.threerings.crowd.client.*;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.util.CrowdContext; import com.threerings.crowd.util.CrowdContext;
import com.threerings.parlor.Log;
import com.threerings.parlor.client.*; import com.threerings.parlor.client.*;
import com.threerings.parlor.game.client.*; import com.threerings.parlor.game.client.*;
import com.threerings.parlor.game.data.*; import com.threerings.parlor.game.data.*;
import com.threerings.parlor.util.ParlorContext; import com.threerings.parlor.util.ParlorContext;
import static com.threerings.parlor.Log.log;
public class TestClient extends com.threerings.crowd.client.TestClient public class TestClient extends com.threerings.crowd.client.TestClient
implements InvitationHandler, InvitationResponseObserver implements InvitationHandler, InvitationResponseObserver
{ {
@@ -54,7 +55,7 @@ public class TestClient extends com.threerings.crowd.client.TestClient
{ {
// we intentionally don't call super() // we intentionally don't call super()
Log.info("Client did logon [client=" + client + "]."); log.info("Client did logon [client=" + client + "].");
// get a casted reference to our body object // get a casted reference to our body object
_body = (BodyObject)client.getClientObject(); _body = (BodyObject)client.getClientObject();
@@ -69,7 +70,7 @@ public class TestClient extends com.threerings.crowd.client.TestClient
public void invitationReceived (Invitation invite) public void invitationReceived (Invitation invite)
{ {
Log.info("Invitation received [invite=" + invite + "]."); log.info("Invitation received [invite=" + invite + "].");
// accept the invitation. we're game... // accept the invitation. we're game...
invite.accept(); invite.accept();
@@ -77,23 +78,23 @@ public class TestClient extends com.threerings.crowd.client.TestClient
public void invitationCancelled (Invitation invite) public void invitationCancelled (Invitation invite)
{ {
Log.info("Invitation cancelled [invite=" + invite + "]."); log.info("Invitation cancelled [invite=" + invite + "].");
} }
public void invitationAccepted (Invitation invite) public void invitationAccepted (Invitation invite)
{ {
Log.info("Invitation accepted [invite=" + invite + "]."); log.info("Invitation accepted [invite=" + invite + "].");
} }
public void invitationRefused (Invitation invite, String message) public void invitationRefused (Invitation invite, String message)
{ {
Log.info("Invitation refused [invite=" + invite + log.info("Invitation refused [invite=" + invite +
", message=" + message + "]."); ", message=" + message + "].");
} }
public void invitationCountered (Invitation invite, GameConfig config) public void invitationCountered (Invitation invite, GameConfig config)
{ {
Log.info("Invitation countered [invite=" + invite + log.info("Invitation countered [invite=" + invite +
", config=" + config + "]."); ", config=" + config + "].");
} }
@@ -23,9 +23,10 @@ package com.threerings.parlor;
import com.threerings.crowd.server.CrowdServer; import com.threerings.crowd.server.CrowdServer;
import com.threerings.parlor.Log;
import com.threerings.parlor.server.ParlorManager; import com.threerings.parlor.server.ParlorManager;
import static com.threerings.parlor.Log.log;
/** /**
* A test server for the Parlor services. * A test server for the Parlor services.
*/ */
@@ -43,7 +44,7 @@ public class TestServer extends CrowdServer
// initialize our parlor manager // initialize our parlor manager
parmgr.init(invmgr, plreg); parmgr.init(invmgr, plreg);
Log.info("Parlor server initialized."); log.info("Parlor server initialized.");
} }
/** Main entry point for test server. */ /** Main entry point for test server. */
@@ -54,8 +55,7 @@ public class TestServer extends CrowdServer
server.init(); server.init();
server.run(); server.run();
} catch (Exception e) { } catch (Exception e) {
Log.warning("Unable to initialize server."); log.warning("Unable to initialize server.", e);
Log.logStackTrace(e);
} }
} }
} }
@@ -23,11 +23,12 @@ package com.threerings.whirled;
import java.io.IOException; import java.io.IOException;
import com.threerings.whirled.Log;
import com.threerings.whirled.client.persist.SceneRepository; import com.threerings.whirled.client.persist.SceneRepository;
import com.threerings.whirled.data.SceneModel; import com.threerings.whirled.data.SceneModel;
import com.threerings.whirled.util.NoSuchSceneException; import com.threerings.whirled.util.NoSuchSceneException;
import static com.threerings.whirled.Log.log;
/** /**
* The dummy scene repository just pretends to load and store scenes, but * The dummy scene repository just pretends to load and store scenes, but
* in fact it just creates new blank scenes when requested to load a scene * in fact it just creates new blank scenes when requested to load a scene
@@ -39,7 +40,7 @@ public class DummyClientSceneRepository implements SceneRepository
public SceneModel loadSceneModel (int sceneId) public SceneModel loadSceneModel (int sceneId)
throws IOException, NoSuchSceneException throws IOException, NoSuchSceneException
{ {
Log.info("Creating dummy scene model [id=" + sceneId + "]."); log.info("Creating dummy scene model [id=" + sceneId + "].");
return new SceneModel(); return new SceneModel();
} }