+/*
+ * 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;
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
}
}
+ public static JLogger getLogger(Class c)
+ {
+ return getLogger(c, LogLevel.INFO);
+ }
+
+ public static JLogger getLogger(Class c, LogLevel loglevel)
+ {
+ return getLogger(c.getCanonicalName(), loglevel);
+ }
+
public static JLogger getLogger(String name)
{
return getLogger(name, LogLevel.INFO);
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);
- System.out.println(logLine);
+ String logLine = String.format("%s: %s", loglevel.toString(),
+ message);
+ jalview.bin.Console.outPrintln(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());
+ jalview.bin.Console.errPrintln(t.getMessage());
}
return false;
}
else
{
- loggerLogMessage(level, message, t);
+ loggerLogMessage(loglevel, message, t);
return true;
}
}