You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:22:30 UTC

[sling-org-apache-sling-commons-logservice] 02/09: SLING-4563 : Log start level number on STARTLEVEL CHANGED event

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.logservice-1.0.6
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-logservice.git

commit 4634a15941ff5eb173b0fc9e2fa2c6544a3b2c10
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Apr 7 14:55:15 2015 +0000

    SLING-4563 : Log start level number on STARTLEVEL CHANGED event
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice@1671863 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                                        |  2 +-
 .../apache/sling/commons/logservice/internal/LogSupport.java   | 10 ++++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index e0ed2cc..01cbc8b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -98,7 +98,7 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
-            <version>4.0.0</version>
+            <version>4.2.0</version>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
diff --git a/src/main/java/org/apache/sling/commons/logservice/internal/LogSupport.java b/src/main/java/org/apache/sling/commons/logservice/internal/LogSupport.java
index 78bf2b6..126e654 100644
--- a/src/main/java/org/apache/sling/commons/logservice/internal/LogSupport.java
+++ b/src/main/java/org/apache/sling/commons/logservice/internal/LogSupport.java
@@ -38,6 +38,7 @@ import org.osgi.service.component.ComponentConstants;
 import org.osgi.service.log.LogEntry;
 import org.osgi.service.log.LogListener;
 import org.osgi.service.log.LogService;
+import org.osgi.service.startlevel.StartLevel;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -347,7 +348,12 @@ public class LogSupport implements SynchronousBundleListener, ServiceListener,
                 message = "FrameworkEvent PACKAGES REFRESHED";
                 break;
             case FrameworkEvent.STARTLEVEL_CHANGED:
-                message = "FrameworkEvent STARTLEVEL CHANGED";
+                // bundle must be the system bundle
+                final Bundle bundle = event.getBundle();
+                // StartLevel service is always there
+                final ServiceReference slRef = bundle.getBundleContext().getServiceReference(StartLevel.class.getName());
+                final StartLevel sl = (StartLevel) bundle.getBundleContext().getService(slRef);
+                message = "FrameworkEvent STARTLEVEL CHANGED to " + sl.getStartLevel();
                 break;
             case FrameworkEvent.WARNING:
                 message = "FrameworkEvent WARNING";
@@ -359,7 +365,7 @@ public class LogSupport implements SynchronousBundleListener, ServiceListener,
                 message = "FrameworkEvent " + event.getType();
         }
 
-        LogEntry entry = new LogEntryImpl(event.getBundle(), null, level,
+        final LogEntry entry = new LogEntryImpl(event.getBundle(), null, level,
             message, exception);
         fireLogEvent(entry);
     }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.