bloritsch 2002/07/26 10:06:44 Modified: src/java/org/apache/cocoon Main.java Log: add verbose messaging Revision Changes Path 1.22 +31 -20 xml-cocoon2/src/java/org/apache/cocoon/Main.java Index: Main.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/Main.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- Main.java 21 Jul 2002 13:08:07 -0000 1.21 +++ Main.java 26 Jul 2002 17:06:44 -0000 1.22 @@ -104,6 +104,7 @@ protected static final int HELP_OPT = 'h'; protected static final int VERSION_OPT = 'v'; + protected static final int VERBOSE_OPT = 'V'; protected static final int LOG_KIT_OPT = 'k'; protected static final int LOGGER_OPT = 'l'; protected static final int LOG_LEVEL_OPT = 'u'; @@ -138,6 +139,10 @@ CLOptionDescriptor.ARGUMENT_DISALLOWED, VERSION_OPT, "print the version information and exit"), + new CLOptionDescriptor("verbose", + CLOptionDescriptor.ARGUMENT_DISALLOWED, + VERBOSE_OPT, + "enable verbose messages to System.out"), new CLOptionDescriptor("logKitconfig", CLOptionDescriptor.ARGUMENT_REQUIRED, LOG_KIT_OPT, @@ -186,6 +191,8 @@ + " file (default is ${contextDir}/cocoon.xconf)") }; + protected static boolean verbose = false; + /** * <code>processFile</code> method. * @@ -261,6 +268,10 @@ printVersion(); break; + case Main.VERBOSE_OPT: + Main.verbose = true; + break; + case Main.DEST_DIR_OPT: destDir = option.getArgument(); break; @@ -346,7 +357,7 @@ System.exit(1); } - System.out.print("."); + if (verbose) System.out.print("."); try { File dest = null; @@ -365,7 +376,7 @@ conf = new File(context, configFile); } - System.out.print("."); + if (verbose) System.out.print("."); DefaultContext appContext = new DefaultContext(); appContext.put(Constants.CONTEXT_CLASS_LOADER, Main.class.getClassLoader()); @@ -394,7 +405,7 @@ logKitManager.setLogger(log); } - System.out.print("."); + if (verbose) System.out.print("."); appContext.put(Constants.CONTEXT_CLASSPATH, getClassPath(contextDir)); appContext.put(Constants.CONTEXT_WORK_DIR, work); @@ -404,7 +415,7 @@ appContext.put(Constants.CONTEXT_CONFIG_URL, conf.toURL()); Cocoon c = new Cocoon(); - System.out.print("."); + if (verbose) System.out.print("."); c.setLogger(log); c.contextualize(appContext); @@ -412,7 +423,7 @@ c.initialize(); Main main = new Main(c, context, dest, brokenLinkFile); - System.out.print("."); + if (verbose) System.out.print("."); main.userAgent = userAgent; main.accept = accept; @@ -424,9 +435,9 @@ if (main.process(targets, precompileOnly) == 0) { main.recursivelyPrecompile(context, context); } - System.out.print("\ndisposing..."); + if (verbose) System.out.print("\ndisposing..."); c.dispose(); - System.out.print(".done.\n"); + if (verbose) System.out.print(".done.\n"); log.info("Done"); } catch (Exception e) { log.fatalError("Exception caught ", e); @@ -572,7 +583,7 @@ */ public void warmup() throws Exception { log.info("Warming up..."); - System.out.println("Warming up..."); + if (verbose) System.out.println("Warming up..."); //log.info(" [Cocoon might need to compile the sitemaps, this might take a while]"); //cocoon.process(new LinkSamplingEnvironment("/", context, attributes, null)); cocoon.generateSitemap(new LinkSamplingEnvironment("/", context, attributes, null, this.log)); @@ -588,7 +599,7 @@ public int process(Collection uris, boolean precompileOnly) throws Exception { int nCount = 0; log.info("...ready, let's go:"); - System.out.println("...ready, let's go:"); + if (verbose) System.out.println("...ready, let's go:"); ArrayList links = new java.util.ArrayList(); Iterator i = uris.iterator(); @@ -620,7 +631,7 @@ } } catch (ResourceNotFoundException rnfe) { log.warn(" [broken link]--> " + url); - System.out.println(" [broken link]--> " + url); + if (verbose) System.out.println(" [broken link]--> " + url); if (null != this.brokenLinkWriter) { this.brokenLinkWriter.println(url); } @@ -712,8 +723,8 @@ public Collection processURI(String uri) throws Exception { log.info("Processing URI: " + uri); - System.out.println("URI: " + uri); - System.out.print(" getting links: ."); + if (verbose) System.out.println("URI: " + uri); + if (verbose) System.out.print(" getting links: ."); // Get parameters, deparameterized URI and path from URI final TreeMap parameters = new TreeMap(); @@ -772,12 +783,12 @@ try { translatedAbsoluteLink = this.translateURI(absoluteLink); log.info(" Link translated: " + absoluteLink); - System.out.println("."); + if (verbose) System.out.print("."); allTranslatedLinks.put(absoluteLink, translatedAbsoluteLink); absoluteLinks.add(absoluteLink); } catch (ResourceNotFoundException rnfe) { log.warn(" [broken link]--> " + absoluteLink); - System.out.println(" [broken link]--> " + absoluteLink); + if (verbose) System.out.println("\n [broken link]--> " + absoluteLink); if (null != this.brokenLinkWriter) { this.brokenLinkWriter.println(absoluteLink); @@ -790,7 +801,7 @@ translatedLinks.put(link, translatedRelativeLink); } - System.out.println("\n processing"); + if (verbose) System.out.println("\n processing"); try { // Process URI @@ -801,7 +812,7 @@ if (type == null) { log.warn(" [broken link]--> " + filename); - System.out.println(" [broken link]--> " + filename); + if (verbose) System.out.println(" [broken link]--> " + filename); if (null != this.brokenLinkWriter) { this.brokenLinkWriter.println(filename); @@ -809,11 +820,11 @@ resourceUnavailable(file); } else { log.info(" [" + type + "]--> " + filename); - System.out.println(" [" + type + "]--> " + filename); + if (verbose) System.out.println(" [" + type + "]--> " + filename); } } catch (ResourceNotFoundException rnfe) { this.log.warn("Could not process URI: " + deparameterizedURI); - System.out.println("Could not process URI: " + deparameterizedURI); + if (verbose) System.out.println("Could not process URI: " + deparameterizedURI); } return absoluteLinks; @@ -829,7 +840,7 @@ public String translateURI(String uri) throws Exception { if (null == uri || "".equals(uri)) { log.warn("translate empty uri"); - System.out.println("translate empty uri"); + if (verbose) System.out.println("translate empty uri"); return ""; } HashMap parameters = new HashMap();
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]