tjwatson commented on a change in pull request #22:
URL: https://github.com/apache/felix-dev/pull/22#discussion_r432704403



##########
File path: log/src/main/java/org/apache/felix/log/LogServiceImpl.java
##########
@@ -137,29 +136,13 @@ public Logger getLogger(Class<?> clazz) {
 
     @Override
     public <L extends Logger> L getLogger(Class<?> clazz, Class<L> loggerType) 
{
-        LogService logService = getLogService(clazz);
-        return logService.getLogger(clazz.getName(), loggerType);
+        Bundle bundle = FrameworkUtil.getBundle(clazz);
+        return m_loggerAdminImpl.getLogger(bundle, clazz.getName(), 
loggerType);
     }
 
     @Override
     public <L extends Logger> L getLogger(Bundle bundle, String name, Class<L> 
loggerType) {
-        LogService logService = getLogService(bundle);
-        return logService.getLogger(name, loggerType);
-    }
-
-    private LogService getLogService(Bundle bundle) {
-        if (((bundle.getState() & Bundle.ACTIVE) != Bundle.ACTIVE) &&
-            ((bundle.getState() & Bundle.RESOLVED) != Bundle.RESOLVED)) {
-            throw new IllegalArgumentException("Bundle " + bundle + " is not 
resolved.");
-        }
-        BundleContext bundleContext = bundle.getBundleContext();
-        ServiceReference<LogService> serviceReference = 
bundleContext.getServiceReference(LogService.class);
-        return bundleContext.getService(serviceReference);
-    }
-
-    private LogService getLogService(Class<?> clazz) {
-        Bundle bundle = FrameworkUtil.getBundle(clazz);
-        return getLogService(bundle);
+        return m_loggerAdminImpl.getLogger(bundle, name, loggerType);

Review comment:
       I think this should work

##########
File path: log/src/main/java/org/apache/felix/log/LogServiceImpl.java
##########
@@ -126,8 +125,8 @@ public Logger getLogger(String name) {
 
     @Override
     public Logger getLogger(Class<?> clazz) {
-        LogService logService = getLogService(clazz);
-        return logService.getLogger(clazz.getName());
+        Bundle bundle = FrameworkUtil.getBundle(clazz);

Review comment:
       The class here is only to get the name of the logger.  It is not 
intended to get a logger for another bundle.

##########
File path: log/src/main/java/org/apache/felix/log/LogServiceImpl.java
##########
@@ -137,29 +136,13 @@ public Logger getLogger(Class<?> clazz) {
 
     @Override
     public <L extends Logger> L getLogger(Class<?> clazz, Class<L> loggerType) 
{
-        LogService logService = getLogService(clazz);
-        return logService.getLogger(clazz.getName(), loggerType);
+        Bundle bundle = FrameworkUtil.getBundle(clazz);

Review comment:
       Same comment about the class param




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to