Simplified logging facilities.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4131 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-05-19 22:47:44 +00:00
parent 98bbe02560
commit a22ca8b079
39 changed files with 286 additions and 358 deletions
+102
View File
@@ -0,0 +1,102 @@
package {
import flash.utils.getQualifiedClassName;
import mx.logging.ILogger;
import mx.logging.LogEventLevel;
import mx.logging.targets.TraceTarget;
/**
* A simple logging mechanism built on top of the standard mx logging
* facilities.
*
* This class need not be imported.
*
* Typical usage for creating a Log to be used by the entire class would be:
* public class MyClass
* {
* private static const log :Log = Log.getLog(MyClass);
* ...
*
* OR, if you just need a one-off Log:
* protected function doStuff (thingy :Thingy) :void
* {
* if (thingy == null) {
* Log.getLog(this).warn("thiny is null!");
* ....
*/
public class Log
{
/**
* Retrieve a Log for the specififed class.
*
* @param spec can be any Object or Class specifier.
*/
public static function getLog (spec :*) :Log
{
// let's just use the full classname
var path :String = getQualifiedClassName(spec).replace("::", ".");
return new Log(mx.logging.Log.getLogger(path));
}
/**
* @private
*/
public function Log (dest :ILogger)
{
_dest = dest;
}
/**
* Log a message with 'debug' priority.
*/
public function debug (... messages) :void
{
_dest.debug.apply(_dest, messages);
}
/**
* Log a message with 'info' priority.
*/
public function info (... messages) :void
{
_dest.info.apply(_dest, messages);
}
/**
* Log a message with 'debug' priority.
*/
public function warning (... messages) :void
{
_dest.warn.apply(_dest, messages);
}
/**
* Log a message with 'debug' priority.
*/
public function logStackTrace (error :Error) :void
{
_dest.warn(error.getStackTrace());
}
/**
* Our static (class) initializer.
*/
private static function staticInit () :void
{
var targ :TraceTarget = new TraceTarget();
targ.includeCategory = targ.includeDate = targ.includeLevel =
targ.includeTime = true;
targ.filters = ["*"]; // TODO
targ.level = LogEventLevel.DEBUG;
mx.logging.Log.addTarget(targ);
}
staticInit(); // call the static initializer
/** Our true destination. */
protected var _dest :ILogger;
}
}
-36
View File
@@ -1,36 +0,0 @@
package com.threerings.crowd {
import mx.logging.ILogger;
import com.threerings.util.LogDaddy;
public class Log extends LogDaddy
{
/** The Logger for this package. */
public static var log :ILogger = getLogger("crowd");
/** Convenience function. */
public static function debug (message :String, ... rest) :void
{
log.debug(message, rest);
}
/** Convenience function. */
public static function info (message :String, ... rest) :void
{
log.info(message, rest);
}
/** Convenience function. */
public static function warning (message :String, ... rest) :void
{
log.warn(message, rest);
}
/** Convenience function. */
public static function logStackTrace (err :Error) :void
{
log.warn(err.getStackTrace());
}
}
}
@@ -43,7 +43,6 @@ import com.threerings.util.MessageManager;
import com.threerings.util.Name; import com.threerings.util.Name;
import com.threerings.util.TimeUtil; import com.threerings.util.TimeUtil;
import com.threerings.crowd.Log;
import com.threerings.crowd.client.LocationObserver; import com.threerings.crowd.client.LocationObserver;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
@@ -88,7 +87,8 @@ public class ChatDirector extends BasicDirector
_cctx.getLocationDirector().addLocationObserver(this); _cctx.getLocationDirector().addLocationObserver(this);
if (_bundle == null || _msgmgr == null) { if (_bundle == null || _msgmgr == null) {
com.threerings.crowd.Log.warning("Null bundle or message manager given to ChatDirector"); Log.getLog(this).warning(
"Null bundle or message manager given to ChatDirector");
return; return;
} }
var msg :MessageBundle = _msgmgr.getBundle(_bundle); var msg :MessageBundle = _msgmgr.getBundle(_bundle);
@@ -906,7 +906,7 @@ public class ChatDirector extends BasicDirector
if (bundle != null && _msgmgr != null) { if (bundle != null && _msgmgr != null) {
var msgb :MessageBundle = _msgmgr.getBundle(bundle); var msgb :MessageBundle = _msgmgr.getBundle(bundle);
if (msgb == null) { if (msgb == null) {
com.threerings.crowd.Log.warning( Log.getLog(this).warning(
"No message bundle available to translate message " + "No message bundle available to translate message " +
"[bundle=" + bundle + ", message=" + message + "]."); "[bundle=" + bundle + ", message=" + message + "].");
} else { } else {
@@ -33,7 +33,6 @@ import com.threerings.presents.dobj.ObjectAccessError;
import com.threerings.presents.dobj.Subscriber; import com.threerings.presents.dobj.Subscriber;
import com.threerings.presents.dobj.SubscriberAdapter; import com.threerings.presents.dobj.SubscriberAdapter;
import com.threerings.crowd.Log;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.LocationCodes; import com.threerings.crowd.data.LocationCodes;
import com.threerings.crowd.data.PlaceConfig; import com.threerings.crowd.data.PlaceConfig;
@@ -50,19 +49,7 @@ import com.threerings.crowd.util.CrowdContext;
public class LocationDirector extends BasicDirector public class LocationDirector extends BasicDirector
implements Subscriber, LocationReceiver implements Subscriber, LocationReceiver
{ {
/** private static const log :Log = Log.getLog(LocationDirector);
* Used to recover from a moveTo request that was accepted but
* resulted in a failed attempt to fetch the place object to which we
* were moving.
*/
// public static interface FailureHandler
// {
// /**
// * Should instruct the client to move to the last known working
// * location (as well as clean up after the failed moveTo request).
// */
// public void recoverFailedMove (int placeId);
// }
/** /**
* Constructs a location director which will configure itself for * Constructs a location director which will configure itself for
@@ -128,7 +115,7 @@ public class LocationDirector extends BasicDirector
{ {
// make sure the placeId is valid // make sure the placeId is valid
if (placeId < 0) { if (placeId < 0) {
Log.warning("Refusing moveTo(): invalid placeId " + placeId + "."); log.warning("Refusing moveTo(): invalid placeId " + placeId + ".");
return false; return false;
} }
@@ -149,13 +136,13 @@ public class LocationDirector extends BasicDirector
// minute, go ahead and let this new one through in an attempt // minute, go ahead and let this new one through in an attempt
// to recover from dropped moveTo requests // to recover from dropped moveTo requests
if (refuse) { if (refuse) {
Log.warning("Refusing moveTo; We have a request outstanding " + log.warning("Refusing moveTo; We have a request outstanding " +
"[ppid=" + _pendingPlaceId + "[ppid=" + _pendingPlaceId +
", npid=" + placeId + "]."); ", npid=" + placeId + "].");
return false; return false;
} else { } else {
Log.warning("Overriding stale moveTo request " + log.warning("Overriding stale moveTo request " +
"[ppid=" + _pendingPlaceId + "[ppid=" + _pendingPlaceId +
", npid=" + placeId + "]."); ", npid=" + placeId + "].");
} }
@@ -179,7 +166,7 @@ public class LocationDirector extends BasicDirector
var placeId :int = _pendingPlaceId; var placeId :int = _pendingPlaceId;
_pendingPlaceId = -1; _pendingPlaceId = -1;
Log.info("moveTo failed [pid=" + placeId + log.info("moveTo failed [pid=" + placeId +
", reason=" + reason + "]."); ", reason=" + reason + "].");
// let our observers know that something has gone horribly awry // let our observers know that something has gone horribly awry
@@ -187,7 +174,7 @@ public class LocationDirector extends BasicDirector
}; };
// issue a moveTo request // issue a moveTo request
Log.info("Issuing moveTo(" + placeId + ")."); log.info("Issuing moveTo(" + placeId + ").");
_lservice.moveTo(_cctx.getClient(), placeId, _lservice.moveTo(_cctx.getClient(), placeId,
new MoveAdapter(success, failure)); new MoveAdapter(success, failure));
return true; return true;
@@ -276,9 +263,9 @@ public class LocationDirector extends BasicDirector
try { try {
_controller.mayLeavePlace(_plobj); _controller.mayLeavePlace(_plobj);
} catch (e :Error) { } catch (e :Error) {
Log.warning("Place controller choked in " + log.warning("Place controller choked in " +
"mayLeavePlace [plobj=" + _plobj + "]."); "mayLeavePlace [plobj=" + _plobj + "].");
Log.logStackTrace(e); log.logStackTrace(e);
} }
} }
} }
@@ -315,7 +302,7 @@ public class LocationDirector extends BasicDirector
// check whether we should use a custom class loader // check whether we should use a custom class loader
_controller = config.createController(); _controller = config.createController();
if (_controller == null) { if (_controller == null) {
Log.warning("Place config returned null controller " + log.warning("Place config returned null controller " +
"[config=" + config + "]."); "[config=" + config + "].");
return; return;
} }
@@ -339,9 +326,9 @@ public class LocationDirector extends BasicDirector
try { try {
_controller.didLeavePlace(_plobj); _controller.didLeavePlace(_plobj);
} catch (e :Error) { } catch (e :Error) {
Log.warning("Place controller choked in " + log.warning("Place controller choked in " +
"didLeavePlace [plobj=" + _plobj + "]."); "didLeavePlace [plobj=" + _plobj + "].");
Log.logStackTrace(e); log.logStackTrace(e);
} }
_controller = null; _controller = null;
} }
@@ -405,7 +392,7 @@ public class LocationDirector extends BasicDirector
}; };
var failure :Function = function ( var failure :Function = function (
oid :int, cause :ObjectAccessError) :void { oid :int, cause :ObjectAccessError) :void {
Log.warning("Location director unable to fetch body " + log.warning("Location director unable to fetch body " +
"object; all has gone horribly wrong" + "object; all has gone horribly wrong" +
"[cause=" + cause + "]."); "[cause=" + cause + "].");
}; };
@@ -453,7 +440,7 @@ public class LocationDirector extends BasicDirector
// documentation inherited from interface // documentation inherited from interface
public function forcedMove (placeId :int) :void public function forcedMove (placeId :int) :void
{ {
Log.info("Moving at request of server [placeId=" + placeId + "]."); log.info("Moving at request of server [placeId=" + placeId + "].");
if (movePending()) { if (movePending()) {
// clear out our old place information // clear out our old place information
@@ -476,9 +463,9 @@ public class LocationDirector extends BasicDirector
try { try {
_controller.willEnterPlace(_plobj); _controller.willEnterPlace(_plobj);
} catch (e :Error) { } catch (e :Error) {
Log.warning("Controller choked in willEnterPlace " + log.warning("Controller choked in willEnterPlace " +
"[place=" + _plobj + "]."); "[place=" + _plobj + "].");
Log.logStackTrace(e); log.logStackTrace(e);
} }
} }
@@ -491,7 +478,7 @@ public class LocationDirector extends BasicDirector
{ {
// aiya! we were unable to fetch our new place object; something // aiya! we were unable to fetch our new place object; something
// is badly wrong // is badly wrong
Log.warning("Aiya! Unable to fetch place object for new location " + log.warning("Aiya! Unable to fetch place object for new location " +
"[plid=" + oid + ", reason=" + cause + "]."); "[plid=" + oid + ", reason=" + cause + "].");
// clear out our half initialized place info // clear out our half initialized place info
@@ -533,7 +520,7 @@ public class LocationDirector extends BasicDirector
// public void setFailureHandler (FailureHandler handler) // public void setFailureHandler (FailureHandler handler)
// { // {
// if (_failureHandler != null) { // if (_failureHandler != null) {
// Log.warning("Requested to set failure handler, but we've " + // log.warning("Requested to set failure handler, but we've " +
// "already got one. The conflicting entities will " + // "already got one. The conflicting entities will " +
// "likely need to perform more sophisticated " + // "likely need to perform more sophisticated " +
// "coordination to deal with failures. " + // "coordination to deal with failures. " +
@@ -0,0 +1,17 @@
package com.threerings.crowd.client {
/**
* Used to recover from a moveTo request that was accepted but
* resulted in a failed attempt to fetch the place object to which we
* were moving.
*/
public interface LocationDirector_FailureHandler
{
/**
* Should instruct the client to move to the last known working
* location (as well as clean up after the failed moveTo request).
*/
function recoverFailedMove (placeId :int) :void;
}
}
@@ -33,7 +33,6 @@ import com.threerings.presents.dobj.EntryRemovedEvent;
import com.threerings.presents.dobj.EntryUpdatedEvent; import com.threerings.presents.dobj.EntryUpdatedEvent;
import com.threerings.presents.dobj.SetListener; import com.threerings.presents.dobj.SetListener;
import com.threerings.crowd.Log;
import com.threerings.crowd.data.OccupantInfo; 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;
@@ -23,7 +23,6 @@ package com.threerings.crowd.client {
import flash.display.DisplayObjectContainer; import flash.display.DisplayObjectContainer;
import com.threerings.crowd.Log;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
/** /**
@@ -72,9 +71,10 @@ public class PlaceViewUtil
try { try {
(root as PlaceView)[funct](plobj); (root as PlaceView)[funct](plobj);
} catch (e :Error) { } catch (e :Error) {
Log.warning("Component choked on " + funct + "() " + var log :Log = Log.getLog(PlaceViewUtil);
log.warning("Component choked on " + funct + "() " +
"[component=" + root + ", plobj=" + plobj + "]."); "[component=" + root + ", plobj=" + plobj + "].");
Log.logStackTrace(e); log.logStackTrace(e);
} }
} }
@@ -24,7 +24,6 @@ package com.threerings.crowd.data {
import com.threerings.util.Byte; import com.threerings.util.Byte;
import com.threerings.util.Name; import com.threerings.util.Name;
//import com.threerings.presents.Log;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationCodes; import com.threerings.presents.data.InvocationCodes;
@@ -131,13 +130,9 @@ public class BodyObject extends ClientObject
{ {
super.readObject(ins); super.readObject(ins);
Log.debug("Reading username");
username = (ins.readObject() as Name); username = (ins.readObject() as Name);
Log.debug("Reading location");
location = ins.readInt(); location = ins.readInt();
Log.debug("Reading status");
status = ins.readByte(); status = ins.readByte();
Log.debug("Reading awayMessage");
awayMessage = (ins.readField(String) as String); awayMessage = (ins.readField(String) as String);
} }
@@ -32,7 +32,6 @@ import com.threerings.presents.dobj.DSet;
import com.threerings.presents.dobj.DSet_Entry; import com.threerings.presents.dobj.DSet_Entry;
import com.threerings.presents.dobj.OidList; import com.threerings.presents.dobj.OidList;
import com.threerings.crowd.Log;
import com.threerings.crowd.chat.data.SpeakMarshaller; import com.threerings.crowd.chat.data.SpeakMarshaller;
//import com.threerings.crowd.chat.data.SpeakObject; //import com.threerings.crowd.chat.data.SpeakObject;
+2 -4
View File
@@ -8,8 +8,6 @@ import flash.net.Socket;
import flash.utils.ByteArray; import flash.utils.ByteArray;
import flash.utils.Endian; import flash.utils.Endian;
import com.threerings.presents.Log;
/** /**
* Reads socket data until a complete frame is available. * Reads socket data until a complete frame is available.
* This dispatches a FrameAvailableEvent.FRAME_AVAILABLE once a frame * This dispatches a FrameAvailableEvent.FRAME_AVAILABLE once a frame
@@ -28,7 +26,7 @@ public class FrameReader extends EventDispatcher
*/ */
protected function socketHasData (event :ProgressEvent) :void protected function socketHasData (event :ProgressEvent) :void
{ {
Log.debug("socketHasData(" + _socket.bytesAvailable + ")"); Log.getLog(this).debug("socketHasData(" + _socket.bytesAvailable + ")");
if (_curData == null) { if (_curData == null) {
if (_socket.bytesAvailable < HEADER_SIZE) { if (_socket.bytesAvailable < HEADER_SIZE) {
// if there are less bytes available than a header, let's // if there are less bytes available than a header, let's
@@ -54,7 +52,7 @@ public class FrameReader extends EventDispatcher
if (_length === _curData.length) { if (_length === _curData.length) {
// we have now read a complete frame, let us dispatch the data // we have now read a complete frame, let us dispatch the data
_curData.position = 0; // move the read pointer to the beginning _curData.position = 0; // move the read pointer to the beginning
Log.debug("+ FrameAvailable"); Log.getLog(this).debug("+ FrameAvailable");
dispatchEvent(new FrameAvailableEvent(_curData)); dispatchEvent(new FrameAvailableEvent(_curData));
_curData = null; // clear, so we know we need to first read length _curData = null; // clear, so we know we need to first read length
+11 -9
View File
@@ -9,6 +9,8 @@ import com.threerings.util.ClassUtil;
public class ObjectInputStream public class ObjectInputStream
{ {
private static const log :Log = Log.getLog(ObjectInputStream);
public function ObjectInputStream (source :IDataInput = null) public function ObjectInputStream (source :IDataInput = null)
{ {
if (source == null) { if (source == null) {
@@ -35,7 +37,7 @@ public class ObjectInputStream
// a zero code indicates a null value // a zero code indicates a null value
if (code == 0) { if (code == 0) {
Log.debug(DEBUG_ID + "Read null"); log.debug(DEBUG_ID + "Read null");
return null; return null;
} }
@@ -49,21 +51,21 @@ public class ObjectInputStream
// read in the class metadata // read in the class metadata
var cname :String = Translations.getFromServer(readUTF()); var cname :String = Translations.getFromServer(readUTF());
// Log.debug("read cname: " + cname); // log.debug("read cname: " + cname);
var streamer :Streamer = Streamer.getStreamerByJavaName(cname); var streamer :Streamer = Streamer.getStreamerByJavaName(cname);
if (streamer == Streamer.BAD_STREAMER) { if (streamer == Streamer.BAD_STREAMER) {
Log.warning("OMG, cannot stream " + cname); log.warning("OMG, cannot stream " + cname);
return null; return null;
} }
// Log.debug("Got streamer (" + streamer + ")"); // log.debug("Got streamer (" + streamer + ")");
cmap = new ClassMapping(code, cname, streamer); cmap = new ClassMapping(code, cname, streamer);
_classMap[code] = cmap; _classMap[code] = cmap;
Log.debug(DEBUG_ID + log.debug(DEBUG_ID +
"Created mapping: (" + code + "): " + cname); "Created mapping: (" + code + "): " + cname);
} else { } else {
Log.debug(DEBUG_ID + "Read known code: (" + code + ")"); log.debug(DEBUG_ID + "Read known code: (" + code + ")");
cmap = (_classMap[code] as ClassMapping); cmap = (_classMap[code] as ClassMapping);
if (null == cmap) { if (null == cmap) {
throw new IOError("Read object for which we have no " + throw new IOError("Read object for which we have no " +
@@ -71,7 +73,7 @@ public class ObjectInputStream
} }
} }
// Log.debug("Creating object sleeve..."); // log.debug("Creating object sleeve...");
var target :Object; var target :Object;
if (cmap.streamer === null) { if (cmap.streamer === null) {
var clazz :Class = ClassUtil.getClassByName(cmap.classname); var clazz :Class = ClassUtil.getClassByName(cmap.classname);
@@ -80,9 +82,9 @@ public class ObjectInputStream
} else { } else {
target = cmap.streamer.createObject(this); target = cmap.streamer.createObject(this);
} }
//Log.debug("Reading object..."); //log.debug("Reading object...");
readBareObjectImpl(target, cmap.streamer); readBareObjectImpl(target, cmap.streamer);
Log.debug(DEBUG_ID + "Read object: " + target); log.debug(DEBUG_ID + "Read object: " + target);
return target; return target;
} catch (me :MemoryError) { } catch (me :MemoryError) {
@@ -8,6 +8,8 @@ import com.threerings.util.HashMap;
public class ObjectOutputStream public class ObjectOutputStream
{ {
private static const log :Log = Log.getLog(ObjectOutputStream);
public function ObjectOutputStream (targ :IDataOutput) public function ObjectOutputStream (targ :IDataOutput)
{ {
_targ = targ; _targ = targ;
@@ -38,7 +40,7 @@ public class ObjectOutputStream
// streamer may be null to indicate a Streamable object // streamer may be null to indicate a Streamable object
if (streamer == Streamer.BAD_STREAMER) { if (streamer == Streamer.BAD_STREAMER) {
// TODO // TODO
Log.warning("OMG, cannot stream " + cname); log.warning("OMG, cannot stream " + cname);
return; return;
} }
-2
View File
@@ -1,7 +1,5 @@
package com.threerings.io { package com.threerings.io {
import com.threerings.presents.Log;
public dynamic class TypedArray extends Array public dynamic class TypedArray extends Array
{ {
public function TypedArray (jtype :String) public function TypedArray (jtype :String)
@@ -7,8 +7,6 @@ import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamer; import com.threerings.io.Streamer;
import com.threerings.io.TypedArray; import com.threerings.io.TypedArray;
import com.threerings.presents.Log;
/** /**
* A Streamer for Array objects. * A Streamer for Array objects.
*/ */
@@ -35,7 +33,7 @@ public class ArrayStreamer extends Streamer
_elementType = int; _elementType = int;
} else { } else {
com.threerings.presents.Log.warning("Other array types are " + Log.getLog(this).warning("Other array types are " +
"currently not handled yet [jname=" + jname + "]."); "currently not handled yet [jname=" + jname + "].");
throw new Error("Unimplemented bit"); throw new Error("Unimplemented bit");
} }
-36
View File
@@ -1,36 +0,0 @@
package com.threerings.presents {
import mx.logging.ILogger;
import com.threerings.util.LogDaddy;
public class Log extends LogDaddy
{
/** The Logger for this package. */
public static var log :ILogger = getLogger("presents");
/** Convenience function. */
public static function debug (message :String, ... rest) :void
{
log.debug(message, rest);
}
/** Convenience function. */
public static function info (message :String, ... rest) :void
{
log.info(message, rest);
}
/** Convenience function. */
public static function warning (message :String, ... rest) :void
{
log.warn(message, rest);
}
/** Convenience function. */
public static function logStackTrace (err :Error) :void
{
log.warn(err.getStackTrace());
}
}
}
@@ -19,13 +19,13 @@ import com.threerings.presents.net.Credentials;
import com.threerings.presents.net.PingRequest; import com.threerings.presents.net.PingRequest;
import com.threerings.presents.net.PongResponse; import com.threerings.presents.net.PongResponse;
import com.threerings.presents.Log;
public class Client extends EventDispatcher public class Client extends EventDispatcher
{ {
/** The default port on which the server listens for client connections. */ /** The default port on which the server listens for client connections. */
public static const DEFAULT_SERVER_PORT :int = 47624; public static const DEFAULT_SERVER_PORT :int = 47624;
private static const log :Log = Log.getLog(Client);
public function Client (creds :Credentials, stage :Stage) public function Client (creds :Credentials, stage :Stage)
{ {
_creds = creds; _creds = creds;
@@ -228,7 +228,7 @@ public class Client extends EventDispatcher
public function logoff (abortable :Boolean) :Boolean public function logoff (abortable :Boolean) :Boolean
{ {
if (_comm == null) { if (_comm == null) {
Log.warning("Ignoring request to log off: not logged on."); log.warning("Ignoring request to log off: not logged on.");
return true; return true;
} }
@@ -249,7 +249,7 @@ public class Client extends EventDispatcher
public function gotBootstrap (data :BootstrapData, omgr :DObjectManager) public function gotBootstrap (data :BootstrapData, omgr :DObjectManager)
:void :void
{ {
Log.debug("Got bootstrap " + data + "."); log.debug("Got bootstrap " + data + ".");
_bstrap = data; _bstrap = data;
_omgr = omgr; _omgr = omgr;
@@ -257,7 +257,7 @@ public class Client extends EventDispatcher
_invdir.init(omgr, _cloid, this); _invdir.init(omgr, _cloid, this);
Log.debug("TimeBaseService: " + requireService(TimeBaseService)); log.debug("TimeBaseService: " + requireService(TimeBaseService));
} }
/** /**
@@ -47,8 +47,6 @@ import com.threerings.presents.net.SubscribeRequest;
import com.threerings.presents.net.UnsubscribeRequest; import com.threerings.presents.net.UnsubscribeRequest;
import com.threerings.presents.net.UnsubscribeResponse; import com.threerings.presents.net.UnsubscribeResponse;
import com.threerings.presents.Log;
/** /**
* The client distributed object manager manages a set of proxy objects * The client distributed object manager manages a set of proxy objects
* which mirror the distributed objects maintained on the server. * which mirror the distributed objects maintained on the server.
@@ -59,6 +57,8 @@ import com.threerings.presents.Log;
public class ClientDObjectMgr public class ClientDObjectMgr
implements DObjectManager implements DObjectManager
{ {
private static const log :Log = Log.getLog(ClientDObjectMgr);
/** /**
* Constructs a client distributed object manager. * Constructs a client distributed object manager.
* *
@@ -149,7 +149,7 @@ public class ClientDObjectMgr
long expire = System.currentTimeMillis() + long expire = System.currentTimeMillis() +
((Long)_delays.get(dclass)).longValue(); ((Long)_delays.get(dclass)).longValue();
_flushes.put(obj.getOid(), new FlushRecord(obj, expire)); _flushes.put(obj.getOid(), new FlushRecord(obj, expire));
// Log.info("Flushing " + obj.getOid() + " at " + // log.info("Flushing " + obj.getOid() + " at " +
// new java.util.Date(expire)); // new java.util.Date(expire));
return; return;
} }
@@ -194,14 +194,13 @@ public class ClientDObjectMgr
} }
var obj :Object = _actions.shift(); var obj :Object = _actions.shift();
Log.debug("processNextAction: " + obj);
// do the proper thing depending on the object // do the proper thing depending on the object
if (obj is BootstrapNotification) { if (obj is BootstrapNotification) {
_client.gotBootstrap(obj.getData(), this); _client.gotBootstrap(obj.getData(), this);
} else if (obj is EventNotification) { } else if (obj is EventNotification) {
var evt :DEvent = obj.getEvent(); var evt :DEvent = obj.getEvent();
// Log.info("Dispatch event: " + evt); // log.info("Dispatch event: " + evt);
dispatchEvent(evt); dispatchEvent(evt);
} else if (obj is ObjectResponse) { } else if (obj is ObjectResponse) {
@@ -210,7 +209,7 @@ public class ClientDObjectMgr
} else if (obj is UnsubscribeResponse) { } else if (obj is UnsubscribeResponse) {
var oid :int = obj.getOid(); var oid :int = obj.getOid();
if (_dead.remove(oid) == null) { if (_dead.remove(oid) == null) {
Log.warning("Received unsub ACK from unknown object " + log.warning("Received unsub ACK from unknown object " +
"[oid=" + oid + "]."); "[oid=" + oid + "].");
} }
@@ -253,7 +252,7 @@ public class ClientDObjectMgr
var target :DObject = (_ocache.get(toid) as DObject); var target :DObject = (_ocache.get(toid) as DObject);
if (target == null) { if (target == null) {
if (_dead.get(toid) == null) { if (_dead.get(toid) == null) {
Log.warning("Unable to dispatch event on non-proxied " + log.warning("Unable to dispatch event on non-proxied " +
"object [event=" + event + "]."); "object [event=" + event + "].");
} }
return; return;
@@ -266,7 +265,7 @@ public class ClientDObjectMgr
// if this is an object destroyed event, we need to remove the // if this is an object destroyed event, we need to remove the
// object from our object table // object from our object table
if (event is ObjectDestroyedEvent) { if (event is ObjectDestroyedEvent) {
// Log.info("Pitching destroyed object " + // log.info("Pitching destroyed object " +
// "[oid=" + toid + ", class=" + // "[oid=" + toid + ", class=" +
// StringUtil.shortClassName(target) + "]."); // StringUtil.shortClassName(target) + "].");
_ocache.remove(toid); _ocache.remove(toid);
@@ -278,9 +277,9 @@ public class ClientDObjectMgr
} }
} catch (e :Error) { } catch (e :Error) {
Log.warning("Failure processing event [event=" + event + log.warning("Failure processing event [event=" + event +
", target=" + target + "]."); ", target=" + target + "].");
Log.logStackTrace(e); log.logStackTrace(e);
} }
} }
@@ -300,15 +299,15 @@ public class ClientDObjectMgr
// let the penders know that the object is available // let the penders know that the object is available
var req :PendingRequest = (_penders.remove(oid) as PendingRequest); var req :PendingRequest = (_penders.remove(oid) as PendingRequest);
if (req == null) { if (req == null) {
Log.warning("Got object, but no one cares?! " + log.warning("Got object, but no one cares?! " +
"[oid=" + oid + ", obj=" + obj + "]."); "[oid=" + oid + ", obj=" + obj + "].");
return; return;
} }
Log.debug("Got object: pendReq=" + req); log.debug("Got object: pendReq=" + req);
for (var ii :int = 0; ii < req.targets.length; ii++) { for (var ii :int = 0; ii < req.targets.length; ii++) {
var target :Subscriber = (req.targets[ii] as Subscriber); var target :Subscriber = (req.targets[ii] as Subscriber);
Log.debug("Notifying subscriber: " + target); log.debug("Notifying subscriber: " + target);
// add them as a subscriber // add them as a subscriber
obj.addSubscriber(target); obj.addSubscriber(target);
// and let them know that the object is in // and let them know that the object is in
@@ -325,7 +324,7 @@ public class ClientDObjectMgr
// let the penders know that the object is not available // let the penders know that the object is not available
var req :PendingRequest = (_penders.remove(oid) as PendingRequest); var req :PendingRequest = (_penders.remove(oid) as PendingRequest);
if (req == null) { if (req == null) {
Log.warning("Failed to get object, but no one cares?! " + log.warning("Failed to get object, but no one cares?! " +
"[oid=" + oid + "]."); "[oid=" + oid + "].");
return; return;
} }
@@ -343,7 +342,7 @@ public class ClientDObjectMgr
*/ */
protected function doSubscribe (oid :int, target :Subscriber) :void protected function doSubscribe (oid :int, target :Subscriber) :void
{ {
// Log.info("doSubscribe: " + oid + ": " + target); // log.info("doSubscribe: " + oid + ": " + target);
// first see if we've already got the object in our table // first see if we've already got the object in our table
var obj :DObject = (_ocache.get(oid) as DObject); var obj :DObject = (_ocache.get(oid) as DObject);
@@ -369,7 +368,7 @@ public class ClientDObjectMgr
req = new PendingRequest(oid); req = new PendingRequest(oid);
req.addTarget(target); req.addTarget(target);
_penders.put(oid, req); _penders.put(oid, req);
// Log.info("Registering pending request [oid=" + oid + "]."); // log.info("Registering pending request [oid=" + oid + "].");
// and issue a request to get things rolling // and issue a request to get things rolling
_comm.postMessage(new SubscribeRequest(oid)); _comm.postMessage(new SubscribeRequest(oid));
@@ -386,7 +385,7 @@ public class ClientDObjectMgr
dobj.removeSubscriber(target); dobj.removeSubscriber(target);
} else { } else {
Log.info("Requested to remove subscriber from " + log.info("Requested to remove subscriber from " +
"non-proxied object [oid=" + oid + "non-proxied object [oid=" + oid +
", sub=" + target + "]."); ", sub=" + target + "].");
} }
@@ -16,8 +16,6 @@ import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream; import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Translations; import com.threerings.io.Translations;
import com.threerings.presents.Log;
import com.threerings.presents.net.AuthRequest; import com.threerings.presents.net.AuthRequest;
import com.threerings.presents.net.AuthResponse; import com.threerings.presents.net.AuthResponse;
import com.threerings.presents.net.AuthResponseData; import com.threerings.presents.net.AuthResponseData;
@@ -76,7 +74,8 @@ public class Communicator
try { try {
_socket.close(); _socket.close();
} catch (err :Error) { } catch (err :Error) {
Log.warning("Error closing failed socket [error=" + err + "]."); Log.getLog(this).warning(
"Error closing failed socket [error=" + err + "].");
} }
_socket = null; _socket = null;
_outStream = null; _outStream = null;
@@ -140,7 +139,8 @@ public class Communicator
var msg :DownstreamMessage = var msg :DownstreamMessage =
(_inStream.readObject() as DownstreamMessage); (_inStream.readObject() as DownstreamMessage);
if (frameData.bytesAvailable > 0) { if (frameData.bytesAvailable > 0) {
Log.warning("Beans! We didn't fully read a frame, surely there's " + Log.getLog(this).warning(
"Beans! We didn't fully read a frame, surely there's " +
"a bug in some streaming code. " + "a bug in some streaming code. " +
"[bytesLeftOver=" + frameData.bytesAvailable + "]."); "[bytesLeftOver=" + frameData.bytesAvailable + "].");
} }
@@ -180,7 +180,7 @@ public class Communicator
*/ */
protected function socketError (event :IOErrorEvent) :void protected function socketError (event :IOErrorEvent) :void
{ {
Log.warning("socket error: " + event); Log.getLog(this).warning("socket error: " + event);
shutdown(new Error("socket closed unexpectedly.")); shutdown(new Error("socket closed unexpectedly."));
} }
@@ -21,8 +21,6 @@
package com.threerings.presents.client { package com.threerings.presents.client {
import com.threerings.presents.Log;
/** /**
* Provides the basic functionality used to dispatch invocation * Provides the basic functionality used to dispatch invocation
* notification events. * notification events.
@@ -47,9 +45,9 @@ public /* abstract */ class InvocationDecoder
*/ */
public function dispatchNotification (methodId :int, args :Array) :void public function dispatchNotification (methodId :int, args :Array) :void
{ {
Log.warning("Requested to dispatch unknown method " + Log.getLog(this).warning("Requested to dispatch unknown method " +
"[receiver=" + receiver + ", methodId=" + methodId + "[receiver=" + receiver + ", methodId=" + methodId +
", args=" + args + "]."); ", args=" + args + "].");
} }
} }
} }
@@ -20,16 +20,16 @@ import com.threerings.presents.dobj.SubscriberAdapter;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
import com.threerings.presents.Log;
public class InvocationDirector public class InvocationDirector
implements EventListener implements EventListener
{ {
private static const log :Log = Log.getLog(InvocationDirector);
public function init (omgr :DObjectManager, cloid :int, client :Client) public function init (omgr :DObjectManager, cloid :int, client :Client)
:void :void
{ {
if (_clobj != null) { if (_clobj != null) {
Log.warning("Zoiks, client object around during invmgr init!"); log.warning("Zoiks, client object around during invmgr init!");
cleanup(); cleanup();
} }
@@ -84,11 +84,11 @@ public class InvocationDirector
var rreg :InvocationRegistration = var rreg :InvocationRegistration =
(_clobj.receivers.get(receiverCode) as InvocationRegistration); (_clobj.receivers.get(receiverCode) as InvocationRegistration);
if (rreg == null) { if (rreg == null) {
Log.warning("Receiver unregistered for which we have no " + log.warning("Receiver unregistered for which we have no " +
"id to code mapping [code=" + receiverCode + "]."); "id to code mapping [code=" + receiverCode + "].");
} else { } else {
var odecoder :Object = _receivers.remove(rreg.receiverId); var odecoder :Object = _receivers.remove(rreg.receiverId);
// Log.info("Cleared receiver " + // log.info("Cleared receiver " +
// StringUtil.shortClassName(odecoder) + // StringUtil.shortClassName(odecoder) +
// " " + rreg + "."); // " " + rreg + ".");
} }
@@ -188,7 +188,7 @@ public class InvocationDirector
var listener :ListenerMarshaller = var listener :ListenerMarshaller =
(_listeners.remove(reqId) as ListenerMarshaller); (_listeners.remove(reqId) as ListenerMarshaller);
if (listener == null) { if (listener == null) {
Log.warning("Received invocation response for which we have " + log.warning("Received invocation response for which we have " +
"no registered listener [reqId=" + reqId + "no registered listener [reqId=" + reqId +
", methId=" + methodId + ", methId=" + methodId +
", args=" + args + "]. " + ", args=" + args + "]. " +
@@ -198,7 +198,7 @@ public class InvocationDirector
return; return;
} }
// Log.info("Dispatching invocation response " + // log.info("Dispatching invocation response " +
// "[listener=" + listener + ", methId=" + methodId + // "[listener=" + listener + ", methId=" + methodId +
// ", args=" + StringUtil.toString(args) + "]."); // ", args=" + StringUtil.toString(args) + "].");
@@ -206,10 +206,10 @@ public class InvocationDirector
try { try {
listener.dispatchResponse(methodId, args); listener.dispatchResponse(methodId, args);
} catch (e :Error) { } catch (e :Error) {
Log.warning("Invocation response listener choked " + log.warning("Invocation response listener choked " +
"[listener=" + listener + ", methId=" + methodId + "[listener=" + listener + ", methId=" + methodId +
", args=" + args + "]."); ", args=" + args + "].");
Log.logStackTrace(e); log.logStackTrace(e);
} }
// flush expired listeners periodically // flush expired listeners periodically
@@ -230,25 +230,25 @@ public class InvocationDirector
var decoder :InvocationDecoder = var decoder :InvocationDecoder =
(_receivers.get(receiverId) as InvocationDecoder); (_receivers.get(receiverId) as InvocationDecoder);
if (decoder == null) { if (decoder == null) {
Log.warning("Received notification for which we have no " + log.warning("Received notification for which we have no " +
"registered receiver [recvId=" + receiverId + "registered receiver [recvId=" + receiverId +
", methodId=" + methodId + ", methodId=" + methodId +
", args=" + args + "]."); ", args=" + args + "].");
return; return;
} }
// Log.info("Dispatching invocation notification " + // log.info("Dispatching invocation notification " +
// "[receiver=" + decoder.receiver + ", methodId=" + methodId + // "[receiver=" + decoder.receiver + ", methodId=" + methodId +
// ", args=" + StringUtil.toString(args) + "]."); // ", args=" + StringUtil.toString(args) + "].");
try { try {
decoder.dispatchNotification(methodId, args); decoder.dispatchNotification(methodId, args);
} catch (e :Error) { } catch (e :Error) {
Log.warning("Invocation notification receiver choked " + log.warning("Invocation notification receiver choked " +
"[receiver=" + decoder.receiver + "[receiver=" + decoder.receiver +
", methId=" + methodId + ", methId=" + methodId +
", args=" + args + "]."); ", args=" + args + "].");
Log.logStackTrace(e); log.logStackTrace(e);
} }
} }
@@ -323,7 +323,7 @@ public class InvocationDirector
internal function gotClientObjectFailed ( internal function gotClientObjectFailed (
oid :int, cause :ObjectAccessError) :void oid :int, cause :ObjectAccessError) :void
{ {
Log.warning("Invocation director unable to subscribe to " + log.warning("Invocation director unable to subscribe to " +
"client object [cloid=" + oid + ", cause=" + cause + "]!"); "client object [cloid=" + oid + ", cause=" + cause + "]!");
_client.getClientObjectFailed(cause); _client.getClientObjectFailed(cause);
} }
@@ -5,7 +5,6 @@ import flash.utils.describeType;
import mx.collections.ArrayCollection; import mx.collections.ArrayCollection;
import com.threerings.util.Name; import com.threerings.util.Name;
import com.threerings.presents.Log;
import com.threerings.presents.data.TimeBaseMarshaller; import com.threerings.presents.data.TimeBaseMarshaller;
import com.threerings.presents.dobj.DSet; import com.threerings.presents.dobj.DSet;
import com.threerings.presents.dobj.QSet; import com.threerings.presents.dobj.QSet;
@@ -18,6 +17,8 @@ import com.threerings.presents.net.BootstrapData;
public class TestClient extends Client public class TestClient extends Client
{ {
private static const log :Log = Log.getLog(TestClient);
public function TestClient () public function TestClient ()
{ {
super(new UsernamePasswordCreds(new Name("Ray"), "fork-u-2")); super(new UsernamePasswordCreds(new Name("Ray"), "fork-u-2"));
@@ -26,10 +27,10 @@ public class TestClient extends Client
var g1 :String = null; var g1 :String = null;
var g2 :String = (com.threerings.util.Util.cast(g1, String) as String); var g2 :String = (com.threerings.util.Util.cast(g1, String) as String);
Log.debug("foo: " + (g1 === g2) + ", *" + g2 + "*, "); // + g2.length); log.debug("foo: " + (g1 === g2) + ", *" + g2 + "*, "); // + g2.length);
var ob :Object = "this is a string"; var ob :Object = "this is a string";
Log.debug("part of an object: " + ob.substring(1)); log.debug("part of an object: " + ob.substring(1));
var arr :Array = new Array(); var arr :Array = new Array();
arr[0] = "Florp"; arr[0] = "Florp";
@@ -37,17 +38,17 @@ public class TestClient extends Client
arr[2] = "Swissbrat"; arr[2] = "Swissbrat";
for (var key:* in arr) { for (var key:* in arr) {
Log.debug("a key=" + key + " -> " + arr[key]); log.debug("a key=" + key + " -> " + arr[key]);
} }
delete arr[1]; delete arr[1];
arr["1"] = "oinkenheimer"; arr["1"] = "oinkenheimer";
for (var key:* in arr) { for (var key:* in arr) {
Log.debug("a key=" + key + " -> " + arr[key]); log.debug("a key=" + key + " -> " + arr[key]);
} }
Log.debug("length: " + arr.length); log.debug("length: " + arr.length);
Log.debug("arr[0]: " + arr[0]); log.debug("arr[0]: " + arr[0]);
Log.debug("arr[1]: " + arr[1]); log.debug("arr[1]: " + arr[1]);
Log.debug("arr[2]: " + arr[2]); log.debug("arr[2]: " + arr[2]);
//testFunc(2); //testFunc(2);
var bob :Person = new Person("Bob"); var bob :Person = new Person("Bob");
@@ -55,25 +56,25 @@ public class TestClient extends Client
var bob2 :Person = new Person("Bob"); var bob2 :Person = new Person("Bob");
bob.callPrintName(jim.printName); bob.callPrintName(jim.printName);
Log.debug("bob == jim: " + (bob == jim)); log.debug("bob == jim: " + (bob == jim));
Log.debug("bob === jim: " + (bob === jim)); log.debug("bob === jim: " + (bob === jim));
Log.debug("bob == bob2: " + (bob == bob2)); log.debug("bob == bob2: " + (bob == bob2));
Log.debug("bob === bob2: " + (bob === bob2)); log.debug("bob === bob2: " + (bob === bob2));
Log.debug("bob == bob: " + (bob == bob)); log.debug("bob == bob: " + (bob == bob));
Log.debug("bob === bob: " + (bob === bob)); log.debug("bob === bob: " + (bob === bob));
var list :ArrayCollection = new ArrayCollection(); var list :ArrayCollection = new ArrayCollection();
list.addItem(bob); list.addItem(bob);
Log.debug("jim's indeX: " + list.getItemIndex(jim)); log.debug("jim's indeX: " + list.getItemIndex(jim));
Log.debug("bob2's indeX: " + list.getItemIndex(bob2)); log.debug("bob2's indeX: " + list.getItemIndex(bob2));
Log.debug("function: " + describeType(testFunc).toXMLString()); log.debug("function: " + describeType(testFunc).toXMLString());
Log.debug("func length: " + testFunc.length); log.debug("func length: " + testFunc.length);
Log.debug("funcToString: " + testFunc); log.debug("funcToString: " + testFunc);
Log.debug("interfaces: " + describeType(Bint)); log.debug("interfaces: " + describeType(Bint));
var funcy :Function = function (i :int) :void { var funcy :Function = function (i :int) :void {
Log.debug("i is " + i); log.debug("i is " + i);
Log.debug("first list item is " + list[0]); log.debug("first list item is " + list[0]);
} }
_savedFunc = funcy; _savedFunc = funcy;
@@ -84,8 +85,8 @@ public class TestClient extends Client
var a :Object = new OldClass(); var a :Object = new OldClass();
var c :Class = OldClass; var c :Class = OldClass;
Log.debug("instance: " + describeType(a).toXMLString()); log.debug("instance: " + describeType(a).toXMLString());
Log.debug("class : " + describeType(Pork).toXMLString()); log.debug("class : " + describeType(Pork).toXMLString());
*/ */
/* /*
@@ -93,18 +94,18 @@ public class TestClient extends Client
var c :Object = 2.4; var c :Object = 2.4;
var d :Object = new HooperClass(this); var d :Object = new HooperClass(this);
Log.debug("1) " + (a as HelperClass)); log.debug("1) " + (a as HelperClass));
Log.debug("2) " + (b as HelperClass)); log.debug("2) " + (b as HelperClass));
Log.debug("3) " + HelperClass(a)); log.debug("3) " + HelperClass(a));
//Log.debug("4) " + HelperClass(b)); //log.debug("4) " + HelperClass(b));
Log.debug("5) " + (c as int)); log.debug("5) " + (c as int));
Log.debug("6) " + int(c)); log.debug("6) " + int(c));
//Log.debug("7) " + (d === a)); //log.debug("7) " + (d === a));
Log.debug("8) " + (a as HooperClass)); log.debug("8) " + (a as HooperClass));
Log.debug("9) " + HelperClass(d)); log.debug("9) " + HelperClass(d));
//Log.debug("X) " + HooperClass(a)); //log.debug("X) " + HooperClass(a));
var x :HelperClass = HelperClass(d); var x :HelperClass = HelperClass(d);
var y :HelperClass = (d as HelperClass); var y :HelperClass = (d as HelperClass);
@@ -113,11 +114,11 @@ public class TestClient extends Client
x.hype(); x.hype();
y.hype(); y.hype();
z.hype(); z.hype();
Log.debug("x === d: " + (x === d)); log.debug("x === d: " + (x === d));
Log.debug("y === d: " + (y === d)); log.debug("y === d: " + (y === d));
Log.debug("x === y: " + (x === y)); log.debug("x === y: " + (x === y));
Log.debug("d === z: " + (d === z)); log.debug("d === z: " + (d === z));
Log.debug("y === z: " + (y === z)); log.debug("y === z: " + (y === z));
*/ */
//var ta :TypedArray = new TypedArray(HooperClass); //var ta :TypedArray = new TypedArray(HooperClass);
@@ -142,13 +143,13 @@ public class TestClient extends Client
public function testFunc (one :int, two :int = 0, three :int = -1) :void public function testFunc (one :int, two :int = 0, three :int = -1) :void
{ {
Log.debug("this: " + ", args: " + arguments.length + log.debug("this: " + ", args: " + arguments.length +
": " + arguments); ": " + arguments);
} }
public function crazyArgs (num :int = 0, str :String = "lol") :void public function crazyArgs (num :int = 0, str :String = "lol") :void
{ {
Log.debug("crazyArgs " + num + ", " + str); log.debug("crazyArgs " + num + ", " + str);
} }
prototype var _foo :String; prototype var _foo :String;
@@ -158,7 +159,6 @@ public class TestClient extends Client
} }
} }
import com.threerings.presents.Log;
import com.threerings.presents.client.TestClient; import com.threerings.presents.client.TestClient;
interface Aint { interface Aint {
@@ -178,7 +178,8 @@ class Person
public function printName () :void public function printName () :void
{ {
Log.debug("printName called on " + _name + "! (this=" + this + ")"); Log.getLog(this).debug(
"printName called on " + _name + "! (this=" + this + ")");
} }
public function callPrintName (funcy :Function) :void public function callPrintName (funcy :Function) :void
@@ -211,7 +212,7 @@ class HelperClass
public function hype () :void public function hype () :void
{ {
Log.debug("helper hype"); Log.getLog(this).debug("helper hype");
} }
protected var _cli :TestClient; protected var _cli :TestClient;
@@ -232,7 +233,7 @@ final class HooperClass extends HelperClass
public override function hype () :void public override function hype () :void
{ {
Log.debug("hooper hype"); Log.getLog(this).debug("hooper hype");
} }
public function porker () :void public function porker () :void
@@ -27,8 +27,6 @@ import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream; import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable; import com.threerings.io.Streamable;
import com.threerings.presents.Log;
import com.threerings.presents.client.Client; import com.threerings.presents.client.Client;
import com.threerings.presents.client.ConfirmListener; import com.threerings.presents.client.ConfirmListener;
import com.threerings.presents.client.ResultListener; import com.threerings.presents.client.ResultListener;
@@ -11,8 +11,6 @@ import com.threerings.presents.client.InvocationListener;
import com.threerings.presents.dobj.DObjectManager; import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.dobj.InvocationResponseEvent; import com.threerings.presents.dobj.InvocationResponseEvent;
import com.threerings.presents.Log;
public class ListenerMarshaller public class ListenerMarshaller
implements Streamable, InvocationListener implements Streamable, InvocationListener
{ {
@@ -55,10 +53,10 @@ public class ListenerMarshaller
listener.requestFailed((args[0] as String)); listener.requestFailed((args[0] as String));
} else { } else {
Log.warning("Requested to dispatch unknown invocation " + Log.getLog(this).warning(
"response [listener=" + listener + "Requested to dispatch unknown invocation response " +
", methodId=" + methodId + "[listener=" + listener + ", methodId=" + methodId +
", args=" + args + "]."); ", args=" + args + "].");
} }
} }
@@ -7,16 +7,12 @@ import com.threerings.io.Streamable;
import com.threerings.util.Comparable; import com.threerings.util.Comparable;
import com.threerings.util.StringBuilder; import com.threerings.util.StringBuilder;
import com.threerings.presents.Log;
public /* abstract */ class DEvent public /* abstract */ class DEvent
implements Streamable implements Streamable
{ {
public function DEvent (targetOid :int) public function DEvent (targetOid :int)
{ {
_toid = targetOid; _toid = targetOid;
//Log.debug("unset old = " + UNSET_OLD_ENTRY);
} }
/** /**
@@ -37,7 +33,8 @@ public /* abstract */ class DEvent
public function applyToObject (target :DObject) :Boolean public function applyToObject (target :DObject) :Boolean
{ {
// TODO // TODO
Log.warning("DEvent.applyToTarget is really an abstract method."); Log.getLog(this).warning(
"DEvent.applyToTarget is really an abstract method.");
return false; return false;
} }
@@ -11,11 +11,11 @@ import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream; import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable; import com.threerings.io.Streamable;
import com.threerings.presents.Log;
public class DObject // extends EventDispatcher public class DObject // extends EventDispatcher
implements Streamable implements Streamable
{ {
private static const log :Log = Log.getLog(DObject);
public function getOid ():int public function getOid ():int
{ {
return _oid; return _oid;
@@ -61,9 +61,9 @@ public class DObject // extends EventDispatcher
_listeners = new ArrayCollection(); _listeners = new ArrayCollection();
} else if (_listeners.contains(listener)) { } else if (_listeners.contains(listener)) {
com.threerings.presents.Log.warning("Refusing repeat listener registration " + log.warning("Refusing repeat listener registration " +
"[dobj=" + which() + ", list=" + listener + "]."); "[dobj=" + which() + ", list=" + listener + "].");
com.threerings.presents.Log.logStackTrace(new Error()); log.logStackTrace(new Error());
return; return;
} }
_listeners.addItem(listener); _listeners.addItem(listener);
@@ -94,9 +94,9 @@ public class DObject // extends EventDispatcher
(listener as EventListener).eventReceived(event); (listener as EventListener).eventReceived(event);
} }
} catch (e :Error) { } catch (e :Error) {
com.threerings.presents.Log.warning("Listener choked during notification " + log.warning("Listener choked during notification " +
"[list=" + listener + ", event=" + event + "]."); "[list=" + listener + ", event=" + event + "].");
com.threerings.presents.Log.logStackTrace(e); log.logStackTrace(e);
} }
} }
} }
@@ -114,7 +114,7 @@ public class DObject // extends EventDispatcher
_omgr.postEvent(event); _omgr.postEvent(event);
} else { } else {
com.threerings.presents.Log.warning("Unable to post event, object has no omgr " + log.warning("Unable to post event, object has no omgr " +
"[oid=" + getOid() + ", class=" + ClassUtil.getClassName(this) + "[oid=" + getOid() + ", class=" + ClassUtil.getClassName(this) +
", event=" + event + "]."); ", event=" + event + "].");
} }
+2 -4
View File
@@ -12,8 +12,6 @@ import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable; import com.threerings.io.Streamable;
import com.threerings.io.TypedArray; import com.threerings.io.TypedArray;
import com.threerings.presents.Log;
/** /**
* The distributed set class provides a means by which an unordered set of * The distributed set class provides a means by which an unordered set of
* objects can be maintained as a distributed object field. Entries can be * objects can be maintained as a distributed object field. Entries can be
@@ -122,8 +120,8 @@ public class DSet
} }
} else if (contains(elem)) { } else if (contains(elem)) {
com.threerings.presents.Log.warning("Refusing to add duplicate entry [set=" + this + Log.getLog(this).warning("Refusing to add duplicate entry " +
", entry=" + elem + "]."); "[set=" + this + ", entry=" + elem + "].");
return false; return false;
} }
@@ -5,8 +5,6 @@ import com.threerings.io.ObjectOutputStream;
import com.threerings.util.StringBuilder; import com.threerings.util.StringBuilder;
import com.threerings.presents.Log;
/** /**
* An entry added event is dispatched when an entry is added to a {@link * An entry added event is dispatched when an entry is added to a {@link
* DSet} attribute of a distributed entry. It can also be constructed to * DSet} attribute of a distributed entry. It can also be constructed to
@@ -49,7 +47,8 @@ public class EntryAddedEvent extends NamedEvent
{ {
var added :Boolean = target[_name].add(_entry); var added :Boolean = target[_name].add(_entry);
if (!added) { if (!added) {
Log.warning("Duplicate entry found [event=" + this + "]."); Log.getLog(this).warning(
"Duplicate entry found [event=" + this + "].");
} }
return true; return true;
} }
@@ -5,8 +5,6 @@ import com.threerings.io.ObjectOutputStream;
import com.threerings.util.StringBuilder; import com.threerings.util.StringBuilder;
import com.threerings.presents.Log;
/** /**
* An entry removed event is dispatched when an entry is removed from a * An entry removed event is dispatched when an entry is removed from a
* {@link DSet} attribute of a distributed object. It can also be * {@link DSet} attribute of a distributed object. It can also be
@@ -67,8 +65,8 @@ public class EntryRemovedEvent extends NamedEvent
_oldEntry = dset.removeKey(_key); _oldEntry = dset.removeKey(_key);
if (_oldEntry == null) { if (_oldEntry == null) {
// complain if there was actually nothing there // complain if there was actually nothing there
Log.warning("No matching entry to remove [key=" + _key + Log.getLog(this).warning("No matching entry to remove " +
", set=" + dset + "]."); "[key=" + _key + ", set=" + dset + "].");
return false; return false;
} }
} }
@@ -5,8 +5,6 @@ import com.threerings.io.ObjectOutputStream;
import com.threerings.util.StringBuilder; import com.threerings.util.StringBuilder;
import com.threerings.presents.Log;
/** /**
* An entry updated event is dispatched when an entry of a {@link DSet} is * An entry updated event is dispatched when an entry of a {@link DSet} is
* updated. It can also be constructed to request the update of an entry * updated. It can also be constructed to request the update of an entry
@@ -67,8 +65,8 @@ public class EntryUpdatedEvent extends NamedEvent
_oldEntry = dset.update(_entry); _oldEntry = dset.update(_entry);
if (_oldEntry == null) { if (_oldEntry == null) {
// complain if we didn't update anything // complain if we didn't update anything
Log.warning("No matching entry to update [entry=" + this + Log.getLog(this).warning("No matching entry to update " +
", set=" + dset + "]."); "[entry=" + this + ", set=" + dset + "].");
return false; return false;
} }
} }
@@ -8,8 +8,6 @@ import com.threerings.io.TypedArray;
import com.threerings.util.StringBuilder; import com.threerings.util.StringBuilder;
import com.threerings.presents.Log;
/** /**
* An oid list is used to store lists of object ids. The list will not * An oid list is used to store lists of object ids. The list will not
* allow duplicate ids. This class is not synchronized, with the * allow duplicate ids. This class is not synchronized, with the
@@ -102,7 +100,7 @@ public class OidList
// documentation inherited from interface Streamable // documentation inherited from interface Streamable
public function writeObject (out :ObjectOutputStream) :void public function writeObject (out :ObjectOutputStream) :void
{ {
Log.warning("TODO: Not implemented: " + this); Log.getLog(this).warning("TODO: Not implemented: " + this);
} }
// documentation inherited from interface Streamable // documentation inherited from interface Streamable
@@ -1,7 +1,5 @@
package com.threerings.presents.dobj { package com.threerings.presents.dobj {
import com.threerings.presents.Log;
public class SubscriberAdapter public class SubscriberAdapter
implements Subscriber implements Subscriber
{ {
@@ -14,7 +12,6 @@ public class SubscriberAdapter
// documentation inherited from interface Subscriber // documentation inherited from interface Subscriber
public function objectAvailable (obj :DObject) :void public function objectAvailable (obj :DObject) :void
{ {
Log.debug("calling success function: " + _success);
_success(obj); _success(obj);
} }
@@ -6,8 +6,6 @@ import com.threerings.io.Streamable;
import com.threerings.util.StreamableArrayList; import com.threerings.util.StreamableArrayList;
import com.threerings.presents.Log;
/** /**
* A BoostrapData object is communicated back to the client * A BoostrapData object is communicated back to the client
* after authentication has succeeded and after the server is fully * after authentication has succeeded and after the server is fully
@@ -26,7 +24,8 @@ public class BootstrapData
// documentation inherited from interface Streamable // documentation inherited from interface Streamable
public function writeObject (out :ObjectOutputStream) :void public function writeObject (out :ObjectOutputStream) :void
{ {
com.threerings.presents.Log.warning("This is client code: BootstrapData shouldn't be written"); Log.getLog(this).warning(
"This is client code: BootstrapData shouldn't be written");
} }
// documentation inherited from interface Streamable // documentation inherited from interface Streamable
@@ -4,8 +4,6 @@ import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream; import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable; import com.threerings.io.Streamable;
import com.threerings.presents.Log;
public /* abstract */ class DownstreamMessage public /* abstract */ class DownstreamMessage
implements Streamable implements Streamable
{ {
@@ -17,8 +15,8 @@ public /* abstract */ class DownstreamMessage
// documentation inherited from interface Streamable // documentation inherited from interface Streamable
public function writeObject (out :ObjectOutputStream) :void public function writeObject (out :ObjectOutputStream) :void
{ {
Log.warning("This is client code: Downstream messages shouldn't " + Log.getLog(this).warning(
"be written"); "This is client code: Downstream messages shouldn't be written");
//out.writeShort(messageId); //out.writeShort(messageId);
} }
@@ -6,8 +6,6 @@ import com.threerings.io.ObjectOutputStream;
import com.threerings.util.JavaConstants; import com.threerings.util.JavaConstants;
import com.threerings.presents.Log;
public /* abstract */ class UpstreamMessage public /* abstract */ class UpstreamMessage
implements Streamable implements Streamable
{ {
@@ -35,7 +33,8 @@ public /* abstract */ class UpstreamMessage
// documentation inherited from interface Streamable // documentation inherited from interface Streamable
public function readObject (ins :ObjectInputStream) :void public function readObject (ins :ObjectInputStream) :void
{ {
Log.warning("This is client code: Upstream messages shouldn't be read"); Log.getLog(this).warning(
"This is client code: Upstream messages shouldn't be read");
//messageId = ins.readShort(); //messageId = ins.readShort();
} }
-34
View File
@@ -1,34 +0,0 @@
package com.threerings.util {
import mx.logging.ILogger;
public class Log extends LogDaddy
{
/** The Logger for this package. */
public static var log :ILogger = getLogger("util");
/** Convenience function. */
public static function debug (message :String, ... rest) :void
{
log.debug(message, rest);
}
/** Convenience function. */
public static function info (message :String, ... rest) :void
{
log.info(message, rest);
}
/** Convenience function. */
public static function warning (message :String, ... rest) :void
{
log.warn(message, rest);
}
/** Convenience function. */
public static function logStackTrace (err :Error) :void
{
log.warn(err.getStackTrace());
}
}
}
-40
View File
@@ -1,40 +0,0 @@
package com.threerings.util {
import mx.logging.ILogger;
import mx.logging.LogEventLevel;
import mx.logging.targets.TraceTarget;
/**
* Jesus Horseradish Christ. I wanted to just call this class Log, but
* other classes that don't even import it are getting confused between
* this and the subclasses with the same name. It's possible that this
* is some wacky compiler bug.
*/
public class LogDaddy
{
/**
* Retrieve the Logger for the specified package name, and ensure
* that our log target is set up.
*/
public static function getLogger (pkg :String) :ILogger
{
return mx.logging.Log.getLogger(pkg);
}
/**
* Our static (class) initializer.
*/
private static function staticInit () :void
{
var targ :TraceTarget = new TraceTarget();
targ.filters = ["*"];
targ.level = LogEventLevel.DEBUG;
mx.logging.Log.addTarget(targ);
// we could do some stuff here: set up different targets
// with different log levels...
}
staticInit(); // call our static initializer
}
}
+2 -2
View File
@@ -86,7 +86,7 @@ public class MessageBundle
} }
if (reportMissing) { if (reportMissing) {
Log.warning("Missing translation message " + Log.getLog(this).warning("Missing translation message " +
"[bundle=" + _path + ", key=" + key + "]."); "[bundle=" + _path + ", key=" + key + "].");
} }
@@ -146,7 +146,7 @@ public class MessageBundle
// if the base key is not found, look to see if we should try to // if the base key is not found, look to see if we should try to
// convert our first argument to an Integer and try again // convert our first argument to an Integer and try again
if (msg == null) { if (msg == null) {
Log.warning("Missing translation message " + Log.getLog(this).warning("Missing translation message " +
"[bundle=" + _path + ", key=" + key + "]."); "[bundle=" + _path + ", key=" + key + "].");
} }
+4 -4
View File
@@ -137,8 +137,8 @@ public class MessageManager
rbundle = ResourceBundle.getResourceBundle(fqpath); rbundle = ResourceBundle.getResourceBundle(fqpath);
// } // }
} catch (mre :Error) { } catch (mre :Error) {
Log.warning("Unable to resolve resource bundle " + Log.getLog(this).warning("Unable to resolve resource bundle " +
"[path=" + fqpath + "]."); "[path=" + fqpath + "].");
} }
// if the resource bundle contains a special resource, we'll // if the resource bundle contains a special resource, we'll
@@ -157,8 +157,8 @@ public class MessageManager
// nothing to worry about // nothing to worry about
} catch (t :Error) { } catch (t :Error) {
Log.warning("Failure instantiating custom message bundle " + Log.getLog(this).warning("Failure instantiating custom message" +
"[mbclass=" + mbclass + ", error=" + t + "]."); " bundle [mbclass=" + mbclass + ", error=" + t + "].");
} }
} }
+3 -1
View File
@@ -64,7 +64,9 @@ public class ObserverList
remove(list[ii]); remove(list[ii]);
} }
} catch (err :Error) { } catch (err :Error) {
Log.warning("ObserverOp choked during notification."); var log :Log = Log.getLog(this);
log.warning("ObserverOp choked during notification.");
log.logStackTrace(err);
} }
} }
} }