ruper2/src/java/core/org/krysalis/ruper/tool Tool.java,1.5,1.6 FileTool.java,1.2,1.3
[email protected] Mon, 22 Sep 2003 17:19:19 -0700
Newsgroups
gmane.comp.krysalis.metamorphosis.cvs
Message-ID
<[email protected] >
Update of /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper/tool
In directory sc8-pr-cvs1:/tmp/cvs-serv11617/src/java/core/org/krysalis/ruper/tool
Modified Files:
Tool.java FileTool.java
Log Message:
Renamed Simple Logger to Standard (since it writes to StdOut)
More work on logging and messages
Index: Tool.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper/tool/Tool.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Tool.java 22 Sep 2003 17:09:42 -0000 1.5
--- Tool.java 23 Sep 2003 00:19:17 -0000 1.6
***************
*** 6,11 ****
import java.io.PrintWriter;
import org.krysalis.ruper.log.Logger;
! import org.krysalis.ruper.log.SimpleLogListener;
import org.krysalis.version.util.SystemUtils;
import org.krysalis.version.util.cli.CommandLine;
--- 6,12 ----
import java.io.PrintWriter;
+ import org.krysalis.ruper.log.LogConstant;
import org.krysalis.ruper.log.Logger;
! import org.krysalis.ruper.log.StandardLogListener;
import org.krysalis.version.util.SystemUtils;
import org.krysalis.version.util.cli.CommandLine;
***************
*** 21,31 ****
public abstract class Tool {
private static Option l_verboseOption = null;
private static Option l_helpOption = null;
private static Options l_options = null;
! static {
l_helpOption = new Option("h", "help", false, "print help");
l_verboseOption = new Option("v", "verbose", false, "verbose output");
--- 22,37 ----
public abstract class Tool {
+ private static Option l_debugOption = null;
private static Option l_verboseOption = null;
private static Option l_helpOption = null;
private static Options l_options = null;
! private static boolean l_debug = false;
! private static boolean l_verbose = false;
! private static boolean l_help = false;
+ static {
l_helpOption = new Option("h", "help", false, "print help");
+ l_debugOption = new Option("d", "debug", false, "debug output");
l_verboseOption = new Option("v", "verbose", false, "verbose output");
***************
*** 44,47 ****
--- 50,54 ----
protected abstract void init();
+
protected void printHelp() {
getOptions().display();
***************
*** 57,60 ****
--- 64,71 ----
parser.setStrict(false);
cmdline = parser.parse(l_options, args);
+
+ l_help = cmdline.isSet(l_helpOption);
+ l_verbose = cmdline.isSet(l_verboseOption);
+ l_debug = cmdline.isSet(l_debugOption);
}
catch (ParseException exp) {
***************
*** 72,85 ****
DebugUtils.enableCommonsLogging();
- // Set logging context..
- //:TODO: Make sensetive to level (-debug -verbose, etc.)
- Logger logger = Logger.pushContext(new SimpleLogListener());
-
init();
CommandLine cmdline = parseCommandLine(args);
! try {
execute(cmdline);
}
--- 83,103 ----
DebugUtils.enableCommonsLogging();
init();
CommandLine cmdline = parseCommandLine(args);
! if (l_help) {
! printHelp();
! System.exit(0);
! }
+ // Set logging context
+ int level = LogConstant.INFO;
+ if (l_verbose || l_debug)
+ level = l_debug ? LogConstant.DEBUG : LogConstant.VERBOSE;
+ Logger logger =
+ logger = Logger.pushContext(level,new StandardLogListener());
+
+ try {
execute(cmdline);
}
Index: FileTool.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper/tool/FileTool.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** FileTool.java 8 Sep 2003 23:21:39 -0000 1.2
--- FileTool.java 23 Sep 2003 00:19:17 -0000 1.3
***************
*** 9,12 ****
--- 9,13 ----
import org.krysalis.ruper.api.tool.FileUpdater;
+ import org.krysalis.ruper.log.Logger;
import org.krysalis.ruper.query.ResourceResult;
import org.krysalis.version.util.cli.CommandLine;
***************
*** 33,42 ****
FileUpdater fu = new FileUpdater();
!
getOutput().println("File: [" + fileName + "]");
! ResourceResult result = fu.determineFileUpdates(fileName);
! DebugUtils.dump(result);
}
--- 34,44 ----
FileUpdater fu = new FileUpdater();
!
getOutput().println("File: [" + fileName + "]");
! ResourceResult result = fu.determineFilesUpdates(fileName);
! if (Logger.getLog().isDebug())
! DebugUtils.dump(result);
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf