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$
|
// $Id$
|
||||||
//
|
//
|
||||||
// Narya library - tools for developing networked games
|
// 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/
|
// http://www.threerings.net/code/narya/
|
||||||
//
|
//
|
||||||
// This library is free software; you can redistribute it and/or modify it
|
// 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
|
// License along with this library; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// 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
|
* 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 =
|
/** We dispatch our log messages through this logger. */
|
||||||
new com.samskivert.util.Log("util");
|
public static Logger log = Logger.getLogger("com.threerings.narya");
|
||||||
|
|
||||||
/** 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -28,6 +28,8 @@ import java.util.ResourceBundle;
|
|||||||
import com.samskivert.text.MessageUtil;
|
import com.samskivert.text.MessageUtil;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
|
import static com.threerings.NaryaLog.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A message bundle provides an easy mechanism by which to obtain
|
* A message bundle provides an easy mechanism by which to obtain
|
||||||
* translated message strings from a resource bundle. It uses the {@link
|
* translated message strings from a resource bundle. It uses the {@link
|
||||||
@@ -116,7 +118,7 @@ public class MessageBundle
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (reportMissing) {
|
if (reportMissing) {
|
||||||
Log.warning("Missing translation message " +
|
log.warning("Missing translation message " +
|
||||||
"[bundle=" + _path + ", key=" + key + "].");
|
"[bundle=" + _path + ", key=" + key + "].");
|
||||||
Thread.dumpStack();
|
Thread.dumpStack();
|
||||||
}
|
}
|
||||||
@@ -235,14 +237,14 @@ public class MessageBundle
|
|||||||
args = newargs;
|
args = newargs;
|
||||||
msg = getResourceString(key + getSuffix(args));
|
msg = getResourceString(key + getSuffix(args));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.warning("Failure doing automatic plural handling " +
|
log.warning("Failure doing automatic plural handling " +
|
||||||
"[bundle=" + _path + ", key=" + key +
|
"[bundle=" + _path + ", key=" + key +
|
||||||
", args=" + StringUtil.toString(args) +
|
", args=" + StringUtil.toString(args) +
|
||||||
", error=" + e + "].");
|
", error=" + e + "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log.warning("Missing translation message " +
|
log.warning("Missing translation message " +
|
||||||
"[bundle=" + _path + ", key=" + key + "].");
|
"[bundle=" + _path + ", key=" + key + "].");
|
||||||
Thread.dumpStack();
|
Thread.dumpStack();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import java.util.ResourceBundle;
|
|||||||
|
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
|
import static com.threerings.NaryaLog.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The message manager provides a thin wrapper around Java's built-in
|
* The message manager provides a thin wrapper around Java's built-in
|
||||||
* localization support, supporting a policy of dividing up localization
|
* localization support, supporting a policy of dividing up localization
|
||||||
@@ -70,7 +72,7 @@ public class MessageManager
|
|||||||
|
|
||||||
// use the default locale
|
// use the default locale
|
||||||
_locale = Locale.getDefault();
|
_locale = Locale.getDefault();
|
||||||
Log.info("Using locale: " + _locale + ".");
|
log.info("Using locale: " + _locale + ".");
|
||||||
|
|
||||||
// make sure the prefix ends with a dot
|
// make sure the prefix ends with a dot
|
||||||
if (!_prefix.endsWith(".")) {
|
if (!_prefix.endsWith(".")) {
|
||||||
@@ -139,7 +141,7 @@ public class MessageManager
|
|||||||
rbundle = ResourceBundle.getBundle(fqpath, _locale);
|
rbundle = ResourceBundle.getBundle(fqpath, _locale);
|
||||||
}
|
}
|
||||||
} catch (MissingResourceException mre) {
|
} catch (MissingResourceException mre) {
|
||||||
Log.warning("Unable to resolve resource bundle " +
|
log.warning("Unable to resolve resource bundle " +
|
||||||
"[path=" + fqpath + ", locale=" + _locale + "].");
|
"[path=" + fqpath + ", locale=" + _locale + "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +161,7 @@ public class MessageManager
|
|||||||
// nothing to worry about
|
// nothing to worry about
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Log.warning("Failure instantiating custom message bundle " +
|
log.warning("Failure instantiating custom message bundle " +
|
||||||
"[mbclass=" + mbclass + ", error=" + t + "].");
|
"[mbclass=" + mbclass + ", error=" + t + "].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import com.samskivert.util.Tuple;
|
import com.samskivert.util.Tuple;
|
||||||
|
|
||||||
|
import static com.threerings.NaryaLog.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to perform rudimentary memory profiling on large, running systems
|
* Used to perform rudimentary memory profiling on large, running systems
|
||||||
* where it is impractical to operate a real profiler. Instances of {@link
|
* where it is impractical to operate a real profiler. Instances of {@link
|
||||||
@@ -75,7 +77,7 @@ public class TrackedObject
|
|||||||
if (count != null) {
|
if (count != null) {
|
||||||
count[0]--;
|
count[0]--;
|
||||||
} else {
|
} else {
|
||||||
Log.warning("Finalized TrackedObject missing counter! " +
|
log.warning("Finalized TrackedObject missing counter! " +
|
||||||
"[class=" + clazz + "].");
|
"[class=" + clazz + "].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ package com.threerings.util.signal;
|
|||||||
|
|
||||||
import com.samskivert.util.HashIntMap;
|
import com.samskivert.util.HashIntMap;
|
||||||
import com.samskivert.util.ObserverList;
|
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
|
* Uses native code to catch Unix signals and invoke callbacks on a
|
||||||
@@ -173,7 +174,7 @@ public class SignalManager
|
|||||||
if (_haveLibrary && _sigdis == null) {
|
if (_haveLibrary && _sigdis == null) {
|
||||||
_sigdis = new Thread() {
|
_sigdis = new Thread() {
|
||||||
public void run () {
|
public void run () {
|
||||||
Log.info("Dispatching signals...");
|
log.info("Dispatching signals...");
|
||||||
dispatchSignals();
|
dispatchSignals();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -190,7 +191,7 @@ public class SignalManager
|
|||||||
{
|
{
|
||||||
ObserverList list = (ObserverList)_handlers.get(signal);
|
ObserverList list = (ObserverList)_handlers.get(signal);
|
||||||
if (list == null || !list.contains(handler)) {
|
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 + "].");
|
"[signal=" + signal + ", handler=" + handler + "].");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -273,7 +274,7 @@ public class SignalManager
|
|||||||
System.loadLibrary("signal");
|
System.loadLibrary("signal");
|
||||||
_haveLibrary = true;
|
_haveLibrary = true;
|
||||||
} catch (Throwable t) {
|
} 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