[Swift-commit] r2761 - trunk/src/org/griphyn/vdl/karajan/lib

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Sun Mar 29 14:32:13 CDT 2009


Author: hategan
Date: 2009-03-29 14:32:13 -0500 (Sun, 29 Mar 2009)
New Revision: 2761

Modified:
   trunk/src/org/griphyn/vdl/karajan/lib/Log.java
Log:
added message argument to Log - simpler xml

Modified: trunk/src/org/griphyn/vdl/karajan/lib/Log.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/Log.java	2009-03-29 19:31:29 UTC (rev 2760)
+++ trunk/src/org/griphyn/vdl/karajan/lib/Log.java	2009-03-29 19:32:13 UTC (rev 2761)
@@ -19,9 +19,10 @@
 
 public class Log extends AbstractSequentialWithArguments {
 	public static final Arg LEVEL = new Arg.Positional("level");
+	public static final Arg MESSAGE = new Arg.Optional("message", null);
 
 	static {
-		setArguments(Log.class, new Arg[] { LEVEL, Arg.VARGS });
+		setArguments(Log.class, new Arg[] { LEVEL, MESSAGE, Arg.VARGS });
 	}
 
 	private static Map loggers = new HashMap();
@@ -71,12 +72,18 @@
 		Level lvl = getLevel(TypeUtil.toString(LEVEL.getValue(stack)));
 		Logger logger = getLogger(cls);
 		if (logger.isEnabledFor(lvl)) {
-			Object[] msg = Arg.VARGS.asArray(stack);
-			StringBuffer sb = new StringBuffer();
-			for (int i = 0; i < msg.length; i++) {
-				sb.append(TypeUtil.toString(msg[i]));
-			}
-			logger.log(lvl, sb.toString());
+		    Object smsg = MESSAGE.getValue(stack);
+		    if (smsg != null) {
+		        logger.log(lvl, smsg);
+		    }
+		    else {
+		        Object[] msg = Arg.VARGS.asArray(stack);
+		        StringBuffer sb = new StringBuffer();
+		        for (int i = 0; i < msg.length; i++) {
+		            sb.append(TypeUtil.toString(msg[i]));
+		        }
+		        logger.log(lvl, sb.toString());
+		    }
 		}
 		super.post(stack);
 	}




More information about the Swift-commit mailing list