From c1cf342ce2c996b57a56cc6147a46ea1f779eea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Kubitz?= Date: Mon, 22 Jan 2024 17:38:24 +0100 Subject: [PATCH] e4: use ILog instead of deprecated LogService constants --- .../swt/HandledContributionItem.java | 8 +-- .../swt/MenuManagerServiceFilter.java | 5 +- .../workbench/swt/PartRenderingEngine.java | 9 ++- .../ui/internal/LocaleChangeServiceImpl.java | 10 +--- .../e4/ui/internal/workbench/Activator.java | 55 ------------------- .../ReflectionContributionFactory.java | 19 +++---- .../e4/ui/internal/workbench/URIHelper.java | 4 +- .../addons/CommandProcessingAddon.java | 4 +- .../services/EvaluationReference.java | 4 +- .../ui/internal/services/LogThrottle.java | 9 ++- .../ui/tests/services/LogThrottleTest.java | 16 +++--- 11 files changed, 38 insertions(+), 105 deletions(-) diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java index 65f274027c5..2bb3024ef6f 100644 --- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java +++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java @@ -29,6 +29,7 @@ import org.eclipse.core.commands.ParameterizedCommand; import org.eclipse.core.commands.State; import org.eclipse.core.commands.common.NotDefinedException; +import org.eclipse.core.runtime.ILog; import org.eclipse.e4.core.commands.ECommandService; import org.eclipse.e4.core.commands.EHandlerService; import org.eclipse.e4.core.commands.internal.HandlerServiceImpl; @@ -38,7 +39,6 @@ import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.di.annotations.Optional; import org.eclipse.e4.ui.bindings.EBindingService; -import org.eclipse.e4.ui.internal.workbench.Activator; import org.eclipse.e4.ui.internal.workbench.ContributionsAnalyzer; import org.eclipse.e4.ui.internal.workbench.renderers.swt.IUpdateService; import org.eclipse.e4.ui.internal.workbench.swt.Policy; @@ -57,7 +57,6 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.ToolItem; -import org.osgi.service.log.LogService; public class HandledContributionItem extends AbstractContributionItem { /** @@ -246,10 +245,11 @@ protected void updateMenuItem() { String keyBindingText = null; if (parmCmd != null) { if (text == null || text.isEmpty()) { + String localizedCommandName = getModel().getCommand().getLocalizedCommandName(); try { - text = parmCmd.getName(getModel().getCommand().getLocalizedCommandName()); + text = parmCmd.getName(localizedCommandName); } catch (NotDefinedException e) { - Activator.log(LogService.LOG_DEBUG, e.getMessage(), e); + ILog.get().warn("not found: " + localizedCommandName, e); //$NON-NLS-1$ } } if (bindingService != null) { diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerServiceFilter.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerServiceFilter.java index 210bf758e69..acadf15e4e9 100644 --- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerServiceFilter.java +++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerServiceFilter.java @@ -15,11 +15,11 @@ import jakarta.inject.Inject; import java.lang.reflect.Method; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.core.runtime.SafeRunner; import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.services.log.Logger; -import org.eclipse.e4.ui.internal.workbench.Activator; import org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer; import org.eclipse.e4.ui.internal.workbench.swt.Policy; import org.eclipse.e4.ui.internal.workbench.swt.WorkbenchSWTActivator; @@ -32,7 +32,6 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Widget; -import org.osgi.service.log.LogService; public class MenuManagerServiceFilter implements Listener { public static final String NUL_MENU_ITEM = "(None Applicable)"; //$NON-NLS-1$ @@ -53,7 +52,7 @@ public static Method getAboutToShow() { .getDeclaredMethod("handleAboutToShow"); //$NON-NLS-1$ aboutToShow.setAccessible(true); } catch (SecurityException | NoSuchMethodException e) { - Activator.log(LogService.LOG_ERROR, e.getMessage(), e); + ILog.get().error(e.getMessage(), e); } } return aboutToShow; diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java index ee76de10e46..cf08b6a17b6 100644 --- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java +++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java @@ -35,6 +35,7 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.core.runtime.InvalidRegistryObjectException; import org.eclipse.core.runtime.Platform; @@ -62,7 +63,6 @@ import org.eclipse.e4.ui.css.swt.theme.IThemeManager; import org.eclipse.e4.ui.di.Focus; import org.eclipse.e4.ui.di.PersistState; -import org.eclipse.e4.ui.internal.workbench.Activator; import org.eclipse.e4.ui.internal.workbench.E4Workbench; import org.eclipse.e4.ui.model.application.MApplication; import org.eclipse.e4.ui.model.application.MApplicationElement; @@ -106,7 +106,6 @@ import org.eclipse.ui.testing.TestableObject; import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; -import org.osgi.service.log.LogService; import org.w3c.dom.Element; import org.w3c.dom.css.CSSStyleDeclaration; @@ -1372,7 +1371,7 @@ public void setClassnameAndId(Object widget, String classname, String id) { cssEngine.parseStyleSheet(stream); } } catch (IOException e) { - Activator.log(LogService.LOG_ERROR, e.getMessage(), e); + ILog.get().error(e.getMessage(), e); } Shell[] shells = display.getShells(); @@ -1382,7 +1381,7 @@ public void setClassnameAndId(Object widget, String classname, String id) { s.reskin(SWT.ALL); cssEngine.applyStyles(s, true); } catch (Exception e) { - Activator.log(LogService.LOG_ERROR, e.getMessage(), e); + ILog.get().error(e.getMessage(), e); } finally { s.setRedraw(true); } @@ -1470,7 +1469,7 @@ protected Set getThemeRelatedPreferences() { bundleIDs.add(nameSpace); } } catch (InvalidRegistryObjectException e) { - Activator.log(LogService.LOG_ERROR, e.getMessage(), e); + ILog.get().error( e.getMessage(), e); } } } diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/LocaleChangeServiceImpl.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/LocaleChangeServiceImpl.java index 07c820e13d1..1c0ca43ce0b 100644 --- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/LocaleChangeServiceImpl.java +++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/LocaleChangeServiceImpl.java @@ -17,8 +17,8 @@ import jakarta.inject.Inject; import java.util.List; import java.util.Locale; +import org.eclipse.core.runtime.ILog; import org.eclipse.e4.core.contexts.IEclipseContext; -import org.eclipse.e4.core.di.annotations.Optional; import org.eclipse.e4.core.internal.services.ResourceBundleHelper; import org.eclipse.e4.core.services.events.IEventBroker; import org.eclipse.e4.core.services.nls.ILocaleChangeService; @@ -34,7 +34,6 @@ import org.eclipse.e4.ui.model.application.ui.basic.MWindow; import org.eclipse.e4.ui.model.application.ui.menu.MMenu; import org.eclipse.e4.ui.model.application.ui.menu.MToolBar; -import org.osgi.service.log.LogService; /** * Default implementation of {@link ILocaleChangeService} that changes the {@link Locale} in the @@ -50,9 +49,6 @@ public class LocaleChangeServiceImpl implements ILocaleChangeService { @Inject IEventBroker broker; - @Inject - @Optional - LogService logService; /** * Create a new {@link LocaleChangeServiceImpl} for the given {@link IEclipseContext}. @@ -97,9 +93,7 @@ public void changeApplicationLocale(String localeString) { } catch (Exception e) { // performing a locale update failed // there is no locale change performed - if (logService != null) - logService.log(LogService.LOG_ERROR, e.getMessage() - + " - No Locale change will be performed."); //$NON-NLS-1$ + ILog.get().error("No Locale change performed.", e); //$NON-NLS-1$ } } diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/Activator.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/Activator.java index a750567a038..c36daf0a461 100644 --- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/Activator.java +++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/Activator.java @@ -41,9 +41,7 @@ import org.osgi.framework.Bundle; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; -import org.osgi.service.log.LogService; import org.osgi.util.tracker.BundleTracker; -import org.osgi.util.tracker.ServiceTracker; /** * BundleActivator to access the required OSGi services. @@ -58,8 +56,6 @@ public class Activator implements BundleActivator, DebugOptionsListener { private BundleContext context; - private ServiceTracker logTracker; - /** Tracks all bundles which are in the state: RESOLVED, STARTING, ACTIVE or STOPPING. */ private BundleTracker> resolvedBundles; @@ -109,10 +105,6 @@ public void start(BundleContext context) throws Exception { @Override public void stop(BundleContext context) throws Exception { - if (logTracker != null) { - logTracker.close(); - logTracker = null; - } if (resolvedBundles != null) { // the close of the BundleTracker will also remove all entries form the BundleFinder resolvedBundles.close(); @@ -141,51 +133,4 @@ public DebugTrace getTrace() { public static void trace(String option, String msg, Throwable error) { activator.getTrace().trace(option, msg, error); } - - public LogService getLogService() { - LogService logService = null; - if (logTracker != null) { - logService = logTracker.getService(); - } else if (context != null) { - logTracker = new ServiceTracker<>(context, - LogService.class.getName(), null); - logTracker.open(); - logService = logTracker.getService(); - } - if (logService == null) { - throw new IllegalStateException("No LogService is available."); //$NON-NLS-1$ - } - return logService; - } - - /** - * @param level - * one from {@code LogService} constants - * @see LogService#LOG_ERROR - * @see LogService#LOG_WARNING - * @see LogService#LOG_INFO - * @see LogService#LOG_DEBUG - */ - public static void log(int level, String message) { - LogService logService = activator.getLogService(); - if (logService != null) { - logService.log(level, message); - } - } - - /** - * @param level - * one from {@code LogService} constants - * @see LogService#LOG_ERROR - * @see LogService#LOG_WARNING - * @see LogService#LOG_INFO - * @see LogService#LOG_DEBUG - */ - public static void log(int level, String message, Throwable exception) { - LogService logService = activator.getLogService(); - if (logService != null) { - logService.log(level, message, exception); - } - } - } diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ReflectionContributionFactory.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ReflectionContributionFactory.java index db49a0b5b70..4910d0501d1 100644 --- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ReflectionContributionFactory.java +++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ReflectionContributionFactory.java @@ -16,6 +16,7 @@ package org.eclipse.e4.ui.internal.workbench; import java.util.Map; +import org.eclipse.core.runtime.ILog; import org.eclipse.e4.core.contexts.ContextInjectionFactory; import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.di.InjectionException; @@ -23,7 +24,6 @@ import org.eclipse.e4.core.services.contributions.IContributionFactorySpi; import org.eclipse.emf.common.util.URI; import org.osgi.framework.Bundle; -import org.osgi.service.log.LogService; /** * Create the contribution factory. @@ -48,10 +48,9 @@ private Object doCreate(String uriString, IEclipseContext context, IEclipseConte } // translate old-style platform:/plugin/ class specifiers into new-style bundleclass:// URIs if (uriString.startsWith("platform:/plugin/")) { //$NON-NLS-1$ - Activator.log(LogService.LOG_ERROR, - "platform-style URIs deprecated for referencing types: " + uriString); //$NON-NLS-1$ + ILog.get().error("platform-style URIs deprecated for referencing types: " + uriString); //$NON-NLS-1$ uriString = uriString.replace("platform:/plugin/", "bundleclass://"); //$NON-NLS-1$ //$NON-NLS-2$ - Activator.log(LogService.LOG_ERROR, "URI rewritten as: " + uriString); //$NON-NLS-1$ + ILog.get().error("URI rewritten as: " + uriString); //$NON-NLS-1$ } URI uri = URI.createURI(uriString); Bundle bundle = getBundle(uri); @@ -60,7 +59,7 @@ private Object doCreate(String uriString, IEclipseContext context, IEclipseConte contribution = createFromBundle(bundle, context, staticContext, uri); } else { contribution = null; - Activator.log(LogService.LOG_ERROR, "Unable to retrieve the bundle from the URI: " //$NON-NLS-1$ + ILog.get().error( "Unable to retrieve the bundle from the URI: " //$NON-NLS-1$ + uriString); } return contribution; @@ -74,7 +73,7 @@ protected Object createFromBundle(Bundle bundle, IEclipseContext context, IContributionFactorySpi factory = (IContributionFactorySpi) languages.get(prefix); if (factory == null) { String message = "Unsupported contribution factory type '" + prefix + "'"; //$NON-NLS-1$ //$NON-NLS-2$ - Activator.log(LogService.LOG_ERROR, message); + ILog.get().error( message); return null; } StringBuilder resource = new StringBuilder(uri.segment(1)); @@ -96,18 +95,18 @@ protected Object createFromBundle(Bundle bundle, IEclipseContext context, if (contribution == null) { String message = "Unable to load class '" + clazz + "' from bundle '" //$NON-NLS-1$ //$NON-NLS-2$ + bundle.getBundleId() + "'"; //$NON-NLS-1$ - Activator.log(LogService.LOG_ERROR, message, new Exception()); + ILog.get().error( message, new Exception()); } } catch (ClassNotFoundException e) { contribution = null; String message = "Unable to load class '" + clazz + "' from bundle '" //$NON-NLS-1$ //$NON-NLS-2$ + bundle.getBundleId() + "'"; //$NON-NLS-1$ - Activator.log(LogService.LOG_ERROR, message, e); + ILog.get().error( message, e); } catch (InjectionException e) { contribution = null; String message = "Unable to create class '" + clazz + "' from bundle '" //$NON-NLS-1$ //$NON-NLS-2$ + bundle.getBundleId() + "'"; //$NON-NLS-1$ - Activator.log(LogService.LOG_ERROR, message, e); + ILog.get().error( message, e); } } return contribution; @@ -115,7 +114,7 @@ protected Object createFromBundle(Bundle bundle, IEclipseContext context, protected Bundle getBundle(URI platformURI) { if (platformURI.authority() == null) { - Activator.log(LogService.LOG_ERROR, "Failed to get bundle for: " + platformURI); //$NON-NLS-1$ + ILog.get().error( "Failed to get bundle for: " + platformURI); //$NON-NLS-1$ return null; } return Activator.getDefault().getBundleForName(platformURI.authority()); diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/URIHelper.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/URIHelper.java index fcfbe3bff3c..87aa2c853fc 100644 --- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/URIHelper.java +++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/URIHelper.java @@ -19,10 +19,10 @@ import java.net.URI; import java.net.URISyntaxException; import org.eclipse.core.runtime.IContributor; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.spi.RegistryContributor; import org.osgi.framework.Bundle; import org.osgi.framework.wiring.BundleRevision; -import org.osgi.service.log.LogService; /** * Collection of URI-related utilities @@ -86,7 +86,7 @@ static public Bundle getBundle(String contributorURI) { try { uri = new URI(contributorURI); } catch (URISyntaxException e) { - Activator.log(LogService.LOG_ERROR, "Invalid contributor URI: " + contributorURI); //$NON-NLS-1$ + ILog.get().error("Invalid contributor URI: " + contributorURI); //$NON-NLS-1$ return null; } if (!PLATFORM_SCHEMA.equals(uri.getScheme())) diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/addons/CommandProcessingAddon.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/addons/CommandProcessingAddon.java index 52b14fa4578..fa39639918c 100644 --- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/addons/CommandProcessingAddon.java +++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/addons/CommandProcessingAddon.java @@ -28,6 +28,7 @@ import org.eclipse.core.commands.IParameter; import org.eclipse.core.commands.ParameterType; import org.eclipse.core.commands.common.NotDefinedException; +import org.eclipse.core.runtime.ILog; import org.eclipse.e4.core.commands.ECommandService; import org.eclipse.e4.core.commands.internal.HandlerServiceImpl; import org.eclipse.e4.core.services.events.IEventBroker; @@ -163,8 +164,7 @@ public void commandManagerChanged(CommandManagerEvent commandManagerEvent) { categoryModel); application.getCommands().add(createdCommand); } catch (NotDefinedException e) { - Activator.getDefault().getLogService() - .log(0, "Failed to create command " + commandId, e); //$NON-NLS-1$ + ILog.get().error("Failed to create command " + commandId, e); //$NON-NLS-1$ } } } diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/EvaluationReference.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/EvaluationReference.java index a3aa1979206..7929286ccc6 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/EvaluationReference.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/EvaluationReference.java @@ -14,8 +14,6 @@ package org.eclipse.ui.internal.services; -import static org.osgi.service.log.LogLevel.ERROR; - import org.eclipse.core.expressions.EvaluationResult; import org.eclipse.core.expressions.Expression; import org.eclipse.core.expressions.IEvaluationContext; @@ -78,7 +76,7 @@ public boolean evaluate(IEvaluationContext context) { cache = expression.evaluate(context) != EvaluationResult.FALSE; } catch (CoreException e) { String message = "Failed to evaluate: " + expression; //$NON-NLS-1$ - boolean logged = logThrottle.log(ERROR.ordinal(), message, e); + boolean logged = logThrottle.error(message, e); if (!logged && Policy.DEBUG_CMDS) { Activator.trace(Policy.DEBUG_CMDS_FLAG, message, e); } diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/LogThrottle.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/LogThrottle.java index 9b34f92ec63..a74b88cf367 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/LogThrottle.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/services/LogThrottle.java @@ -16,7 +16,7 @@ import java.text.MessageFormat; import java.util.HashMap; import java.util.concurrent.LinkedBlockingQueue; -import org.eclipse.e4.ui.internal.workbench.Activator; +import org.eclipse.core.runtime.ILog; import org.osgi.service.log.LogLevel; /** @@ -50,19 +50,18 @@ public LogThrottle(int queueSize, int throttleValue) { /** * Logs a message with flood protection. * - * @param logLevel any ordinal of @link(LogLevel) * @param message the message to log, may not be null. * @param e the exception to log or {@code null} * @return true if the message was logged, false otherwise. * @see LogLevel */ - public boolean log(int logLevel, String message, Throwable e) { + public boolean error(String message, Throwable e) { int store = store(message); if (store <= fThrottleValue) { - Activator.log(logLevel, message, e); + ILog.get().error(message, e); } if (store == fThrottleValue) { - Activator.log(LogLevel.WARN.ordinal(), fThrottleMessage); + ILog.get().warn(fThrottleMessage); } return store <= fThrottleValue; } diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/services/LogThrottleTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/services/LogThrottleTest.java index 8a719c8f920..71486629e47 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/services/LogThrottleTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/services/LogThrottleTest.java @@ -58,7 +58,7 @@ public void test_log_simple() { LogThrottle throttle = new LogThrottle(QUEUE_SIZE, 1); // when - throttle.log(LogLevel.ERROR.ordinal(), "foo", null); + throttle.error("foo", null); // then verify(logListener, times(1)).logged(logEntryMatcher(LogLevel.ERROR, "foo")); @@ -71,7 +71,7 @@ public void test_log_throttled() { // when for (int i = 0; i < 5; i++) { - throttle.log(LogLevel.ERROR.ordinal(), "foo", null); + throttle.error("foo", null); } // then @@ -84,25 +84,25 @@ public void test_log_throttled() { public void test_log_setThrottle() { // given LogThrottle throttle = new LogThrottle(QUEUE_SIZE, 3); - + // when for (int i = 0; i < 5; i++) { - throttle.log(LogLevel.ERROR.ordinal(), "foo", null); + throttle.error("foo", null); } - + // then verify(logListener, atMost(3)).logged(logEntryMatcher(LogLevel.ERROR, "foo")); verify(logListener, atMost(1)) .logged(logEntryMatcher(LogLevel.WARN, "The previous message has been throttled.*")); - + // and throttle.setThrottle(2); // when for (int i = 0; i < 5; i++) { - throttle.log(LogLevel.ERROR.ordinal(), "bar", null); + throttle.error("bar", null); } - + // then verify(logListener, atMost(2)).logged(logEntryMatcher(LogLevel.ERROR, "bar"));