More logging fixing, moved the compiled config stuff into Nenya.
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@4 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -27,6 +27,8 @@ import com.samskivert.util.ResultListener;
|
||||
import com.samskivert.util.RunAnywhere;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import static com.threerings.NenyaLog.log;
|
||||
|
||||
/**
|
||||
* Encapsulates a bunch of hackery needed to invoke an external web browser
|
||||
* from within a Java application.
|
||||
@@ -78,13 +80,13 @@ public class BrowserUtil
|
||||
cmd = new String[] { genagent, url.toString() };
|
||||
}
|
||||
|
||||
Log.info("Browsing URL [cmd=" + StringUtil.join(cmd, " ") + "].");
|
||||
log.info("Browsing URL [cmd=" + StringUtil.join(cmd, " ") + "].");
|
||||
try {
|
||||
Process process = Runtime.getRuntime().exec(cmd);
|
||||
BrowserTracker tracker = new BrowserTracker(process, url, listener);
|
||||
tracker.start();
|
||||
} catch (Exception e) {
|
||||
Log.warning("Failed to launch browser [url=" + url +
|
||||
log.warning("Failed to launch browser [url=" + url +
|
||||
", error=" + e + "].");
|
||||
listener.requestFailed(e);
|
||||
}
|
||||
@@ -109,7 +111,7 @@ public class BrowserUtil
|
||||
}
|
||||
|
||||
String errmsg = "Launched browser failed [rv=" + rv + "].";
|
||||
Log.warning(errmsg);
|
||||
log.warning(errmsg);
|
||||
if (!RunAnywhere.isWindows()) {
|
||||
_listener.requestFailed(new Exception(errmsg));
|
||||
return;
|
||||
@@ -124,12 +126,11 @@ public class BrowserUtil
|
||||
rv = process.exitValue();
|
||||
if (rv != 0) {
|
||||
errmsg = "Failed to launch iexplore.exe [rv=" + rv + "].";
|
||||
Log.warning(errmsg);
|
||||
log.warning(errmsg);
|
||||
_listener.requestFailed(new Exception(errmsg));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.logStackTrace(e);
|
||||
_listener.requestFailed(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// $Id: CompiledConfig.java 3788 2005-12-20 02:09:18Z ray $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 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 java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Used to load and store compiled configuration data (generally XML files
|
||||
* that are parsed into Java object models and then serialized for rapid
|
||||
* and simple access on the client and server).
|
||||
*/
|
||||
public class CompiledConfig
|
||||
{
|
||||
/**
|
||||
* Unserializes a configuration object from the supplied input stream.
|
||||
*/
|
||||
public static Serializable loadConfig (InputStream source)
|
||||
throws IOException
|
||||
{
|
||||
try {
|
||||
ObjectInputStream oin = new ObjectInputStream(source);
|
||||
return (Serializable)oin.readObject();
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
String errmsg = "Unknown config class";
|
||||
throw (IOException) new IOException(errmsg).initCause(cnfe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the supplied configuration object to the specified file
|
||||
* path.
|
||||
*/
|
||||
public static void saveConfig (File target, Serializable config)
|
||||
throws IOException
|
||||
{
|
||||
FileOutputStream fout = new FileOutputStream(target);
|
||||
ObjectOutputStream oout = new ObjectOutputStream(fout);
|
||||
oout.writeObject(config);
|
||||
oout.close();
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,8 @@ import java.awt.event.AWTEventListener;
|
||||
import com.samskivert.util.Interval;
|
||||
import com.samskivert.util.RunQueue;
|
||||
|
||||
import static com.threerings.NenyaLog.log;
|
||||
|
||||
/**
|
||||
* Used to track user idleness in an AWT application.
|
||||
*/
|
||||
@@ -137,7 +139,7 @@ public abstract class IdleTracker
|
||||
case ACTIVE:
|
||||
// check whether they've idled out
|
||||
if (now >= (_lastEvent + _toIdleTime)) {
|
||||
Log.info("User idle for " + (now-_lastEvent) + "ms.");
|
||||
log.info("User idle for " + (now-_lastEvent) + "ms.");
|
||||
_state = IDLE;
|
||||
idledOut();
|
||||
}
|
||||
@@ -146,7 +148,7 @@ public abstract class IdleTracker
|
||||
case IDLE:
|
||||
// check whether they've been idle for too long
|
||||
if (now >= (_lastEvent + _toIdleTime + _toAbandonTime)) {
|
||||
Log.info("User idle for " + (now-_lastEvent) + "ms. " +
|
||||
log.info("User idle for " + (now-_lastEvent) + "ms. " +
|
||||
"Abandoning ship.");
|
||||
_state = ABANDONED;
|
||||
abandonedShip();
|
||||
|
||||
@@ -44,6 +44,8 @@ import com.samskivert.util.RunAnywhere;
|
||||
|
||||
import com.threerings.util.keybd.Keyboard;
|
||||
|
||||
import static com.threerings.NenyaLog.log;
|
||||
|
||||
/**
|
||||
* The keyboard manager observes keyboard actions on a particular
|
||||
* component and posts commands associated with the key presses to the
|
||||
@@ -139,7 +141,7 @@ public class KeyboardManager
|
||||
{
|
||||
// report incorrect usage
|
||||
if (enabled && _target == null) {
|
||||
Log.warning("Attempt to enable uninitialized keyboard manager!");
|
||||
log.warning("Attempt to enable uninitialized keyboard manager!");
|
||||
Thread.dumpStack();
|
||||
return;
|
||||
}
|
||||
@@ -262,7 +264,7 @@ public class KeyboardManager
|
||||
// bail if we're not enabled, we haven't the focus, or we're not
|
||||
// showing on-screen
|
||||
if (!_enabled || !_focus || !_target.isShowing()) {
|
||||
// Log.info("dispatchKeyEvent [enabled=" + _enabled +
|
||||
// log.info("dispatchKeyEvent [enabled=" + _enabled +
|
||||
// ", focus=" + _focus +
|
||||
// ", showing=" + ((_target == null) ? "N/A" :
|
||||
// "" + _target.isShowing()) + "].");
|
||||
@@ -360,7 +362,7 @@ public class KeyboardManager
|
||||
{
|
||||
if (DEBUG_EVENTS) {
|
||||
int keyCode = e.getKeyCode();
|
||||
Log.info(msg + " [key=" + KeyEvent.getKeyText(keyCode) + "].");
|
||||
log.info(msg + " [key=" + KeyEvent.getKeyText(keyCode) + "].");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,7 +444,7 @@ public class KeyboardManager
|
||||
_scheduled = true;
|
||||
|
||||
if (DEBUG_EVENTS) {
|
||||
Log.info("Pressing key [key=" + _keyText + "].");
|
||||
log.info("Pressing key [key=" + _keyText + "].");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,7 +480,7 @@ public class KeyboardManager
|
||||
// infrequently.
|
||||
if (_lastPress == _lastRelease) {
|
||||
if (DEBUG_EVENTS) {
|
||||
Log.warning("Insta-releasing key due to equal key " +
|
||||
log.warning("Insta-releasing key due to equal key " +
|
||||
"press/release times [key=" + _keyText + "].");
|
||||
}
|
||||
release(time);
|
||||
@@ -497,7 +499,7 @@ public class KeyboardManager
|
||||
}
|
||||
|
||||
if (DEBUG_EVENTS) {
|
||||
Log.info("Releasing key [key=" + _keyText + "].");
|
||||
log.info("Releasing key [key=" + _keyText + "].");
|
||||
}
|
||||
|
||||
// remove the repeat interval
|
||||
@@ -523,7 +525,7 @@ public class KeyboardManager
|
||||
long deltaRelease = now - _lastRelease;
|
||||
|
||||
if (KeyboardManager.DEBUG_INTERVAL) {
|
||||
Log.info("Interval [key=" + _keyText +
|
||||
log.info("Interval [key=" + _keyText +
|
||||
", deltaPress=" + deltaPress +
|
||||
", deltaRelease=" + deltaRelease + "].");
|
||||
}
|
||||
@@ -541,7 +543,7 @@ public class KeyboardManager
|
||||
// _siid = IntervalManager.register(
|
||||
// this, delay, Long.valueOf(_lastPress), false);
|
||||
// if (KeyboardManager.DEBUG_INTERVAL) {
|
||||
// Log.info("Registered sub-interval " +
|
||||
// log.info("Registered sub-interval " +
|
||||
// "[id=" + _siid + "].");
|
||||
// }
|
||||
|
||||
@@ -572,7 +574,7 @@ public class KeyboardManager
|
||||
// sub-interval was registered
|
||||
if (_lastPress != ((Long)arg).longValue()) {
|
||||
if (KeyboardManager.DEBUG_INTERVAL) {
|
||||
Log.warning("Key pressed since sub-interval was " +
|
||||
log.warning("Key pressed since sub-interval was " +
|
||||
"registered, aborting release check " +
|
||||
"[key=" + _keyText + "].");
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
//
|
||||
// $Id: Log.java 4191 2006-06-13 22:42:20Z ray $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 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;
|
||||
|
||||
/**
|
||||
* A placeholder class that contains a reference to the log object used by
|
||||
* the media services package.
|
||||
*/
|
||||
public class Log
|
||||
{
|
||||
public static com.samskivert.util.Log log =
|
||||
new com.samskivert.util.Log("util");
|
||||
|
||||
/** 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);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
package com.threerings.util.keybd;
|
||||
|
||||
import com.threerings.util.Log;
|
||||
import static com.threerings.NenyaLog.log;
|
||||
|
||||
/**
|
||||
* Provides access to the native operating system's auto-repeat keyboard
|
||||
@@ -69,13 +69,13 @@ public class Keyboard
|
||||
System.loadLibrary("keybd");
|
||||
_haveLib = init();
|
||||
if (_haveLib) {
|
||||
Log.info("Loaded native keyboard library.");
|
||||
log.info("Loaded native keyboard library.");
|
||||
} else {
|
||||
Log.info("Native keyboard library initialization failed.");
|
||||
log.info("Native keyboard library initialization failed.");
|
||||
}
|
||||
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
Log.warning("Failed to load native keyboard library " +
|
||||
log.warning("Failed to load native keyboard library " +
|
||||
"[e=" + e + "].");
|
||||
_haveLib = false;
|
||||
}
|
||||
|
||||
@@ -21,9 +21,10 @@
|
||||
|
||||
package com.threerings.util.unsafe;
|
||||
|
||||
import com.threerings.util.Log;
|
||||
import com.samskivert.util.RunAnywhere;
|
||||
|
||||
import static com.threerings.NenyaLog.log;
|
||||
|
||||
/**
|
||||
* A native library for doing unsafe things. Don't use this library. If
|
||||
* you must ignore that warning, then be sure you use it sparingly and
|
||||
@@ -66,7 +67,7 @@ public class Unsafe
|
||||
try {
|
||||
Thread.sleep(millis);
|
||||
} catch (InterruptedException ie) {
|
||||
Log.info("Thread.sleep(" + millis + ") interrupted.");
|
||||
log.info("Thread.sleep(" + millis + ") interrupted.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,7 +139,7 @@ public class Unsafe
|
||||
System.loadLibrary("unsafe");
|
||||
_loaded = init();
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
Log.warning("Failed to load 'unsafe' library: " + e + ".");
|
||||
log.warning("Failed to load 'unsafe' library: " + e + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user