Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnjum Fatima2017-06-20 14:41:01 -0400
committerAnjum Fatima2017-06-20 16:27:59 -0400
commit8fe0bed86a3ffaf04a435eb95ba139b0c080e11e (patch)
tree12ccd1860076002c35a39b0c2aafe24b30d29f8b
parentb0a059a676e6245c25ab0dacb5cd40a5c704e663 (diff)
downloadrt.equinox.framework-8fe0bed86a3ffaf04a435eb95ba139b0c080e11e.tar.gz
rt.equinox.framework-8fe0bed86a3ffaf04a435eb95ba139b0c080e11e.tar.xz
rt.equinox.framework-8fe0bed86a3ffaf04a435eb95ba139b0c080e11e.zip
Bug 518476 - [log] FrameworkEvent of type WARN should be logged as type
WARN Change-Id: I5685496e9f9e4a60c48f13d6529f262d7a87150e Signed-off-by: Anjum Fatima <anjum.eclipse@gmail.com>
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/LogReaderServiceTest.java29
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/LogServiceManager.java14
2 files changed, 42 insertions, 1 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/LogReaderServiceTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/LogReaderServiceTest.java
index 6fad1d28f..02127a689 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/LogReaderServiceTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/LogReaderServiceTest.java
@@ -10,6 +10,9 @@ package org.eclipse.equinox.log.test;
import java.io.File;
import java.util.*;
+import java.util.concurrent.*;
+import org.eclipse.osgi.container.Module;
+import org.eclipse.osgi.container.ModuleContainerAdaptor.ContainerEvent;
import org.eclipse.osgi.internal.framework.EquinoxConfiguration;
import org.eclipse.osgi.launch.Equinox;
import org.eclipse.osgi.tests.OSGiTestsActivator;
@@ -167,6 +170,32 @@ public class LogReaderServiceTest extends AbstractBundleTests {
assertTrue(listener.getEntryX().getLevel() == LogService.LOG_INFO);
}
+ public void testLogFrameworkEventType() throws Exception {
+ final List<LogEntry> events = new CopyOnWriteArrayList<LogEntry>();
+ final CountDownLatch countDown = new CountDownLatch(2);
+ final Bundle b = getContext().getBundle();
+ LogListener listener = new LogListener() {
+ @Override
+ public void logged(LogEntry entry) {
+ if (b.equals(entry.getBundle())) {
+ events.add(entry);
+ countDown.countDown();
+ }
+ }
+ };
+ reader.addLogListener(listener);
+
+ //publishing an event with ERROR
+ b.adapt(Module.class).getContainer().getAdaptor().publishContainerEvent(ContainerEvent.ERROR, b.adapt(Module.class), new Exception());
+ //publishing an event with WARNING
+ b.adapt(Module.class).getContainer().getAdaptor().publishContainerEvent(ContainerEvent.WARNING, b.adapt(Module.class), new Exception());
+ countDown.await(2, TimeUnit.SECONDS);
+ assertEquals("Wrong number of events", 2, events.size());
+ assertEquals("Wrong type.", LogService.LOG_ERROR, events.get(0).getLevel());
+ assertEquals("Wrong type.", LogService.LOG_WARNING, events.get(1).getLevel());
+
+ }
+
public void testLogHistory1() throws BundleException {
File config = OSGiTestsActivator.getContext().getDataFile(getName());
Map<String, Object> configuration = new HashMap<String, Object>();
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/LogServiceManager.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/LogServiceManager.java
index 8ee51d9dc..788a5fcd6 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/LogServiceManager.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/LogServiceManager.java
@@ -130,7 +130,19 @@ public class LogServiceManager implements BundleListener, FrameworkListener, Ser
Bundle bundle = event.getBundle();
int eventType = event.getType();
@SuppressWarnings("deprecation")
- int logType = (eventType == FrameworkEvent.ERROR) ? LogService.LOG_ERROR : LogService.LOG_INFO;
+ int logType;
+ switch (eventType) {
+ case FrameworkEvent.ERROR :
+ logType = LogService.LOG_ERROR;
+ break;
+ case FrameworkEvent.WARNING :
+ logType = LogService.LOG_WARNING;
+ break;
+ default :
+ logType = LogService.LOG_INFO;
+ break;
+ }
+
if (logReaderServiceFactory.isLoggable(bundle, LOGGER_FRAMEWORK_EVENT, logType)) {
LoggerImpl logger = (LoggerImpl) systemBundleLog.getLogger(LOGGER_FRAMEWORK_EVENT);
logger.log(bundle, null, null, logType, getFrameworkEventTypeName(eventType), event.getThrowable());

Back to the top