This is the mail archive of the frysk-cvs@sources.redhat.com mailing list for the frysk project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[SCM] master: Rename Branch to Tree.


The branch, master has been updated
       via  15939cb4dad29f01496f8f215baa716e93011199 (commit)
       via  f2ce10e33af58d7adbbcef53a8d6adf4dba8679f (commit)
       via  f4d04c224be500834d2725bef7e4751f88940319 (commit)
      from  4684fc99d954edfb96985ac678d4c1e8b45a8a2c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 15939cb4dad29f01496f8f215baa716e93011199
Author: Andrew Cagney <cagney@redhat.com>
Date:   Mon Dec 10 10:27:34 2007 -0500

    Rename Branch to Tree.
    
    frysk-sys/frysk/rsl/ChangeLog
    2007-12-10  Andrew Cagney  <cagney@redhat.com>
    
    	* Tree.java: Rename Branch.java.
    	* LogOption.java: Update.
    	* TestLog.java: Update.
    	* Log.java: Update.

commit f2ce10e33af58d7adbbcef53a8d6adf4dba8679f
Author: Andrew Cagney <cagney@redhat.com>
Date:   Mon Dec 10 10:22:43 2007 -0500

    Add compatibility layer for java style logging.
    
    frysk-sys/frysk/rsl/ChangeLog
    2007-12-10  Andrew Cagney  <cagney@redhat.com>
    
    	* Logger.java: New.
    	* Log.java (message(...)): Rename log(...).
    	(print(Throwable)): New.
    	(print(Throwable[])): New.
    	(message(Object,Throwable)): New.
    	(message(Object,Throwable[])): New.
    	(format(String,Object[])): New.
    	(format(String,Object)): New.
    	* LogOption.java (parse(String)): New.

commit f4d04c224be500834d2725bef7e4751f88940319
Author: Andrew Cagney <cagney@redhat.com>
Date:   Mon Dec 10 09:10:53 2007 -0500

    Fix <= vs >= bug in enabling loggers.
    
    frysk-sys/frysk/rsl/ChangeLog
    2007-12-09  Andrew Cagney  <cagney@redhat.com>
    
    	* TestLog.java: Update.
    	(checkLevel(String,Level)): Fix comparison.
    	(testOptionFINE()): New.
    	(testOptionSubFINE()): New.
    	(testOptionCommaOption()): New.
    	(testSingleton()): Replace testPeers.
    	* LogOption.java (parsed(Branch,String)): New.
    	(parsed(String)): Use.
    	* Branch.java (get(String,int)): Make private.
    	(get(String)): New.
    	(get(Level)): Make private; use Log.set.
    	(get(String,Level)): New.
    	(complete(String,int,List)): Make private.
    	(complete(String,List)): New.
    	* Log.java (get(String)): Update.
    	(complete(String,List)): Update.
    	(get(String,Level)): New.
    	(finest(...)): Delete.
    	(set(Level)): Replace set(boolean).
    	(Log(String,String,Level)): boolean param removed.

-----------------------------------------------------------------------

Summary of changes:
 frysk-sys/frysk/rsl/ChangeLog                      |   40 +++++++
 frysk-sys/frysk/rsl/Log.java                       |  121 +++++++++++++++-----
 frysk-sys/frysk/rsl/LogOption.java                 |   34 +++++-
 .../frysk/rsl/Logger.java                          |   51 ++++-----
 frysk-sys/frysk/rsl/TestLog.java                   |   73 +++++++++----
 frysk-sys/frysk/rsl/{Branch.java => Tree.java}     |   66 ++++++++---
 6 files changed, 281 insertions(+), 104 deletions(-)
 copy frysk-core/frysk/stepping/StepTerminatedState.java => frysk-sys/frysk/rsl/Logger.java (74%)
 rename frysk-sys/frysk/rsl/{Branch.java => Tree.java} (80%)

First 500 lines of diff:
diff --git a/frysk-sys/frysk/rsl/ChangeLog b/frysk-sys/frysk/rsl/ChangeLog
index 2141ae3..b6c537d 100644
--- a/frysk-sys/frysk/rsl/ChangeLog
+++ b/frysk-sys/frysk/rsl/ChangeLog
@@ -1,3 +1,43 @@
+2007-12-10  Andrew Cagney  <cagney@redhat.com>
+
+	* Tree.java: Rename Branch.java.
+	* LogOption.java: Update.
+	* TestLog.java: Update.
+	* Log.java: Update.
+
+	* Logger.java: New.
+	* Log.java (message(...)): Rename log(...).
+	(print(Throwable)): New.
+	(print(Throwable[])): New.
+	(message(Object,Throwable)): New.
+	(message(Object,Throwable[])): New.
+	(format(String,Object[])): New.
+	(format(String,Object)): New.
+	* LogOption.java (parse(String)): New.
+
+2007-12-09  Andrew Cagney  <cagney@redhat.com>
+
+	* TestLog.java: Update.
+	(checkLevel(String,Level)): Fix comparison.
+	(testOptionFINE()): New.
+	(testOptionSubFINE()): New.	
+	(testOptionCommaOption()): New.
+	(testSingleton()): Replace testPeers.
+	* LogOption.java (parsed(Branch,String)): New.
+	(parsed(String)): Use.
+	* Branch.java (get(String,int)): Make private.
+	(get(String)): New.
+	(get(Level)): Make private; use Log.set.
+	(get(String,Level)): New.
+	(complete(String,int,List)): Make private.
+	(complete(String,List)): New.
+	* Log.java (get(String)): Update.
+	(complete(String,List)): Update.
+	(get(String,Level)): New.
+	(finest(...)): Delete.
+	(set(Level)): Replace set(boolean).
+	(Log(String,String,Level)): boolean param removed.
+
 2007-12-07  Andrew Cagney  <cagney@redhat.com>
 
 	* LogOption.java: New file.
diff --git a/frysk-sys/frysk/rsl/Log.java b/frysk-sys/frysk/rsl/Log.java
index dfaaeb7..2f96d4c 100644
--- a/frysk-sys/frysk/rsl/Log.java
+++ b/frysk-sys/frysk/rsl/Log.java
@@ -41,6 +41,7 @@ package frysk.rsl;
 
 import java.io.PrintStream;
 import java.util.List;
+import java.text.MessageFormat;
 
 /**
  * Generate log information when enabled.
@@ -51,11 +52,11 @@ public final class Log {
     private final String name;
     private final Level level;
     private boolean logging;
-    Log(String path, String name, Level level, boolean logging) {
+    Log(String path, String name, Level level) {
 	this.path = path;
 	this.name = name;
 	this.level = level;
-	this.logging = logging;
+	this.logging = false;
     }
 
     public String toString() {
@@ -86,8 +87,9 @@ public final class Log {
     /**
      * Enable logging; package private.
      */
-    void set(boolean logging) {
-	this.logging = logging;
+    Log set(Level level) {
+	this.logging = this.level.compareTo(level) >= 0;
+	return this;
     }
 
     /**
@@ -97,32 +99,28 @@ public final class Log {
 	return logging;
     }
 
-    public static Branch get(String klass) {
-	synchronized (Branch.root) {
-	    return Branch.root.get(klass, -1);
-	}
+    public static Tree get(String klass) {
+	return Tree.root.get(klass);
     }
-    public static Log fine(String klass) {
-	return get(klass).get(Level.FINE);
+    public static Log get(String klass, Level level) {
+	return Tree.root.get(klass, level);
     }
-    public static Log finest(String klass) {
-	return get(klass).get(Level.FINEST);
+    public static Log fine(String klass) {
+	return get(klass, Level.FINE);
     }
 
-    public static Branch get(Class klass) {
+    public static Tree get(Class klass) {
 	return get(klass.getName());
     }
+    public static Log get(Class klass, Level level) {
+	return get(klass.getName(), level);
+    }
     public static Log fine(Class klass) {
 	return fine(klass.getName());
     }
-    public static Log finest(Class klass) {
-	return finest(klass.getName());
-    }
 
     public static int complete(String incomplete, List candidates) {
-	synchronized (Branch.root) {
-	    return Branch.root.complete(incomplete, -1, candidates);
-	}
+	return Tree.root.complete(incomplete, candidates);
     }
 
     // Static?
@@ -228,9 +226,54 @@ public final class Log {
 	}
 	out.print("]");
     }
+    /**
+     * Throwables get their message printed; along with any root
+     * causes.
+     */
+    private void print(Throwable t) {
+	out.print(" exception");
+	Throwable cause = t;
+	do {
+	    out.print(":");
+	    out.print(t.getMessage());
+	    cause = cause.getCause();
+	} while (cause != null);
+    }
+    private void print(Throwable[] t) {
+	out.print(" exception");
+	for (int i = 0; i < t.length; i++) {
+	    Throwable cause = t[i];
+	    do {
+		out.print(":");
+		out.print(cause.getMessage());
+		cause = cause.getCause();
+	    } while (cause != null);
+	}
+    }
+    
+    /**
+     * For compatibility with existing loggers.
+     */
+    public void format(String msg, Object[] o) {
+	if (!logging)
+	    return;
+	prefix();
+	print(MessageFormat.format(msg, o));
+	postfix();
+    }
+    /**
+     * For compatibility with existing loggers.
+     */
+    public void format(String msg, Object o) {
+	if (!logging)
+	    return;
+	prefix();
+	print(MessageFormat.format(msg, new Object[] { o }));
+	postfix();
+    }
 
     // Add at will and on demand.
-    public void log(String p1) {
+    public void message(String p1) {
 	if (!logging)
 	    return;
 	prefix();
@@ -239,7 +282,27 @@ public final class Log {
     }
 
     // Add at will and on demand.
-    public void log(Object self, String p1, int p2) {
+    public void message(Object self, String p1, int p2) {
+	if (!logging)
+	    return;
+	prefix(self);
+	print(p1);
+	print(p2);
+	postfix();
+    }
+
+    // Add at will and on demand.
+    public void message(Object self, String p1, long p2) {
+	if (!logging)
+	    return;
+	prefix(self);
+	print(p1);
+	print(p2);
+	postfix();
+    }
+
+    // Add at will and on demand.
+    public void message(Object self, String p1, String p2) {
 	if (!logging)
 	    return;
 	prefix(self);
@@ -249,7 +312,7 @@ public final class Log {
     }
 
     // Add at will and on demand.
-    public void log(Object self, String p1, long p2) {
+    public void message(Object self, String p1, Object p2) {
 	if (!logging)
 	    return;
 	prefix(self);
@@ -259,7 +322,7 @@ public final class Log {
     }
 
     // Add at will and on demand.
-    public void log(Object self, String p1, String p2) {
+    public void message(Object self, String p1, int[] p2) {
 	if (!logging)
 	    return;
 	prefix(self);
@@ -269,7 +332,7 @@ public final class Log {
     }
 
     // Add at will and on demand.
-    public void log(Object self, String p1, Object p2) {
+    public void message(Object self, String p1, long[] p2) {
 	if (!logging)
 	    return;
 	prefix(self);
@@ -279,7 +342,7 @@ public final class Log {
     }
 
     // Add at will and on demand.
-    public void log(Object self, String p1, int[] p2) {
+    public void message(Object self, String p1, String[] p2) {
 	if (!logging)
 	    return;
 	prefix(self);
@@ -289,7 +352,7 @@ public final class Log {
     }
 
     // Add at will and on demand.
-    public void log(Object self, String p1, long[] p2) {
+    public void message(Object self, String p1, Object[] p2) {
 	if (!logging)
 	    return;
 	prefix(self);
@@ -299,7 +362,7 @@ public final class Log {
     }
 
     // Add at will and on demand.
-    public void log(Object self, String p1, String[] p2) {
+    public void message(Object self, String p1, Throwable p2) {
 	if (!logging)
 	    return;
 	prefix(self);
@@ -309,7 +372,7 @@ public final class Log {
     }
 
     // Add at will and on demand.
-    public void log(Object self, String p1, Object[] p2) {
+    public void message(Object self, String p1, Throwable[] p2) {
 	if (!logging)
 	    return;
 	prefix(self);
@@ -317,4 +380,6 @@ public final class Log {
 	print(p2);
 	postfix();
     }
+
+
 }
diff --git a/frysk-sys/frysk/rsl/LogOption.java b/frysk-sys/frysk/rsl/LogOption.java
index c03c92d..5d9a7aa 100644
--- a/frysk-sys/frysk/rsl/LogOption.java
+++ b/frysk-sys/frysk/rsl/LogOption.java
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2005, Red Hat Inc.
+// Copyright 2005, 2007 Red Hat Inc.
 //
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
@@ -52,17 +52,37 @@ public class LogOption extends Option {
 	      "<LOG=LEVEL,...>");
     }
     public void parsed (String arg0) throws OptionException {
+	parse(arg0);
+    }
+    public static void parse(String arg0) throws OptionException {
+	parsed(Tree.root, arg0);
+    }
+    static void parsed (Tree root, String arg0) throws OptionException {
 	String[] logs = arg0.split(",");
 	for (int i = 0; i < logs.length; i++) {
 	    String[] logLevel = logs[i].split("=");
-	    Branch logger = Log.get(logLevel[0]);
+	    Tree logger;
+	    Level level;
+	    switch (logLevel.length) {
+	    case 1:
+		// LEVEL
+		logger = root.get("");
+		level = Level.valueOf(logLevel[0]);
+		break;
+	    case 2:
+		// LOGGER=LEVEL
+		logger = root.get(logLevel[0]);
+		level = Level.valueOf(logLevel[1]);
+		break;
+	    default:
+		throw new OptionException("Could not parse: " + logs[i]);
+	    }
 	    if (logger == null)
-		throw new OptionException("Couldn't find logger: "
-					  + logLevel[0]);
-	    Level level = Level.valueOf(logLevel[1]);
+		throw new OptionException("Couldn't find logger for: "
+					  + logs[i]);
 	    if (level == null)
-		throw new OptionException("Invalid log level: "
-					  + logLevel[1]);
+		throw new OptionException("Invalid log level for: "
+					  + logs[i]);
 	    logger.set(level);
 	}
     }
diff --git a/frysk-core/frysk/stepping/StepTerminatedState.java b/frysk-sys/frysk/rsl/Logger.java
similarity index 74%
copy from frysk-core/frysk/stepping/StepTerminatedState.java
copy to frysk-sys/frysk/rsl/Logger.java
index 4f87217..856f6ac 100644
--- a/frysk-core/frysk/stepping/StepTerminatedState.java
+++ b/frysk-sys/frysk/rsl/Logger.java
@@ -1,11 +1,11 @@
 // This file is part of the program FRYSK.
-//
+// 
 // Copyright 2007, Red Hat Inc.
-//
+// 
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
 // the Free Software Foundation; version 2 of the License.
-//
+// 
 // FRYSK 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
@@ -37,37 +37,28 @@
 // version and license this file solely under the GPL without
 // exception.
 
-package frysk.stepping;
-
-import frysk.proc.Task;
-
-public class StepTerminatedState extends State {
+package frysk.rsl;
 
-    /* Whether or not this state represents a terminating state, rather 
-     * than a terminated one. */
-    private boolean terminating = false;
-    
-    public StepTerminatedState(Task task) {
+/**
+ * Java logger compatibility class; to aid easy conversion.
+ */
+public final class Logger {
+    public static Logger getLogger(String path) {
+	return new Logger(path);
     }
-    
-    public StepTerminatedState(Task task, boolean terminating) {
-	this.terminating = terminating;
+    private final Log[] logger = new Log[Level.MAX.intValue()];
+    private Logger(String path) {
+	for (int i = 0; i < Level.MAX.intValue(); i++) {
+	    this.logger[i] = Log.get(path, Level.valueOf(i));
+	}
     }
-
-    public State handleUpdate(TaskStepEngine tse) {
-	return this;
+    public boolean isLoggable(Level level) {
+	return logger[level.intValue()].logging();
     }
-
-    public boolean isStopped() {
-	return true;
+    public void log(Level level, String message, Object[] param) {
+	logger[level.intValue()].format(message, param);
     }
-
-    public boolean isAlive() {
-	return false;
+    public void log(Level level, String message, Object param) {
+	logger[level.intValue()].format(message, param);
     }
-    
-    public boolean isTerminating() {
-	return this.terminating;
-    }
-
 }
diff --git a/frysk-sys/frysk/rsl/TestLog.java b/frysk-sys/frysk/rsl/TestLog.java
index bc91dd9..92302df 100644
--- a/frysk-sys/frysk/rsl/TestLog.java
+++ b/frysk-sys/frysk/rsl/TestLog.java
@@ -47,60 +47,66 @@ import java.util.LinkedList;
  */
 
 public class TestLog extends TestCase {
-    private static final Log fine = Log.fine(TestCase.class);
+    private static final Log log = Log.fine(TestCase.class);
 
-    private Branch root;
+    private Tree root;
     public void setUp() {
-	fine.log("setUp");
-	root = new Branch();
+	log.message("setUp");
+	root = new Tree();
     }
     public void tearDown() {
-	fine.log("tearDown");
+	log.message("tearDown");
 	root = null;
     }
-    private Branch get(String path) {
-	return root.get(path, -1);
+    private Tree get(String path) {
+	return root.get(path);
+    }
+    private Log get(String path, Level level) {
+	return root.get(path, level);
     }
 
     public void testRoot() {
-	//log.fine(this, "hello");
 	assertNotNull("root", root);
     }
 
     public void testGetSelf() {
-	Log self = get("self").get(Level.FINE);
+	Log self = get("self", Level.FINE);
 	assertNotNull("self", self);
     }
 
+    public void testGetRoot() {
+	assertEquals("root", root, root.get(""));
+    }
+
     public void testPath() {
 	String path = "a.long.path";
-	assertEquals("path", path, get(path).get(Level.FINE).path());
+	assertEquals("path", path, get(path, Level.FINE).path());
     }
 
     public void testName() {
 	assertEquals("name", "path",
-		     get("a.long.path").get(Level.FINE).name());
+		     get("a.long.path", Level.FINE).name());
     }
 
     public void testLevel() {
 	assertEquals("level", Level.FINE,
-		     get("a.long.path").get(Level.FINE).level());
+		     get("a.long.path", Level.FINE).level());
     }
 
-    public void testPeers() {
-	Log lhs = get("the.lhs").get(Level.FINE);
-	Log rhs = get("the.rhs").get(Level.FINE);
+    public void testSingleton() {
+	Log lhs = get("the.lhs", Level.FINE);
+	Log rhs = get("the.rhs", Level.FINE);
 	assertNotNull("the.lhs", lhs);
 	assertNotNull("the.rhs", rhs);
 	assertTrue("lhs != rhs", lhs != rhs);
-	assertEquals("the.lhs", lhs, get("the.lhs").get(Level.FINE));
-	assertEquals("the.rhs", rhs, get("the.rhs").get(Level.FINE));
+	assertSame("the.lhs", lhs, get("the.lhs", Level.FINE));
+	assertSame("the.rhs", rhs, get("the.rhs", Level.FINE));
     }
 


hooks/post-receive
--
frysk system monitor/debugger


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]