From 3181be14ebe7519de94dfb59eefdce845e76cad5 Mon Sep 17 00:00:00 2001
From: Aaron Kimball <aaron@cloudera.com>
Date: Fri, 12 Feb 2010 12:01:30 -0800
Subject: [PATCH] MAPREDUCE-1467. Add a --verbose flag to Sqoop.

---
 src/contrib/sqoop/doc/Sqoop-manpage.txt            |    3 +++
 src/contrib/sqoop/doc/misc-args.txt                |    4 ++++
 .../org/apache/hadoop/sqoop/ImportOptions.java     |   10 ++++++++++
 3 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/contrib/sqoop/doc/Sqoop-manpage.txt b/src/contrib/sqoop/doc/Sqoop-manpage.txt
index aadabce..0aec6d5 100644
--- a/src/contrib/sqoop/doc/Sqoop-manpage.txt
+++ b/src/contrib/sqoop/doc/Sqoop-manpage.txt
@@ -162,6 +162,9 @@ no import or code generation is performed.
 --list-tables::
   List tables in database and exit
 
+--verbose::
+  Print more information while working
+
 
 ENVIRONMENT
 -----------
diff --git a/src/contrib/sqoop/doc/misc-args.txt b/src/contrib/sqoop/doc/misc-args.txt
index 9d77a98..2143942 100644
--- a/src/contrib/sqoop/doc/misc-args.txt
+++ b/src/contrib/sqoop/doc/misc-args.txt
@@ -34,3 +34,7 @@ Data emitted to HDFS is by default uncompressed. You can instruct
 Sqoop to use gzip to compress your data by providing either the
 +--compress+ or +-z+ argument (both are equivalent).
 
+Using +--verbose+ will instruct Sqoop to print more details about its
+operation; this is particularly handy if Sqoop appears to be misbehaving.
+
+
diff --git a/src/contrib/sqoop/src/java/org/apache/hadoop/sqoop/ImportOptions.java b/src/contrib/sqoop/src/java/org/apache/hadoop/sqoop/ImportOptions.java
index cc44407..49a7956 100644
--- a/src/contrib/sqoop/src/java/org/apache/hadoop/sqoop/ImportOptions.java
+++ b/src/contrib/sqoop/src/java/org/apache/hadoop/sqoop/ImportOptions.java
@@ -30,6 +30,9 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.util.ToolRunner;
+import org.apache.log4j.Category;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
 
 /**
  * Command-line arguments used by Sqoop
@@ -334,6 +337,7 @@ public class ImportOptions {
     System.out.println("--list-tables                List tables in database and exit");
     System.out.println("--list-databases             List all databases available and exit");
     System.out.println("--debug-sql (statement)      Execute 'statement' in SQL and exit");
+    System.out.println("--verbose                    Print more information while working");
     System.out.println("");
     System.out.println("Generic Hadoop command-line options:");
     ToolRunner.printGenericCommandUsage(System.out);
@@ -551,6 +555,12 @@ public class ImportOptions {
           for (i++; i < args.length; i++) {
             this.debugSqlCmd = this.debugSqlCmd + args[i] + " ";
           }
+        } else if (args[i].equals("--verbose")) {
+          // Immediately switch into DEBUG logging.
+          Category sqoopLogger =
+              Logger.getLogger(ImportOptions.class.getName()).getParent();
+          sqoopLogger.setLevel(Level.DEBUG);
+
         } else if (args[i].equals("--help")) {
           printUsage();
           throw new InvalidOptionsException("");
-- 
1.6.0.4

