Merge branch 'update/JAL-3949_jalview_bin_Console_to_cure_sanity_even_more' of https...
authorBen Soares <b.soares@dundee.ac.uk>
Fri, 11 Feb 2022 15:43:34 +0000 (15:43 +0000)
committerBen Soares <b.soares@dundee.ac.uk>
Fri, 11 Feb 2022 15:43:34 +0000 (15:43 +0000)
1  2 
src/jalview/io/vamsas/DatastoreItem.java
src/jalview/log/JLogger.java

@@@ -25,7 -25,7 +25,7 @@@ import java.util.Hashtable
  import java.util.IdentityHashMap;
  import java.util.Vector;
  
- import jalview.bin.Cache;
+ import jalview.bin.Console;
  import jalview.io.VamsasAppDatastore;
  import jalview.log.JLoggerLog4j;
  import jalview.util.MessageManager;
@@@ -61,7 -61,7 +61,7 @@@ public abstract class DatastoreIte
     * shared log instance
     */
    protected static JLoggerLog4j log = JLoggerLog4j
 -          .getLogger(DatastoreItem.class.getCanonicalName());
 +          .getLogger(DatastoreItem.class);
  
    /**
     * note: this is taken verbatim from jalview.io.VamsasAppDatastore
@@@ -74,9 -74,9 +74,9 @@@
      {
        return cdoc.getObject((VorbaId) jv2vobj.get(jvobj));
      }
-     if (Cache.isDebugEnabled())
+     if (Console.isDebugEnabled())
      {
-       Cache.debug(
+       Console.debug(
                "Returning null VorbaID binding for jalview object " + jvobj);
      }
      return null;
@@@ -95,7 -95,7 +95,7 @@@
      if (id == null)
      {
        id = cdoc.registerObject(vobj);
-       Cache.debug(
+       Console.debug(
                "Registering new object and returning null for getvObj2jv");
        return null;
      }
        if (id == null || vobj.getVorbaId() == null
                || cdoc.getObject(id) != vobj)
        {
-         Cache.error("Failed to get id for "
+         Console.error("Failed to get id for "
                  + (vobj.isRegisterable() ? "registerable"
                          : "unregisterable")
                  + " object " + vobj);
      if (vobj2jv.containsKey(vobj.getVorbaId())
              && !(vobj2jv.get(vobj.getVorbaId())).equals(jvobj))
      {
-       Cache.debug(
+       Console.debug(
                "Warning? Overwriting existing vamsas id binding for "
                        + vobj.getVorbaId(),
                new Exception(MessageManager.getString(
      else if (jv2vobj.containsKey(jvobj)
              && !((VorbaId) jv2vobj.get(jvobj)).equals(vobj.getVorbaId()))
      {
-       Cache.debug(
+       Console.debug(
                "Warning? Overwriting existing jalview object binding for "
                        + jvobj,
                new Exception(MessageManager.getString(
       * bindjvvobj")); }
       */
      // we just update the hash's regardless!
-     Cache.debug("Binding " + vobj.getVorbaId() + " to " + jvobj);
+     Console.debug("Binding " + vobj.getVorbaId() + " to " + jvobj);
      vobj2jv.put(vobj.getVorbaId(), jvobj);
      // JBPNote - better implementing a hybrid invertible hash.
      jv2vobj.put(jvobj, vobj.getVorbaId());
    {
      if (this.jvobj != null && this.vobj != null)
      {
-       Cache.debug("updating dsobj registry. (" + this.getClass().getName()
+       Console.debug("updating dsobj registry. (" + this.getClass().getName()
                + ")");
      }
      this.jvobj = jvobj;
@@@ -3,7 -3,7 +3,7 @@@ 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
        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);
        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());
      }
      else
      {
 -      loggerLogMessage(level, message, t);
 +      loggerLogMessage(loglevel, message, t);
        return true;
      }
    }