JAL-629 Change all stdout and stderr output to use Console.outPrintln and Console...
[jalview.git] / src / jalview / log / JLogger.java
index 2f4fafb..554b997 100644 (file)
@@ -1,5 +1,26 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.log;
 
+import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -26,6 +47,16 @@ public abstract class JLogger implements JLoggerI
   protected abstract void loggerLogMessage(LogLevel level, String message,
           Throwable t);
 
+  public static boolean isLevel(String levelString)
+  {
+    for (LogLevel l : EnumSet.allOf(LogLevel.class))
+    {
+      if (l.name().equals(levelString))
+        return true;
+    }
+    return false;
+  }
+
   public static LogLevel toLevel(String levelString)
   {
     try
@@ -40,7 +71,7 @@ public abstract class JLogger implements JLoggerI
 
   public static JLogger getLogger(Class c)
   {
-    return getLogger(c);
+    return getLogger(c, LogLevel.INFO);
   }
 
   public static JLogger getLogger(Class c, LogLevel loglevel)
@@ -107,13 +138,13 @@ public abstract class JLogger implements JLoggerI
     {
       String logLine = String.format("%s: %s", loglevel.toString(),
               message);
-      System.out.println(logLine);
+      jalview.bin.Console.outPrintln(logLine);
       if (t != null)
       {
         if (loglevel.compareTo(LogLevel.DEBUG) <= 0)
           t.printStackTrace(System.err);
         else
-          System.err.println(t.getMessage());
+          jalview.bin.Console.errPrintln(t.getMessage());
       }
       return false;
     }