X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Flog%2FJLogger.java;h=45dde90cf0c04409b630377493a353581259a5c0;hb=63fe1298bc071a5cbe84e14a3cecf1b481ff8b48;hp=776db603ed00d04c765ec3031c69b47125f16c38;hpb=cb8e52fbbc5f725e3f7f48c672cdddb0690bd978;p=jalview.git diff --git a/src/jalview/log/JLogger.java b/src/jalview/log/JLogger.java index 776db60..45dde90 100644 --- a/src/jalview/log/JLogger.java +++ b/src/jalview/log/JLogger.java @@ -1,3 +1,23 @@ +/* + * 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.HashMap; @@ -38,6 +58,16 @@ public abstract class JLogger implements JLoggerI } } + 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; } }