Move to our new Java logging based logging style which also fixes a conflict
between logging in the Narya util package and the Nenya util package. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4214 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// Copyright (C) 2002-2006 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
|
||||
@@ -19,38 +19,16 @@
|
||||
// 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;
|
||||
package com.threerings;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* A placeholder class that contains a reference to the log object used by
|
||||
* the media services package.
|
||||
* this project.
|
||||
*/
|
||||
public class Log
|
||||
public class NaryaLog
|
||||
{
|
||||
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);
|
||||
}
|
||||
/** We dispatch our log messages through this logger. */
|
||||
public static Logger log = Logger.getLogger("com.threerings.narya");
|
||||
}
|
||||
@@ -28,6 +28,8 @@ import java.util.ResourceBundle;
|
||||
import com.samskivert.text.MessageUtil;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import static com.threerings.NaryaLog.log;
|
||||
|
||||
/**
|
||||
* A message bundle provides an easy mechanism by which to obtain
|
||||
* translated message strings from a resource bundle. It uses the {@link
|
||||
@@ -116,7 +118,7 @@ public class MessageBundle
|
||||
}
|
||||
|
||||
if (reportMissing) {
|
||||
Log.warning("Missing translation message " +
|
||||
log.warning("Missing translation message " +
|
||||
"[bundle=" + _path + ", key=" + key + "].");
|
||||
Thread.dumpStack();
|
||||
}
|
||||
@@ -235,14 +237,14 @@ public class MessageBundle
|
||||
args = newargs;
|
||||
msg = getResourceString(key + getSuffix(args));
|
||||
} catch (Exception e) {
|
||||
Log.warning("Failure doing automatic plural handling " +
|
||||
log.warning("Failure doing automatic plural handling " +
|
||||
"[bundle=" + _path + ", key=" + key +
|
||||
", args=" + StringUtil.toString(args) +
|
||||
", error=" + e + "].");
|
||||
}
|
||||
|
||||
} else {
|
||||
Log.warning("Missing translation message " +
|
||||
log.warning("Missing translation message " +
|
||||
"[bundle=" + _path + ", key=" + key + "].");
|
||||
Thread.dumpStack();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ import java.util.ResourceBundle;
|
||||
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import static com.threerings.NaryaLog.log;
|
||||
|
||||
/**
|
||||
* The message manager provides a thin wrapper around Java's built-in
|
||||
* localization support, supporting a policy of dividing up localization
|
||||
@@ -70,7 +72,7 @@ public class MessageManager
|
||||
|
||||
// use the default locale
|
||||
_locale = Locale.getDefault();
|
||||
Log.info("Using locale: " + _locale + ".");
|
||||
log.info("Using locale: " + _locale + ".");
|
||||
|
||||
// make sure the prefix ends with a dot
|
||||
if (!_prefix.endsWith(".")) {
|
||||
@@ -139,7 +141,7 @@ public class MessageManager
|
||||
rbundle = ResourceBundle.getBundle(fqpath, _locale);
|
||||
}
|
||||
} catch (MissingResourceException mre) {
|
||||
Log.warning("Unable to resolve resource bundle " +
|
||||
log.warning("Unable to resolve resource bundle " +
|
||||
"[path=" + fqpath + ", locale=" + _locale + "].");
|
||||
}
|
||||
|
||||
@@ -159,7 +161,7 @@ public class MessageManager
|
||||
// nothing to worry about
|
||||
|
||||
} catch (Throwable t) {
|
||||
Log.warning("Failure instantiating custom message bundle " +
|
||||
log.warning("Failure instantiating custom message bundle " +
|
||||
"[mbclass=" + mbclass + ", error=" + t + "].");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ import java.util.Map;
|
||||
|
||||
import com.samskivert.util.Tuple;
|
||||
|
||||
import static com.threerings.NaryaLog.log;
|
||||
|
||||
/**
|
||||
* Used to perform rudimentary memory profiling on large, running systems
|
||||
* where it is impractical to operate a real profiler. Instances of {@link
|
||||
@@ -75,7 +77,7 @@ public class TrackedObject
|
||||
if (count != null) {
|
||||
count[0]--;
|
||||
} else {
|
||||
Log.warning("Finalized TrackedObject missing counter! " +
|
||||
log.warning("Finalized TrackedObject missing counter! " +
|
||||
"[class=" + clazz + "].");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ package com.threerings.util.signal;
|
||||
|
||||
import com.samskivert.util.HashIntMap;
|
||||
import com.samskivert.util.ObserverList;
|
||||
import com.threerings.util.Log;
|
||||
|
||||
import static com.threerings.NaryaLog.log;
|
||||
|
||||
/**
|
||||
* Uses native code to catch Unix signals and invoke callbacks on a
|
||||
@@ -173,7 +174,7 @@ public class SignalManager
|
||||
if (_haveLibrary && _sigdis == null) {
|
||||
_sigdis = new Thread() {
|
||||
public void run () {
|
||||
Log.info("Dispatching signals...");
|
||||
log.info("Dispatching signals...");
|
||||
dispatchSignals();
|
||||
}
|
||||
};
|
||||
@@ -190,7 +191,7 @@ public class SignalManager
|
||||
{
|
||||
ObserverList list = (ObserverList)_handlers.get(signal);
|
||||
if (list == null || !list.contains(handler)) {
|
||||
Log.warning("Requested to remove non-registered handler " +
|
||||
log.warning("Requested to remove non-registered handler " +
|
||||
"[signal=" + signal + ", handler=" + handler + "].");
|
||||
return;
|
||||
}
|
||||
@@ -273,7 +274,7 @@ public class SignalManager
|
||||
System.loadLibrary("signal");
|
||||
_haveLibrary = true;
|
||||
} catch (Throwable t) {
|
||||
Log.info("Could not load libsignal.so; signal handling disabled.");
|
||||
log.info("Could not load libsignal.so; signal handling disabled.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user