]> www.vanbest.org Git - tv_grab_nl_java/commitdiff
Command line --log-level aangepast voor log4j log levels
authorJan-Pascal van Best <janpascal@vanbest.org>
Tue, 1 May 2012 11:27:59 +0000 (13:27 +0200)
committerJan-Pascal van Best <janpascal@vanbest.org>
Tue, 1 May 2012 11:27:59 +0000 (13:27 +0200)
README
src/main/java/org/vanbest/xmltv/Config.java
src/main/java/org/vanbest/xmltv/Main.java

diff --git a/README b/README
index 750a59697183ecff9caa3c0f166c2931017a4009..63d074c34cf0a23e9fc9005c4aed273846d1ff37 100644 (file)
--- a/README
+++ b/README
@@ -111,8 +111,8 @@ Beschikbare opties:
 --configure           Interactive configuration
 --output <arg>        Set xlmtv output filename
 --quiet               Be quiet
---log-level           Zet het logging-level. Defaultwaarde is 1; hogere waarde
-                      kan (veel) meer logging opleveren
+--log-level           Zet het logging-level. Defaultwaarde is INFO, andere mogelijkheden zijn
+                                         ERROR,WARN,INFO,DEBUG en TRACE
 --offset <arg>        Start day for grabbing (0=today)
 --days <arg>          Number of days to grab
 
index ce883580f2ef69fd2f58c813df07ea234cfdc9e7..3177e05d6aeef09680bf09915c8691641a920cd6 100644 (file)
@@ -38,12 +38,7 @@ import org.apache.log4j.Logger;
 
 public class Config {
        //constants
-       public static final int LOG_INFO = 0x0001;
-       public static final int LOG_DEBUG = 0x0005;
-       public static final int LOG_JSON = 0x0100;
-       private final static int LOG_PROGRAMME_INFO = 0x0200;
        private final static int CURRENT_FILE_FORMAT=4;
-       public final static int LOG_DEFAULT = LOG_INFO;
 
        // in config file
        public int niceMilliseconds;
@@ -55,11 +50,10 @@ public class Config {
        
        // not stored (yet)
        public boolean joinKijkwijzerRatings = true;
+       boolean fetchDetails = true;
        
        // command-line options
        boolean quiet = false;
-       public int logLevel = LOG_DEFAULT;
-       boolean fetchDetails = true;
        
        String project_version;
        String build_time;
@@ -301,14 +295,6 @@ public class Config {
                }
                return result;
        }
-       
-       public boolean logJSON() {
-               return (logLevel & LOG_JSON) != 0;
-       }
-
-       public boolean logProgrammes() {
-               return (logLevel & LOG_PROGRAMME_INFO) != 0;
-       }
 
        public void setCacheFile(String cacheFile) {
                cacheDbHandle = "jdbc:hsqldb:file:"+cacheFile;
index fc3dec26edaf763c880557c0100a61c46f08a23f..a633079560a6ee7e6a715c50735fcfcee8dc8f4e 100644 (file)
@@ -344,7 +344,7 @@ public class Main {
                                .addOption(OptionBuilder
                                                .withLongOpt("log-level")
                                                .hasArg()
-                                               .withDescription("Set log level (0x0100=JSON)")
+                                               .withDescription("Set log level (ERROR,WARN,INFO,DEBUG,TRACE)")
                                                .create())
                                .addOption(OptionBuilder
                                                .withLongOpt("license")
@@ -387,11 +387,10 @@ public class Main {
                        this.outputWriter = new PrintStream( new FileOutputStream(line.getOptionValue("output")));
                }
                if (line.hasOption("log-level")) {
-                       config.logLevel = Integer.parseInt(line.getOptionValue("log-level"));
-                       if (config.quiet) config.logLevel = 0;
-                        // TODO: make distinction between levels for console and
-                        // file appenders
-                        logger.getRootLogger().setLevel(Level.toLevel(config.logLevel, Level.INFO));
+                       String arg = line.getOptionValue("log-level");
+            // TODO: make distinction between levels for console and
+            // file appenders
+            Logger.getRootLogger().setLevel(Level.toLevel(arg, Level.INFO));
                }
                if (line.hasOption("cache")) {
                        config.setCacheFile(line.getOptionValue("cache"));