Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-03-31 12:32:19 -0400
committerThomas Watson2017-06-16 08:38:08 -0400
commit9566e37ecdca4821070a7a45836264566c9f3c37 (patch)
treeb0eb0cfd6a423b8fb79d08efe556f7c245843fa4 /bundles
parent6ef43b45c7ae11c1859cf969d8e11f2dc53689cc (diff)
downloadrt.equinox.framework-9566e37ecdca4821070a7a45836264566c9f3c37.tar.gz
rt.equinox.framework-9566e37ecdca4821070a7a45836264566c9f3c37.tar.xz
rt.equinox.framework-9566e37ecdca4821070a7a45836264566c9f3c37.zip
Bug 486950 - [osgi R7] log service is being updated
Implement new getLogger method that takes a bundle Change-Id: Ibd50163c2390c5853274cfa72662fd775c7f02ec Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceImpl.java9
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/service/log/LoggerFactory.java26
2 files changed, 35 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceImpl.java
index a2dd568d6..cc4d186cd 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceImpl.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceImpl.java
@@ -71,6 +71,15 @@ public class ExtendedLogServiceImpl implements ExtendedLogService {
return bundleLogService.getLogger(name);
}
+ @Override
+ public <L extends org.osgi.service.log.Logger> L getLogger(Bundle logBundle, String name, Class<L> loggerType) {
+ if (logBundle == null || (logBundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) != 0) {
+ throw new IllegalArgumentException("The bundle is not resolved: " + logBundle); //$NON-NLS-1$
+ }
+ ExtendedLogService bundleLogService = factory.getLogService(logBundle);
+ return bundleLogService.getLogger(name, loggerType);
+ }
+
public String getName() {
return getLogger((String) null).getName();
}
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/service/log/LoggerFactory.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/service/log/LoggerFactory.java
index 3d17ce95f..61d256f03 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/service/log/LoggerFactory.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/service/log/LoggerFactory.java
@@ -17,6 +17,7 @@
package org.osgi.service.log;
import org.osgi.annotation.versioning.ProviderType;
+import org.osgi.framework.Bundle;
/**
* Logger Factory service for logging information.
@@ -100,4 +101,29 @@ public interface LoggerFactory {
* Logger type.
*/
<L extends Logger> L getLogger(Class< ? > clazz, Class<L> loggerType);
+
+ /**
+ * Return the {@link Logger} of the specified type named with the specified
+ * name for the specified bundle.
+ * <p>
+ * This method is not normally used. The other {@code getLogger} methods
+ * return a {@link Logger} associated with the bundle used to obtain this
+ * Logger Factory service. This method is used to obtain a {@link Logger}
+ * for the specified bundle which may be useful to code which is logging on
+ * behalf of another bundle.
+ *
+ * @param <L> The Logger type.
+ * @param bundle The bundle associated with the Logger.
+ * @param name The name to use for the logger name.
+ * @param loggerType The type of Logger. Can be {@link Logger} or
+ * {@link FormatterLogger}.
+ * @return The {@link Logger} or {@link FormatterLogger} named with the
+ * specified name for the specified bundle. If the name parameter is
+ * equal to {@link Logger#ROOT_LOGGER_NAME}, then the root logger is
+ * returned.
+ * @throws IllegalArgumentException If the specified type is not a supported
+ * Logger type or the specified Bundle is not a resolved bundle.
+ */
+ <L extends Logger> L getLogger(Bundle bundle, String name,
+ Class<L> loggerType);
}

Back to the top