From 9df10849f1e0734f3b7961e7fc925eb5743f02bc Mon Sep 17 00:00:00 2001 From: dgelessus <dgelessus@users.noreply.github.com> Date: Thu, 24 Aug 2023 14:51:44 +0200 Subject: [PATCH] Remove logging distinction of "with bugreport" and "without bugreport" The bug report mechanism doesn't exist anymore, so the two variants did the same thing. --- .../gef/editor/action/OpenObserverAction.java | 2 +- .../action/OpenSchedulerEventAction.java | 2 +- .../de/prob/core/ProBJobFinishedListener.java | 5 ++--- .../src/de/prob/core/PrologException.java | 2 +- .../prob/core/command/ExploreStateCommand.java | 4 ++-- .../core/command/LoadEventBModelCommand.java | 2 +- .../prob/core/internal/ServerConnection.java | 3 +-- .../translator/internal/ModelTranslator.java | 3 +-- de.prob.core/src/de/prob/logging/Logger.java | 18 ++---------------- .../eventb/ModelCheckingFinishedListener.java | 4 +--- .../de/prob/ui/eventb/OpenClassicHandler.java | 12 ++++++------ .../prob/ui/eventb/StartAnimationHandler.java | 6 +++--- .../StartDistributedModelcheckHandler.java | 5 ++--- .../ui/ltl/LtlCheckingFinishedListener.java | 4 +--- .../src/de/prob/ui/ticket/ProBLogListener.java | 2 +- 15 files changed, 26 insertions(+), 48 deletions(-) diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/OpenObserverAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/OpenObserverAction.java index 20e1197a..5715f2ac 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/OpenObserverAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/OpenObserverAction.java @@ -123,7 +123,7 @@ public class OpenObserverAction extends SelectionAction { } } else { - Logger.notifyUserWithoutBugreport("The Observer \"" + Logger.notifyUser("The Observer \"" + observer.getName() + "\" does not support a wizard."); } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/OpenSchedulerEventAction.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/OpenSchedulerEventAction.java index cf5b463c..2a26f413 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/OpenSchedulerEventAction.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/action/OpenSchedulerEventAction.java @@ -124,7 +124,7 @@ public class OpenSchedulerEventAction extends SelectionAction { } } else { - Logger.notifyUserWithoutBugreport("The Scheduler Event \"" + Logger.notifyUser("The Scheduler Event \"" + newSchedulerEvent.getName() + "\" does not support a wizard."); } diff --git a/de.prob.core/src/de/prob/core/ProBJobFinishedListener.java b/de.prob.core/src/de/prob/core/ProBJobFinishedListener.java index c38986a7..bbbe41b0 100644 --- a/de.prob.core/src/de/prob/core/ProBJobFinishedListener.java +++ b/de.prob.core/src/de/prob/core/ProBJobFinishedListener.java @@ -23,9 +23,8 @@ public abstract class ProBJobFinishedListener extends JobChangeAdapter { showResult(checkJob.getCommand(), checkJob.getAnimator()); } } else { - final String message = "The job has a wrong type. Expected ProBCommandJob but got " - + job.getClass(); - Logger.notifyUserWithoutBugreport(message); + Logger.notifyUser("The job has a wrong type. Expected ProBCommandJob but got " + + job.getClass()); } } diff --git a/de.prob.core/src/de/prob/core/PrologException.java b/de.prob.core/src/de/prob/core/PrologException.java index c5ce2077..84ae7bdf 100644 --- a/de.prob.core/src/de/prob/core/PrologException.java +++ b/de.prob.core/src/de/prob/core/PrologException.java @@ -26,7 +26,7 @@ public class PrologException extends ProBException { if (!handled) { handled = true; if (onlyWarnings) { - Logger.log(IStatus.WARNING, Logger.NOBUGREPORT, + Logger.log(IStatus.WARNING, Logger.NOTIFY_USER, this.getMessage(), this); } else { Logger.notifyUser(this.getMessage(), this); diff --git a/de.prob.core/src/de/prob/core/command/ExploreStateCommand.java b/de.prob.core/src/de/prob/core/command/ExploreStateCommand.java index 98f0b1e5..b1626326 100644 --- a/de.prob.core/src/de/prob/core/command/ExploreStateCommand.java +++ b/de.prob.core/src/de/prob/core/command/ExploreStateCommand.java @@ -87,12 +87,12 @@ public final class ExploreStateCommand implements IComposableCommand { // only show error message on SETUP_CONSTANTS and // PARTIALLY_SETUP_CONSTANTS if (unsatPropertiesExist) { - Logger.notifyUserWithoutBugreport("ProB could not find valid constants wich satisfy the properties.\n" + Logger.notifyUser("ProB could not find valid constants wich satisfy the properties.\n" + unsatPropsCommand.getUnsatPropertiesDescription()); } else if (!initialised && enabledOperations.isEmpty() && !timeoutOccured) { - Logger.notifyUserWithoutBugreport("ProB could not find valid constants/variables. This might be caused by the animation settings (e.g., Integer range or deferred set size) or by an inconsistency in the axioms."); + Logger.notifyUser("ProB could not find valid constants/variables. This might be caused by the animation settings (e.g., Integer range or deferred set size) or by an inconsistency in the axioms."); } Set<String> timeouts = new HashSet<String>( diff --git a/de.prob.core/src/de/prob/core/command/LoadEventBModelCommand.java b/de.prob.core/src/de/prob/core/command/LoadEventBModelCommand.java index 4e81cec3..9298bc22 100644 --- a/de.prob.core/src/de/prob/core/command/LoadEventBModelCommand.java +++ b/de.prob.core/src/de/prob/core/command/LoadEventBModelCommand.java @@ -104,7 +104,7 @@ public final class LoadEventBModelCommand { + " Typically this means, that your axioms are too complicated for automatic solving. " + "You might create an animation refinement using the context menu to help ProB finding a solution."; } - Logger.notifyUserWithoutBugreport(message); + Logger.notifyUser(message); } } catch (CommandException ex) { Logger.notifyUser("Event-B Model or Context could not be loaded due to an exception: " diff --git a/de.prob.core/src/de/prob/core/internal/ServerConnection.java b/de.prob.core/src/de/prob/core/internal/ServerConnection.java index a593d273..049253f2 100644 --- a/de.prob.core/src/de/prob/core/internal/ServerConnection.java +++ b/de.prob.core/src/de/prob/core/internal/ServerConnection.java @@ -165,8 +165,7 @@ public class ServerConnection implements IServerConnection { shutdown = false; } else { // This should never happen - final String message = "Tried to start a server that is already running"; - Logger.notifyUserWithoutBugreport(message); + Logger.notifyUser("Tried to start a server that is already running"); } } diff --git a/de.prob.core/src/de/prob/eventb/translator/internal/ModelTranslator.java b/de.prob.core/src/de/prob/eventb/translator/internal/ModelTranslator.java index 7cf350f8..55f274f7 100644 --- a/de.prob.core/src/de/prob/eventb/translator/internal/ModelTranslator.java +++ b/de.prob.core/src/de/prob/eventb/translator/internal/ModelTranslator.java @@ -114,8 +114,7 @@ public class ModelTranslator extends AbstractComponentTranslator { public AEventBModelParseUnit getModelAST() { if (broken) { - final String message = "The machine contains Rodin Problems. ProB will continue, but you may observe unexpected behaviour"; - Logger.notifyUserWithoutBugreport(message); + Logger.notifyUser("The machine contains Rodin Problems. ProB will continue, but you may observe unexpected behaviour"); return model; } return model; diff --git a/de.prob.core/src/de/prob/logging/Logger.java b/de.prob.core/src/de/prob/logging/Logger.java index 678c5ddc..e8d1d95b 100644 --- a/de.prob.core/src/de/prob/logging/Logger.java +++ b/de.prob.core/src/de/prob/logging/Logger.java @@ -27,8 +27,7 @@ public final class Logger { public static final int DEBUG = 0; public static final int INFO = 1; public static final int WARNING = 2; - public static final int BUGREPORT = 4; - public static final int NOBUGREPORT = 8; + public static final int NOTIFY_USER = 4; /** * Registers a new {@link ILogListener}. The listener's @@ -59,22 +58,13 @@ public final class Logger { */ public static void notifyUser(final String message, final Throwable throwable) { - log(IStatus.ERROR, BUGREPORT, message, throwable); + log(IStatus.ERROR, NOTIFY_USER, message, throwable); } public static void notifyUser(final String message) { notifyUser(message, null); } - public static void notifyUserWithoutBugreport(final String message, - final Throwable throwable) { - log(IStatus.ERROR, NOBUGREPORT, message, throwable); - } - - public static void notifyUserWithoutBugreport(final String message) { - notifyUserWithoutBugreport(message, null); - } - /** * Check a property. The method notifies the user and throws an exception if * the assertion fails. <br> @@ -151,8 +141,4 @@ public final class Logger { private static void log(final IStatus status) { Activator.getDefault().getLog().log(status); } - - public static void notifyUserAboutWarningWithoutBugreport(String string) { - log(IStatus.WARNING, NOBUGREPORT, string, null); - } } diff --git a/de.prob.ui/src/de/prob/ui/eventb/ModelCheckingFinishedListener.java b/de.prob.ui/src/de/prob/ui/eventb/ModelCheckingFinishedListener.java index 6a3b4744..d3b2c16f 100644 --- a/de.prob.ui/src/de/prob/ui/eventb/ModelCheckingFinishedListener.java +++ b/de.prob.ui/src/de/prob/ui/eventb/ModelCheckingFinishedListener.java @@ -47,9 +47,7 @@ public class ModelCheckingFinishedListener extends JobChangeAdapter { ModelCheckingJob ccJob = (ModelCheckingJob) job; showResult(ccJob.getModelCheckingResult()); } else { - final String message = "The job has a wrong type. Expected ModelCheckingJob but got " - + job.getClass(); - Logger.notifyUserWithoutBugreport(message); + Logger.notifyUser("The job has a wrong type. Expected ModelCheckingJob but got " + job.getClass()); } } diff --git a/de.prob.ui/src/de/prob/ui/eventb/OpenClassicHandler.java b/de.prob.ui/src/de/prob/ui/eventb/OpenClassicHandler.java index c5832a06..dc2f3e06 100644 --- a/de.prob.ui/src/de/prob/ui/eventb/OpenClassicHandler.java +++ b/de.prob.ui/src/de/prob/ui/eventb/OpenClassicHandler.java @@ -36,7 +36,7 @@ public class OpenClassicHandler extends AbstractHandler implements IHandler { final String prob_location = getBinaryLocation(); if (prob_location == null) { - Logger.notifyUserWithoutBugreport("You need to specify a location for" + PROB_STANDALONE_NAME +". See Preferences -> ProB Standalone."); + Logger.notifyUser("You need to specify a location for" + PROB_STANDALONE_NAME +". See Preferences -> ProB Standalone."); } else { final IEventBRoot root = getSelection(); if (root != null) { @@ -53,7 +53,7 @@ public class OpenClassicHandler extends AbstractHandler implements IHandler { runProBClassic(prob_location, tmp); } } else { - Logger.notifyUserWithoutBugreport("You need to select a context or machine to open with " + PROB_STANDALONE_NAME); + Logger.notifyUser("You need to select a context or machine to open with " + PROB_STANDALONE_NAME); } } return null; @@ -97,7 +97,7 @@ public class OpenClassicHandler extends AbstractHandler implements IHandler { new Thread(new ClassicConsole(output)).start(); } catch (IOException e) { - Logger.notifyUserWithoutBugreport("You need to specify a correct location for " + Logger.notifyUser("You need to specify a correct location for " + PROB_CLASSIC_NAME + ". See Preferences -> ProB Standalone.\n" + PROB_CLASSIC_NAME + " location: "+ probBinary + "\nModel file: " + modelFile + @@ -121,7 +121,7 @@ public class OpenClassicHandler extends AbstractHandler implements IHandler { new Thread(new ClassicConsole(voutput)).start(); vprocess.waitFor(); // this blocks Rodin if (vprocess.exitValue() != 0) { - Logger.notifyUserWithoutBugreport("Failed to start java -version. Exit code: " + vprocess.exitValue()); + Logger.notifyUser("Failed to start java -version. Exit code: " + vprocess.exitValue()); } final String[] command = {"java", "-jar", probBinary, "--machine-file", modelFile}; @@ -136,7 +136,7 @@ public class OpenClassicHandler extends AbstractHandler implements IHandler { } catch (IOException | InterruptedException e) { // } catch (IOException e) { - Logger.notifyUserWithoutBugreport("You need to specify a correct location for " + Logger.notifyUser("You need to specify a correct location for " + PROB2_NAME + ". See Preferences -> ProB Standalone.\n" + PROB2_NAME + " location: "+ probBinary + "\nModel file: " + modelFile + @@ -157,7 +157,7 @@ public class OpenClassicHandler extends AbstractHandler implements IHandler { temp = File.createTempFile("prob_", ".eventb"); temp.deleteOnExit(); } catch (IOException e) { - Logger.notifyUserWithoutBugreport("Something went wrong while saving temp file.\n" + Logger.notifyUser("Something went wrong while saving temp file.\n" + e.getLocalizedMessage()); } return temp; diff --git a/de.prob.ui/src/de/prob/ui/eventb/StartAnimationHandler.java b/de.prob.ui/src/de/prob/ui/eventb/StartAnimationHandler.java index 7ad28d59..c041a905 100644 --- a/de.prob.ui/src/de/prob/ui/eventb/StartAnimationHandler.java +++ b/de.prob.ui/src/de/prob/ui/eventb/StartAnimationHandler.java @@ -17,6 +17,7 @@ import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; @@ -92,10 +93,9 @@ public class StartAnimationHandler extends AbstractHandler implements IHandler { Logger.info(stringBuffer.toString()); LimitedLogger.getLogger().log(stringBuffer.toString(),rootElement.getElementName(), null); } else if (realError) - Logger.notifyUserWithoutBugreport(stringBuffer.toString()); + Logger.notifyUser(stringBuffer.toString()); else - Logger.notifyUserAboutWarningWithoutBugreport(stringBuffer - .toString()); + Logger.log(IStatus.WARNING, Logger.NOTIFY_USER, stringBuffer.toString(), null); } else { Animator.getAnimator().resetRodinProjectHasErrorsOrWarnings(); } diff --git a/de.prob.ui/src/de/prob/ui/eventb/StartDistributedModelcheckHandler.java b/de.prob.ui/src/de/prob/ui/eventb/StartDistributedModelcheckHandler.java index c0c52be3..2fc868c1 100644 --- a/de.prob.ui/src/de/prob/ui/eventb/StartDistributedModelcheckHandler.java +++ b/de.prob.ui/src/de/prob/ui/eventb/StartDistributedModelcheckHandler.java @@ -68,8 +68,7 @@ public class StartDistributedModelcheckHandler extends AbstractHandler implement final IFile resource = extractResource(rootElement); if (!checkErrorMarkers(resource)) { - String message = "A model/context in your project contains Errors or Warnings. This can lead to unexpected behavior (e.g. missing variables) when animating."; - Logger.notifyUserWithoutBugreport(message); + Logger.notifyUser("A model/context in your project contains Errors or Warnings. This can lead to unexpected behavior (e.g. missing variables) when animating."); } ; @@ -83,7 +82,7 @@ public class StartDistributedModelcheckHandler extends AbstractHandler implement s = new Socket("localhost", 4444); new ObjectOutputStream(s.getOutputStream()).writeObject(output); } catch (IOException e) { - Logger.notifyUserWithoutBugreport("unable to connect to master", e); + Logger.notifyUser("unable to connect to master", e); } finally { if (s != null) { try { diff --git a/de.prob.ui/src/de/prob/ui/ltl/LtlCheckingFinishedListener.java b/de.prob.ui/src/de/prob/ui/ltl/LtlCheckingFinishedListener.java index 4bef5235..d3b1b1da 100644 --- a/de.prob.ui/src/de/prob/ui/ltl/LtlCheckingFinishedListener.java +++ b/de.prob.ui/src/de/prob/ui/ltl/LtlCheckingFinishedListener.java @@ -34,9 +34,7 @@ public class LtlCheckingFinishedListener extends JobChangeAdapter { showResult(ltlJob.getModelCheckingResult()); } } else { - final String message = "The job has a wrong type. Expected LtlCheckingJob but got " - + job.getClass(); - Logger.notifyUserWithoutBugreport(message); + Logger.notifyUser("The job has a wrong type. Expected LtlCheckingJob but got " + job.getClass()); } } diff --git a/de.prob.ui/src/de/prob/ui/ticket/ProBLogListener.java b/de.prob.ui/src/de/prob/ui/ticket/ProBLogListener.java index f11341d1..8f739f95 100644 --- a/de.prob.ui/src/de/prob/ui/ticket/ProBLogListener.java +++ b/de.prob.ui/src/de/prob/ui/ticket/ProBLogListener.java @@ -27,7 +27,7 @@ public final class ProBLogListener implements ILogListener { final int code = status.getCode(); - if (code == Logger.BUGREPORT || code == Logger.NOBUGREPORT) { + if (code == Logger.NOTIFY_USER) { display.asyncExec(new Runnable() { public void run() { String title = (status.getSeverity() == IStatus.ERROR) ? "An Error occured" -- GitLab