From 8f870c552d430177b647547e2189bdb54564b814 Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Mon, 6 Feb 2023 15:29:48 +0100 Subject: [PATCH] JAL-3878 Change Cache.log calls to Console --- src/jalview/ws2/actions/AbstractPollableTask.java | 3 ++- .../ws2/actions/alignment/AlignmentTask.java | 3 ++- .../ws2/actions/annotation/AnnotationTask.java | 5 +++-- .../client/api/AbstractWebServiceDiscoverer.java | 23 ++++++++++---------- .../ws2/client/slivka/SlivkaParamStoreFactory.java | 5 +++-- src/jalview/ws2/client/slivka/SlivkaWSClient.java | 15 +++++++------ .../ws2/client/slivka/SlivkaWSDiscoverer.java | 3 ++- .../ws2/gui/AlignmentServiceGuiHandler.java | 3 ++- src/jalview/ws2/params/SimpleParamDatastore.java | 5 +++-- 9 files changed, 37 insertions(+), 28 deletions(-) diff --git a/src/jalview/ws2/actions/AbstractPollableTask.java b/src/jalview/ws2/actions/AbstractPollableTask.java index fc3c554..e692c68 100644 --- a/src/jalview/ws2/actions/AbstractPollableTask.java +++ b/src/jalview/ws2/actions/AbstractPollableTask.java @@ -10,6 +10,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import jalview.bin.Cache; +import jalview.bin.Console; import jalview.util.ArrayUtils; import jalview.util.MathUtils; import jalview.ws.params.ArgumentI; @@ -330,7 +331,7 @@ public abstract class AbstractPollableTask implements Task job.setStatus(JobStatus.CANCELLED); } catch (IOException e) { - Cache.log.error(format("failed to cancel job %s", job.getServerJob()), e); + Console.error(format("failed to cancel job %s", job.getServerJob()), e); } } } diff --git a/src/jalview/ws2/actions/alignment/AlignmentTask.java b/src/jalview/ws2/actions/alignment/AlignmentTask.java index 96e9a12..6a0c4dd 100644 --- a/src/jalview/ws2/actions/alignment/AlignmentTask.java +++ b/src/jalview/ws2/actions/alignment/AlignmentTask.java @@ -15,6 +15,7 @@ import jalview.analysis.SeqsetUtils; import jalview.analysis.SeqsetUtils.SequenceInfo; import jalview.api.AlignViewportI; import jalview.bin.Cache; +import jalview.bin.Console; import jalview.datamodel.AlignedCodonFrame; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; @@ -81,7 +82,7 @@ class AlignmentTask extends AbstractPollableTask @Override protected List prepare() throws ServiceInputInvalidException { - Cache.log.info(format("starting alignment service %s:%s", + Console.info(format("starting alignment service %s:%s", client.getClientName(), action.getName())); SequenceI[][] conmsa = msa.getVisibleContigs(gapChar); if (conmsa == null) diff --git a/src/jalview/ws2/actions/annotation/AnnotationTask.java b/src/jalview/ws2/actions/annotation/AnnotationTask.java index 9d16400..165e132 100644 --- a/src/jalview/ws2/actions/annotation/AnnotationTask.java +++ b/src/jalview/ws2/actions/annotation/AnnotationTask.java @@ -14,6 +14,7 @@ import jalview.api.AlignViewportI; import jalview.api.FeatureColourI; import jalview.api.PollableAlignCalcWorkerI; import jalview.bin.Cache; +import jalview.bin.Console; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AnnotatedCollectionI; @@ -298,7 +299,7 @@ public class AnnotationTask implements TaskI { if (this.taskStatus != status) { - Cache.log.debug(String.format("%s status change to %s", this, status.name())); + Console.debug(String.format("%s status change to %s", this, status.name())); this.taskStatus = status; eventHandler.fireTaskStatusChanged(status); } @@ -573,7 +574,7 @@ public class AnnotationTask implements TaskI job.setStatus(JobStatus.CANCELLED); } catch (IOException e) { - Cache.log.error(String.format( + Console.error(String.format( "failed to cancel job %s", job.getServerJob()), e); } } diff --git a/src/jalview/ws2/client/api/AbstractWebServiceDiscoverer.java b/src/jalview/ws2/client/api/AbstractWebServiceDiscoverer.java index 6a81410..c2c7db1 100644 --- a/src/jalview/ws2/client/api/AbstractWebServiceDiscoverer.java +++ b/src/jalview/ws2/client/api/AbstractWebServiceDiscoverer.java @@ -11,6 +11,7 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicInteger; import jalview.bin.Cache; +import jalview.bin.Console; import jalview.ws2.actions.api.ActionI; import jalview.ws2.api.WebService; @@ -60,12 +61,12 @@ public abstract class AbstractWebServiceDiscoverer implements WebServiceDiscover valid.add(new URL(url)); } catch (MalformedURLException e) { - Cache.log.warn(String.format( + Console.warn(String.format( "Problem whilst trying to make a URL from '%s'. " + "This was probably due to malformed comma-separated-list " + "in the %s entry of ${HOME}/.jalview-properties", Objects.toString(url, ""), key)); - Cache.log.debug("Exception occurred while reading url list", e); + Console.debug("Exception occurred while reading url list", e); } } return valid; @@ -133,7 +134,7 @@ public abstract class AbstractWebServiceDiscoverer implements WebServiceDiscover @Override public synchronized final CompletableFuture>> startDiscoverer() { - Cache.log.debug("Requesting service discovery"); + Console.debug("Requesting service discovery"); while (true) { if (state.get() == AGAIN) @@ -142,23 +143,23 @@ public abstract class AbstractWebServiceDiscoverer implements WebServiceDiscover } if (state.compareAndSet(END, BEGIN) || state.compareAndSet(BEGIN, AGAIN)) { - Cache.log.debug("State changed to " + state.get()); + Console.debug("State changed to " + state.get()); final var oldTask = discoveryTask; CompletableFuture>> task = oldTask .handleAsync((_r, _e) -> { - Cache.log.info("Reloading services for " + this); + Console.info("Reloading services for " + this); fireServicesChanged(services = Collections.emptyList()); var allServices = new ArrayList>(); for (var url : getUrls()) { - Cache.log.info("Fetching list of services from " + url); + Console.info("Fetching list of services from " + url); try { allServices.addAll(fetchServices(url)); } catch (IOException e) { - Cache.log.error("Failed to get services from " + url, e); + Console.error("Failed to get services from " + url, e); } } return services = allServices; @@ -170,15 +171,15 @@ public abstract class AbstractWebServiceDiscoverer implements WebServiceDiscover // should never happen, throw exception to break the loop just in case throw new AssertionError(); if (state.compareAndSet(BEGIN, END) || state.compareAndSet(AGAIN, BEGIN)) - Cache.log.debug("Discovery ended, state is " + state.get()); + Console.debug("Discovery ended, state is " + state.get()); break; } if (services != null) fireServicesChanged(services); return null; }); - Cache.log.debug("Spawned task " + task); - Cache.log.debug("Killing task " + oldTask); + Console.debug("Spawned task " + task); + Console.debug("Killing task " + oldTask); oldTask.cancel(false); return discoveryTask = task; } @@ -199,7 +200,7 @@ public abstract class AbstractWebServiceDiscoverer implements WebServiceDiscover } catch (Exception e) { - Cache.log.warn(e); + Console.warn(e.toString(), e); } } } diff --git a/src/jalview/ws2/client/slivka/SlivkaParamStoreFactory.java b/src/jalview/ws2/client/slivka/SlivkaParamStoreFactory.java index 05e6f0c..a848798 100644 --- a/src/jalview/ws2/client/slivka/SlivkaParamStoreFactory.java +++ b/src/jalview/ws2/client/slivka/SlivkaParamStoreFactory.java @@ -13,6 +13,7 @@ import java.util.Map; import com.stevesoft.pat.NotImplementedError; import jalview.bin.Cache; +import jalview.bin.Console; import jalview.ws.params.ArgumentI; import jalview.ws.params.ParamDatastoreI; import jalview.ws.params.ParamManager; @@ -46,7 +47,7 @@ class SlivkaParamStoreFactory url = service.getUrl().toURL(); } catch (MalformedURLException e) { - Cache.log.warn("Invalid service url " + service.getUrl(), e); + Console.warn("Invalid service url " + service.getUrl(), e); } List presets = new ArrayList<>(service.getPresets().size()); for (var preset : service.getPresets()) @@ -222,7 +223,7 @@ class SlivkaParamStoreFactory builder.setDetailsUrl(service.getUrl().toURL()); } catch (MalformedURLException e) { - Cache.log.warn("invalid service url " + service.getUrl(), e); + Console.warn("invalid service url " + service.getUrl(), e); } } } \ No newline at end of file diff --git a/src/jalview/ws2/client/slivka/SlivkaWSClient.java b/src/jalview/ws2/client/slivka/SlivkaWSClient.java index d7841af..47e43c1 100644 --- a/src/jalview/ws2/client/slivka/SlivkaWSClient.java +++ b/src/jalview/ws2/client/slivka/SlivkaWSClient.java @@ -15,6 +15,7 @@ import java.util.regex.Pattern; import jalview.api.FeatureColourI; import jalview.bin.Cache; +import jalview.bin.Console; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; @@ -94,7 +95,7 @@ public class SlivkaWSClient implements WebServiceClientI } if (format == null) { - Cache.log.warn(String.format( + Console.warn(String.format( "Unknown input format %s, assuming fasta.", fileParam.getMediaType())); format = FileFormat.Fasta; @@ -200,7 +201,7 @@ public class SlivkaWSClient implements WebServiceClientI public void cancel(WebServiceJobHandle job) throws IOException, UnsupportedOperationException { - Cache.log.warn( + Console.warn( "slivka client does not support job cancellation"); } } @@ -235,7 +236,7 @@ class SlivkaAlignmentWSClient extends SlivkaWSClient return new FormatAdapter().readFile(f.getContentUrl().toString(), DataSourceType.URL, format); } - Cache.log.warn("No alignment found on the server"); + Console.warn("No alignment found on the server"); throw new IOException("no alignment found"); } @@ -270,7 +271,7 @@ class SlivkaAnnotationWSClient extends SlivkaWSClient aln, service.getId(), f.getContentUrl().toString(), DataSourceType.URL); if (annotPresent) - Cache.log.debug(format("loaded annotations for %s", service.getId())); + Console.debug(format("loaded annotations for %s", service.getId())); } else if (fmt.equalsIgnoreCase("jalview-features")) { @@ -278,13 +279,13 @@ class SlivkaAnnotationWSClient extends SlivkaWSClient DataSourceType.URL); featPresent = ff.parse(aln, colours, true); if (featPresent) - Cache.log.debug(format("loaded features for %s", service.getId())); + Console.debug(format("loaded features for %s", service.getId())); } } if (!annotPresent) - Cache.log.debug(format("no annotations found for %s", service.getId())); + Console.debug(format("no annotations found for %s", service.getId())); if (!featPresent) - Cache.log.debug(format("no features found for %s", service.getId())); + Console.debug(format("no features found for %s", service.getId())); return aln.getAlignmentAnnotation() != null ? Arrays.asList(aln.getAlignmentAnnotation()) : Collections.emptyList(); } diff --git a/src/jalview/ws2/client/slivka/SlivkaWSDiscoverer.java b/src/jalview/ws2/client/slivka/SlivkaWSDiscoverer.java index 58f6d67..70e1c94 100644 --- a/src/jalview/ws2/client/slivka/SlivkaWSDiscoverer.java +++ b/src/jalview/ws2/client/slivka/SlivkaWSDiscoverer.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.List; import jalview.bin.Cache; +import jalview.bin.Console; import jalview.ws.params.ParamManager; import jalview.ws2.actions.alignment.AlignmentAction; import jalview.ws2.actions.annotation.AnnotationAction; @@ -61,7 +62,7 @@ public class SlivkaWSDiscoverer extends AbstractWebServiceDiscoverer return services.isEmpty() ? STATUS_NO_SERVICES : STATUS_OK; } catch (IOException e) { - Cache.log.error("slivka could not retrieve services from " + url, e); + Console.error("slivka could not retrieve services from " + url, e); return STATUS_INVALID; } } diff --git a/src/jalview/ws2/gui/AlignmentServiceGuiHandler.java b/src/jalview/ws2/gui/AlignmentServiceGuiHandler.java index b484ccc..59683a7 100644 --- a/src/jalview/ws2/gui/AlignmentServiceGuiHandler.java +++ b/src/jalview/ws2/gui/AlignmentServiceGuiHandler.java @@ -14,6 +14,7 @@ import javax.swing.JInternalFrame; import javax.swing.SwingUtilities; import jalview.bin.Cache; +import jalview.bin.Console; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentOrder; @@ -226,7 +227,7 @@ class AlignmentServiceGuiHandler @Override public void taskException(TaskI source, Exception e) { - Cache.log.error(String.format("Service %s raised an exception.", service.getName()), e); + Console.error(String.format("Service %s raised an exception.", service.getName()), e); infoPanel.appendProgressText(e.getMessage()); } diff --git a/src/jalview/ws2/params/SimpleParamDatastore.java b/src/jalview/ws2/params/SimpleParamDatastore.java index 259bdca..c2123e8 100644 --- a/src/jalview/ws2/params/SimpleParamDatastore.java +++ b/src/jalview/ws2/params/SimpleParamDatastore.java @@ -14,6 +14,7 @@ import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import jalview.bin.Cache; +import jalview.bin.Console; import jalview.util.MessageManager; import jalview.ws.params.ArgumentI; import jalview.ws.params.ParamDatastoreI; @@ -80,7 +81,7 @@ public class SimpleParamDatastore implements ParamDatastoreI else { userPresets.add(new SimpleParamSet(paramSet)); - Cache.log.warn(String.format( + Console.warn(String.format( "Parameter set instance type %s is not applicable to service" + "at %s.", paramSet.getClass(), serviceUrl)); } @@ -161,7 +162,7 @@ public class SimpleParamDatastore implements ParamDatastoreI } else { - Cache.log.warn("Implementation error: no preset to delete"); + Console.warn("Implementation error: no preset to delete"); } } -- 1.7.10.2