Sorry, Log, no more free ride for you.
Putting you at the top level screws up use of another Log class. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4874 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -23,6 +23,7 @@ package com.threerings.crowd.chat.client {
|
||||
|
||||
import com.threerings.util.ArrayUtil;
|
||||
import com.threerings.util.HashMap;
|
||||
import com.threerings.util.Log;
|
||||
import com.threerings.util.Map;
|
||||
import com.threerings.util.ObserverList;
|
||||
import com.threerings.util.ResultListener;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
package com.threerings.crowd.chat.client {
|
||||
|
||||
import com.threerings.util.Log;
|
||||
import com.threerings.util.Name;
|
||||
import com.threerings.util.StringUtil;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ package com.threerings.crowd.client {
|
||||
import flash.utils.getTimer; // function import
|
||||
|
||||
import com.threerings.util.ObserverList;
|
||||
import com.threerings.util.Log;
|
||||
import com.threerings.util.ResultListener;
|
||||
|
||||
import com.threerings.presents.client.BasicDirector;
|
||||
|
||||
@@ -26,6 +26,8 @@ import flash.display.DisplayObjectContainer;
|
||||
|
||||
import mx.core.IRawChildrenContainer; // a simple interface from flex
|
||||
|
||||
import com.threerings.util.Log;
|
||||
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,8 @@ import flash.net.Socket;
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.Endian;
|
||||
|
||||
import com.threerings.util.Log;
|
||||
|
||||
/**
|
||||
* Reads socket data until a complete frame is available.
|
||||
* This dispatches a FrameAvailableEvent.FRAME_AVAILABLE once a frame
|
||||
|
||||
@@ -28,6 +28,7 @@ import flash.utils.ByteArray;
|
||||
import flash.utils.IDataInput;
|
||||
|
||||
import com.threerings.util.ClassUtil;
|
||||
import com.threerings.util.Log;
|
||||
|
||||
public class ObjectInputStream
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@ import flash.utils.IDataOutput;
|
||||
|
||||
import com.threerings.util.ClassUtil;
|
||||
import com.threerings.util.HashMap;
|
||||
import com.threerings.util.Log;
|
||||
import com.threerings.util.Short;
|
||||
|
||||
public class ObjectOutputStream
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
package com.threerings.io.streamers {
|
||||
|
||||
import com.threerings.util.ClassUtil;
|
||||
import com.threerings.util.Log;
|
||||
|
||||
import com.threerings.io.ArrayMask;
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
|
||||
@@ -28,6 +28,7 @@ import flash.events.TimerEvent;
|
||||
|
||||
import flash.utils.Timer;
|
||||
|
||||
import com.threerings.util.Log;
|
||||
import com.threerings.util.MethodQueue;
|
||||
import com.threerings.util.ObserverList;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import flash.utils.getTimer; // function import
|
||||
|
||||
import com.threerings.util.ClassUtil;
|
||||
import com.threerings.util.HashMap;
|
||||
import com.threerings.util.Log;
|
||||
|
||||
import com.threerings.presents.dobj.CompoundEvent;
|
||||
import com.threerings.presents.dobj.DEvent;
|
||||
|
||||
@@ -31,6 +31,7 @@ import flash.net.Socket;
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.Endian;
|
||||
|
||||
import com.threerings.util.Log;
|
||||
import com.threerings.util.StringUtil;
|
||||
|
||||
import com.threerings.io.FrameAvailableEvent;
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
package com.threerings.presents.client {
|
||||
|
||||
import com.threerings.util.Log;
|
||||
|
||||
/**
|
||||
* Provides the basic functionality used to dispatch invocation
|
||||
* notification events.
|
||||
|
||||
@@ -25,6 +25,7 @@ import flash.errors.IllegalOperationError;
|
||||
import flash.utils.getTimer; // function import
|
||||
|
||||
import com.threerings.util.HashMap;
|
||||
import com.threerings.util.Log;
|
||||
import com.threerings.util.Wrapped;
|
||||
|
||||
import com.threerings.presents.data.InvocationMarshaller_ListenerMarshaller;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
package com.threerings.presents.client {
|
||||
|
||||
import com.threerings.util.Log;
|
||||
import com.threerings.util.StringUtil;
|
||||
|
||||
import com.threerings.presents.data.AuthCodes;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
package com.threerings.presents.data {
|
||||
|
||||
import com.threerings.util.ClassUtil;
|
||||
import com.threerings.util.Log;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
@@ -26,6 +26,7 @@ import flash.errors.IllegalOperationError;
|
||||
import flash.events.EventDispatcher;
|
||||
|
||||
import com.threerings.util.ClassUtil;
|
||||
import com.threerings.util.Log;
|
||||
import com.threerings.util.StringBuilder;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.threerings.util.ArrayIterator;
|
||||
import com.threerings.util.Cloneable;
|
||||
import com.threerings.util.Equalable;
|
||||
import com.threerings.util.Iterator;
|
||||
import com.threerings.util.Log;
|
||||
import com.threerings.util.StringBuilder;
|
||||
import com.threerings.util.Util;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ package com.threerings.presents.dobj {
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
import com.threerings.util.Log;
|
||||
import com.threerings.util.StringBuilder;
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,7 @@ package com.threerings.presents.dobj {
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
import com.threerings.util.Log;
|
||||
import com.threerings.util.StringBuilder;
|
||||
import com.threerings.util.Wrapped;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ package com.threerings.presents.dobj {
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
import com.threerings.util.Log;
|
||||
import com.threerings.util.StringBuilder;
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
import com.threerings.io.Streamable;
|
||||
|
||||
import com.threerings.util.Log;
|
||||
import com.threerings.util.StreamableArrayList;
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
package com.threerings.presents.util {
|
||||
|
||||
import com.threerings.util.Log;
|
||||
|
||||
import com.threerings.presents.dobj.DObject;
|
||||
import com.threerings.presents.dobj.DObjectManager;
|
||||
import com.threerings.presents.dobj.ObjectAccessError;
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// 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.util {
|
||||
|
||||
import flash.utils.getQualifiedClassName;
|
||||
|
||||
/**
|
||||
* A simple logging mechanism.
|
||||
*
|
||||
* 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(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* A convenience function for quickly and easily inserting printy
|
||||
* statements during application development.
|
||||
*/
|
||||
public static function testing (... params) :void
|
||||
{
|
||||
var log :Log = new Log("testing");
|
||||
log.debug.apply(log, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* A convenience function for quickly printing a stack trace
|
||||
* to the log, useful for debugging.
|
||||
*/
|
||||
public static function dumpStack () :void
|
||||
{
|
||||
testing(new Error("dumpStack").getStackTrace());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a logging target.
|
||||
*/
|
||||
public static function addTarget (target :LogTarget) :void
|
||||
{
|
||||
_targets.push(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a logging target.
|
||||
*/
|
||||
public static function removeTarget (target :LogTarget) :void
|
||||
{
|
||||
var dex :int = _targets.indexOf(target);
|
||||
if (dex != -1) {
|
||||
_targets.splice(dex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
public function Log (spec :String)
|
||||
{
|
||||
_spec = spec;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a message with 'debug' priority.
|
||||
*/
|
||||
public function debug (... messages) :void
|
||||
{
|
||||
doLog("[debug]", messages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a message with 'info' priority.
|
||||
*/
|
||||
public function info (... messages) :void
|
||||
{
|
||||
doLog("[INFO]", messages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a message with 'debug' priority.
|
||||
*/
|
||||
public function warning (... messages) :void
|
||||
{
|
||||
doLog("[WARNING]", messages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a message with 'debug' priority.
|
||||
*/
|
||||
public function logStackTrace (error :Error) :void
|
||||
{
|
||||
warning(error.getStackTrace());
|
||||
}
|
||||
|
||||
protected function doLog (level :String, messages :Array) :void
|
||||
{
|
||||
// TODO: better Date formatting?
|
||||
messages.unshift(new Date().toLocaleTimeString(), level, _spec);
|
||||
trace.apply(null, messages);
|
||||
|
||||
// possibly also dispatch to any other log targets.
|
||||
if (_targets.length > 0) {
|
||||
var asOne :String = messages.join(" ");
|
||||
for each (var target :LogTarget in _targets) {
|
||||
target.log(asOne);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Our log specification. */
|
||||
protected var _spec :String;
|
||||
|
||||
protected static var _targets :Array = [];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,9 +22,7 @@
|
||||
package com.threerings.util {
|
||||
|
||||
/**
|
||||
* A very simple Logging interface.
|
||||
* Used with the top-level class QUOTE in this package ENDQUOTE...
|
||||
* (it's actually up above 'com', so it never needs importing...)
|
||||
* A very simple Logging interface used by Log.
|
||||
*/
|
||||
public interface LogTarget
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user