X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Flog%2FJLogger.java;h=554b997eb52fe171568b4616c474606584f5f009;hb=efee78d45ceeb879d98fedd399a71d84a5ecd5f8;hp=7a6054e2f66e06da5d76655e19e85093b7fdd505;hpb=a2214909ebf9788ca5c6386f1f1675efe3d02b9b;p=jalview.git diff --git a/src/jalview/log/JLogger.java b/src/jalview/log/JLogger.java index 7a6054e..554b997 100644 --- a/src/jalview/log/JLogger.java +++ b/src/jalview/log/JLogger.java @@ -1,9 +1,30 @@ +/* + * 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 . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.log; +import java.util.EnumSet; 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 @@ -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 @@ -33,14 +64,14 @@ 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); + 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; }