diff --git a/src/as/com/threerings/util/Log.as b/src/as/com/threerings/util/Log.as index a14e98095..c2d4ac5d7 100644 --- a/src/as/com/threerings/util/Log.as +++ b/src/as/com/threerings/util/Log.as @@ -56,7 +56,8 @@ public class Log public static const DEBUG :int = 0; public static const INFO :int = 1; public static const WARNING :int = 2; - public static const OFF :int = 3; + public static const ERROR :int = 3; + public static const OFF :int = 4; // if you add to this, update LEVEL_NAMES and stringToLevel() at the bottom... /** @@ -204,8 +205,27 @@ public class Log doLog(WARNING, args); } + /** + * Log a message with 'error' priority. + * + * @param args The first argument is the actual message to log. After that, each pair + * of parameters is printed in key/value form, the benefit being that if no log + * message is generated then toString() will not be called on the values. + * A final parameter may be an Error, in which case the stack trace is printed. + * + * @example + * + * log.error("Message", "key1", value1, "key2", value2, optionalError); + * + */ + public function error (... args) :void + { + doLog(ERROR, args); + } + /** * Log just a stack trace with 'warning' priority. + * Deprecated, sorta. Just use warning("Message", error); */ public function logStackTrace (error :Error) :void { @@ -300,6 +320,7 @@ public class Log case "debug": return DEBUG; case "info": return INFO; case "warning": case "warn": return WARNING; + case "error": return ERROR; case "off": return OFF; } } @@ -317,6 +338,6 @@ public class Log protected static var _setLevels :Object = { "": DEBUG }; // global: debug /** The outputted names of each level. The last one isn't used, it corresponds with OFF. */ - protected static const LEVEL_NAMES :Array = [ "debug", "INFO", "WARNING", false ]; + protected static const LEVEL_NAMES :Array = [ "debug", "INFO", "WARN", "ERROR", false ]; } }