JAL-3746 apply copyright to source
[jalview.git] / src / jalview / log / JLogger.java
index 03b664a..45dde90 100644 (file)
@@ -1,9 +1,29 @@
+/*
+ * 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.HashMap;
 import java.util.Map;
 
-import jalview.bin.Cache;
+import jalview.bin.Console;
 import jalview.util.Platform;
 
 public abstract class JLogger implements JLoggerI
@@ -33,11 +53,21 @@ public abstract class JLogger implements JLoggerI
       return LogLevel.valueOf(levelString);
     } catch (IllegalArgumentException e)
     {
-      Cache.error("Could not parse LogLevel '" + levelString + "'", e);
+      Console.error("Could not parse LogLevel '" + levelString + "'", e);
       return LogLevel.INFO;
     }
   }
 
+  public static JLogger getLogger(Class c)
+  {
+    return getLogger(c);
+  }
+
+  public static JLogger getLogger(Class c, LogLevel loglevel)
+  {
+    return getLogger(c.getCanonicalName(), loglevel);
+  }
+
   public static JLogger getLogger(String name)
   {
     return getLogger(name, LogLevel.INFO);
@@ -87,15 +117,20 @@ public abstract class JLogger implements JLoggerI
       loggerSetLevel(level);
   }
 
-  private boolean println(LogLevel level, String message, Throwable t)
+  private boolean println(LogLevel loglevel, String message, Throwable t)
   {
+    if (loglevel.compareTo(this.level) < 0)
+    {
+      return false;
+    }
     if (!loggerExists() || Platform.isJS())
     {
-      String logLine = String.format("%s: %s", level.toString(), message);
+      String logLine = String.format("%s: %s", loglevel.toString(),
+              message);
       System.out.println(logLine);
       if (t != null)
       {
-        if (level.compareTo(LogLevel.DEBUG) <= 0)
+        if (loglevel.compareTo(LogLevel.DEBUG) <= 0)
           t.printStackTrace(System.err);
         else
           System.err.println(t.getMessage());
@@ -104,7 +139,7 @@ public abstract class JLogger implements JLoggerI
     }
     else
     {
-      loggerLogMessage(level, message, t);
+      loggerLogMessage(loglevel, message, t);
       return true;
     }
   }