/***********************************************************************
 * Copyright (c) 2006 The Apache Software Foundation.                  *
 * All rights reserved.                                                *
 * ------------------------------------------------------------------- *
 * Licensed under the Apache License, Version 2.0 (the "License"); you *
 * may not use this file except in compliance with the License. You    *
 * may obtain a copy of the License at:                                *
 *                                                                     *
 *     http://www.apache.org/licenses/LICENSE-2.0                      *
 *                                                                     *
 * Unless required by applicable law or agreed to in writing, software *
 * distributed under the License is distributed on an "AS IS" BASIS,   *
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or     *
 * implied.  See the License for the specific language governing       *
 * permissions and limitations under the License.                      *
 ***********************************************************************/

package org.apache.james.jspf;

import org.apache.log4j.BasicConfigurator;

/**
 * This class is used for commandline usage of JSPF
 * 
 * @author Norman Maurer <nm@byteaction.de>
 * @author Stefano Bagnara <apache@bago.org>
 */
public class SPFQuery {

    /**
     * @param args
     *            The commandline arguments to parse
     */
    public static void main(String[] args) {
        String ip = null;
        String sender = null;
        String helo = null;

        BasicConfigurator.configure();

        // Parse the command line arguments
        if (args.length < 3) {
            usage();
        } else {
            for (int i = 0; i < args.length; i++) {
                String[] arguments = args[i].split("=");
                if (arguments.length == 2) {
                    if (arguments[0].equals("-ip")) {
                        ip = arguments[1];
                    } else if (arguments[0].equals("-sender")) {
                        sender = arguments[1];
                    } else if (arguments[0].equals("-helo")) {
                        helo = arguments[1];
                    } else {
                        usage();
                    }
                } else {
                    usage();
                }

            }

            // check if all needed values was set
            if (ip != null && sender != null && helo != null) {
                SPF spf = new SPF();
                SPFResult result = spf.checkSPF(ip, sender, helo);
                System.out.println(result.getResult());
                System.out.println(result.getHeader());
                System.exit(0);
            } else {
                usage();
            }
        }
    }

    /**
     * Print out the usage
     */
    private static void usage() {
        System.out
                .println("Usage: SPFQuery -ip=192.168.100.1 -sender=postmaster@foo.bar -helo=foo.bar");
        System.exit(0);
    }

}

@@ -1219,33 +1219,132 @@
 e.log4j.
-BasicConfigurator
+ConsoleAppender;%0Aimport org.apache.log4j.Level;%0Aimport org.apache.log4j.Logger;%0Aimport org.apache.log4j.SimpleLayout
 ;%0A%0A/**%0A 
@@ -1516,16 +1516,76 @@
 uery %7B%0A%0A
+    private static Logger logger = Logger.getRootLogger();%0A%0A
     /**%0A
@@ -1705,24 +1705,25 @@
 g%5B%5D args) %7B%0A
+%0A
         Stri
@@ -1807,36 +1807,202 @@
     
-BasicConfigurator.configure(
+SimpleLayout layout = new SimpleLayout();%0A        ConsoleAppender consoleAppender = new ConsoleAppender(layout);%0A        logger.addAppender(consoleAppender);%0A%0A        logger.setLevel(Level.ERROR
 );%0A%0A
@@ -2072,16 +2072,35 @@
 ngth %3C 3
+ %7C%7C args.length %3E 4
 ) %7B%0A    
@@ -2246,57 +2246,9 @@
 %22);%0A
-                if (arguments.length == 2) %7B%0A    
+%0A
     
@@ -2313,20 +2313,16 @@
         
-    
 ip = arg
@@ -2324,36 +2324,32 @@
 = arguments%5B1%5D;%0A
-    
                 
@@ -2413,20 +2413,16 @@
         
-    
 sender =
@@ -2444,36 +2444,32 @@
                 
- 
-   
 %7D else if (argum
@@ -2515,20 +2515,16 @@
         
-    
 helo = a
@@ -2556,75 +2556,213 @@
     
-    %7D else %7B%0A                        usage();%0A                    %7D
+%7D else if (arguments%5B0%5D.equals(%22-debug%22)) %7B%0A                    logger.setLevel(Level.DEBUG);%0A                %7D else if (arguments%5B0%5D.equals(%22-verbose%22)) %7B%0A                    logger.setLevel(Level.TRACE);
 %0A   
@@ -3481,16 +3481,36 @@
 =foo.bar
+ %5B-debug%5D %5B-verbose%5D
 %22);%0A    

Add switches for enable/disable logging on cmdline use. See JSPF-16