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/10/18 23:18:42 UTC

[sling-org-apache-sling-commons-logservice] branch master created (now 831c4b7)

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

rombert pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-logservice.git.


      at 831c4b7  SLING-7167 Adjust READMEs

This branch includes the following new commits:

     new 22f01e3  SLING-2224 Create new LogService bundle
     new 3001661  SLING-2235 Use size limited, access ordered cache for bundle loggers and remove entries for uninstalled bundles
     new c1ff039  [maven-release-plugin] prepare release org.apache.sling.commons.logservice-1.0.0
     new 81f8d8d  [maven-release-plugin] prepare for next development iteration
     new 8500051  SLING-2480 : Add config for maven-sling-plugin to m2e configuration
     new fe2d791  SLING-2483 Use provide:=true instead of version macros to define the proper import version range. Also fix a small glitch in the parent pom relativePath of the framework-extension-ws bundle
     new 27d6ca7  SLING-2486 Log bundle event synchronously and add logging for STARTING and STOPPING events
     new b9f5dea  Update to latest parent pom
     new 48d27cb  Use released versions
     new 29583f1  [maven-release-plugin] prepare release org.apache.sling.commons.logservice-1.0.2
     new 1a04955  [maven-release-plugin] prepare for next development iteration
     new cea6c28  Use latest releases and update to new parent pom
     new fae8a9e  Update to latest parent pom and use latest releases in launchpad
     new e540aae  Correct reactor pom and update to parent pom 16
     new 6ff79cf  Update to latest parent pom
     new 11cce5c  Update to parent pom 18
     new 6eebd9e  Update to parent pom v19
     new 809a09e  Updated to parent version 20
     new 1abc603  Update to Sling Parent POM 22 with baselining enabled
     new 346270f  SLING-4510 : Sling LogService could provide more usable output. Apply patch from David Bosschaert
     new a6bf444  [maven-release-plugin] prepare release org.apache.sling.commons.logservice-1.0.4
     new d39896b  [maven-release-plugin] prepare for next development iteration
     new ac13042  SLING-4563 : Log start level number on STARTLEVEL CHANGED event
     new 8968823  SLING-4563 : Log start level number on STARTLEVEL CHANGED event
     new 1bd99ca  SLING-4698 - Set parent.relativePath to empty for all modules
     new eb765ba  Update to Sling Parent 23
     new c330abb  set parent version to 24 and add empty relativePath where missing
     new e39b56e  Update the main reactor to parent 25
     new e626db9  [maven-release-plugin] prepare release org.apache.sling.commons.logservice-1.0.6
     new 4b4598b  [maven-release-plugin] prepare for next development iteration
     new c9dcca5  SLING-5263 - implement some junit test cases for LogSupport.java
     new 1c3db48  fix typos
     new dccf5ab  Switch to parent pom 26
     new 80c9b21  Update to parent pom 29
     new 6a3b437  use Sling Parent 30
     new ed9aa21  SLING-7167 Adjust READMEs
     new be3093f  SLING-7167 Adjust READMEs
     new 831c4b7  SLING-7167 Adjust READMEs

The 38 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


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

[sling-org-apache-sling-commons-logservice] 11/38: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1a04955e3c973c7731b0226253dd013e786372ee
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Nov 27 10:12:14 2012 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1414064 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 4b4117d..ca2828e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
     </parent>
 
     <artifactId>org.apache.sling.commons.logservice</artifactId>
-    <version>1.0.2</version>
+    <version>1.0.3-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling OSGi LogService Implementation</name>
@@ -38,9 +38,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.logservice-1.0.2</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.logservice-1.0.2</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.commons.logservice-1.0.2</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/logservice</url>
     </scm>
     
     <build>

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

[sling-org-apache-sling-commons-logservice] 04/38: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 81f8d8da130e6b15409be9f6c9a669371eb5ab2e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Jan 31 14:04:08 2012 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1238555 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index b9fa37c..7186826 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
     </parent>
 
     <artifactId>org.apache.sling.commons.logservice</artifactId>
-    <version>1.0.0</version>
+    <version>1.0.1-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling OSGi LogService Implementation</name>
@@ -38,9 +38,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.logservice-1.0.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.logservice-1.0.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.commons.logservice-1.0.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/logservice</url>
     </scm>
     
     <build>

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

[sling-org-apache-sling-commons-logservice] 33/38: Switch to parent pom 26

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit dccf5ab44589b1ea0f92dfe046f0a3e0cd72fd4d
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun Jan 3 14:07:46 2016 +0000

    Switch to parent pom 26
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1722720 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index f7302f7..e6f43c1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>25</version>
+        <version>26</version>
         <relativePath />
     </parent>
 

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

[sling-org-apache-sling-commons-logservice] 06/38: SLING-2483 Use provide:=true instead of version macros to define the proper import version range. Also fix a small glitch in the parent pom relativePath of the framework-extension-ws bundle

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit fe2d7913ff52a0afff6fc86fad468bcc7b7eb8eb
Author: Felix Meschberger <fm...@apache.org>
AuthorDate: Thu May 17 21:02:03 2012 +0000

    SLING-2483 Use provide:=true instead of version macros to define
    the proper import version range. Also fix a small glitch in the parent pom relativePath of the
    framework-extension-ws bundle
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1339861 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 5a82498..d012245 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,7 +64,7 @@
                             org.apache.sling.commons.logservice.*,
                         </Private-Package>
                         <Import-Package>
-                            org.osgi.service.log;version="[$(version;==;$(@)),$(version;=+;$(@)))",
+                            org.osgi.service.log;provide:=true,
                             *
                         </Import-Package>
                     </instructions>

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

[sling-org-apache-sling-commons-logservice] 26/38: Update to Sling Parent 23

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit eb765baaaca351df3d56d77abc7762c4c54749de
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Thu Jun 25 13:08:16 2015 +0000

    Update to Sling Parent 23
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1687500 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 0099001..db41fdb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>22</version>
+        <version>23</version>
         <relativePath/>
     </parent>
 

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

[sling-org-apache-sling-commons-logservice] 10/38: [maven-release-plugin] prepare release org.apache.sling.commons.logservice-1.0.2

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 29583f124ab002c4f646a55c3a97031f5a0a2a54
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Nov 27 10:11:51 2012 +0000

    [maven-release-plugin] prepare release org.apache.sling.commons.logservice-1.0.2
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1414061 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 8c46166..4b4117d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
     </parent>
 
     <artifactId>org.apache.sling.commons.logservice</artifactId>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>1.0.2</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling OSGi LogService Implementation</name>
@@ -38,9 +38,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/logservice</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.logservice-1.0.2</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.logservice-1.0.2</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.commons.logservice-1.0.2</url>
     </scm>
     
     <build>

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

[sling-org-apache-sling-commons-logservice] 01/38: SLING-2224 Create new LogService bundle

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 22f01e3ef1debb58f27aa36d5142f7ad5bd08ebe
Author: Felix Meschberger <fm...@apache.org>
AuthorDate: Sun Oct 2 13:32:34 2011 +0000

    SLING-2224 Create new LogService bundle
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1178187 13f79535-47bb-0310-9956-ffa450edef68
---
 README.txt                                         |  66 +++
 pom.xml                                            | 115 ++++
 .../commons/logservice/internal/Activator.java     |  77 +++
 .../commons/logservice/internal/LogEntryImpl.java  |  71 +++
 .../internal/LogReaderServiceFactory.java          |  83 +++
 .../logservice/internal/LogServiceFactory.java     |  97 ++++
 .../commons/logservice/internal/LogSupport.java    | 586 +++++++++++++++++++++
 7 files changed, 1095 insertions(+)

diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..45fc4a5
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,66 @@
+Apache Sling OSGi LogService Implementation
+
+
+=================================================
+Welcome to Sling - OSGi LogService Implementation
+=================================================
+
+The "logservice" project implements the OSGi LogService imple,entation ontop
+of the SLF4J logging API. This bundle should be installed as one of the first
+modules in the OSGi framework along with the SLF4J API and implementation and
+- provided the framework supports start levels - be set to start at start
+level 1. This ensures the Logging bundle is loaded as early as possible thus
+providing services to the framework and preparing logging.
+
+See the Apache Sling web site (http://sling.apache.org) for
+documentation and other information. You are welcome to join the
+Sling mailing lists (http://sling.apache.org/site/project-information.html)
+to discuss this component and to use the Sling issue tracker
+(http://issues.apache.org/jira/browse/SLING) to report issues or request
+new features.
+
+Apache Sling is a project of the Apache Software Foundation
+(http://www.apache.org).
+
+License (see also LICENSE)
+==========================
+
+Collective work: Copyright 2007 The Apache Software Foundation.
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Getting Started
+===============
+
+This component uses a Maven 2 (http://maven.apache.org/) build
+environment. It requires a Java 5 JDK (or higher) and Maven (http://maven.apache.org/)
+2.0.7 or later. We recommend to use the latest Maven version.
+
+If you have Maven 2 installed, you can compile and
+package the jar using the following command:
+
+    mvn package
+
+See the Maven 2 documentation for other build features.
+
+The latest source code for this component is available in the
+Subversion (http://subversion.tigris.org/) source repository of
+the Apache Software Foundation. If you have Subversion installed,
+you can checkout the latest source using the following command:
+
+    svn checkout http://svn.apache.org/repos/asf/sling/trunk/commons/log
+
+See the Subversion documentation for other source control features.
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..de63690
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+    
+    http://www.apache.org/licenses/LICENSE-2.0
+    
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>12</version>
+        <relativePath>../../../parent/pom.xml</relativePath>
+    </parent>
+
+    <artifactId>org.apache.sling.commons.logservice</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <name>Apache Sling OSGi LogService Implementation</name>
+    <description>
+        Implementation of the OSGi Compendium Log Service using SLF4J
+        as the actual logging backend.
+    </description>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/logservice</url>
+    </scm>
+    
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-Activator>
+                            org.apache.sling.commons.logservice.internal.Activator
+                        </Bundle-Activator>
+                        <Bundle-DocURL>
+                            http://sling.apache.org/site/logging.html
+                        </Bundle-DocURL>
+                        <Export-Package>
+                            org.osgi.service.log
+                        </Export-Package>
+                        <Private-Package>
+                            org.apache.sling.commons.logservice.*,
+                        </Private-Package>
+                        <Import-Package>
+                            org.osgi.service.log;version="[$(version;==;$(@)),$(version;=+;$(@)))",
+                            *
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <configuration>
+                    <!-- No javadocs at all -->
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+        </plugins>
+    </reporting>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.5.0</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <!-- OSGi Libraries not included here -->
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>4.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <version>4.2.0</version>
+        </dependency>
+        
+        <!-- testing -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/src/main/java/org/apache/sling/commons/logservice/internal/Activator.java b/src/main/java/org/apache/sling/commons/logservice/internal/Activator.java
new file mode 100644
index 0000000..60766b5
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/logservice/internal/Activator.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.commons.logservice.internal;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.service.log.LogReaderService;
+import org.osgi.service.log.LogService;
+
+/**
+ * The <code>Activator</code> class is the <code>BundleActivator</code> for the
+ * log service bundle. This activator registers the <code>LogService</code> and
+ * <code>LogReaderService</code>.
+ */
+public class Activator implements BundleActivator {
+
+    private static final String VENDOR = "The Apache Software Foundation";
+
+    private LogSupport logSupport;
+
+    /**
+     * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+     */
+    public void start(final BundleContext context) throws Exception {
+        logSupport = new LogSupport();
+        context.addBundleListener(logSupport);
+        context.addFrameworkListener(logSupport);
+        context.addServiceListener(logSupport);
+
+        LogServiceFactory lsf = new LogServiceFactory(logSupport);
+        Dictionary<String, String> props = new Hashtable<String, String>();
+        props.put(Constants.SERVICE_PID, lsf.getClass().getName());
+        props.put(Constants.SERVICE_DESCRIPTION,
+            "Apache Sling LogService implementation");
+        props.put(Constants.SERVICE_VENDOR, VENDOR);
+        context.registerService(LogService.class.getName(), lsf, props);
+
+        LogReaderServiceFactory lrsf = new LogReaderServiceFactory(logSupport);
+        props = new Hashtable<String, String>();
+        props.put(Constants.SERVICE_PID, lrsf.getClass().getName());
+        props.put(Constants.SERVICE_DESCRIPTION,
+            "Apache Sling LogReaderService implementation");
+        props.put(Constants.SERVICE_VENDOR, VENDOR);
+        context.registerService(LogReaderService.class.getName(), lrsf, props);
+    }
+
+    /**
+     * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+     */
+    public void stop(final BundleContext context) throws Exception {
+        if (logSupport != null) {
+            context.removeBundleListener(logSupport);
+            context.removeFrameworkListener(logSupport);
+            context.removeServiceListener(logSupport);
+            logSupport.shutdown();
+            logSupport = null;
+        }
+    }
+}
diff --git a/src/main/java/org/apache/sling/commons/logservice/internal/LogEntryImpl.java b/src/main/java/org/apache/sling/commons/logservice/internal/LogEntryImpl.java
new file mode 100644
index 0000000..a317293
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/logservice/internal/LogEntryImpl.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.commons.logservice.internal;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogEntry;
+
+public class LogEntryImpl implements LogEntry {
+
+    private final Bundle bundle;
+
+    private final ServiceReference serviceReference;
+
+    private final int level;
+
+    private final String message;
+
+    private final Throwable exception;
+
+    private final long time;
+
+    /* package */LogEntryImpl(Bundle bundle,
+            ServiceReference serviceReference, int level, String message,
+            Throwable exception) {
+        this.bundle = bundle;
+        this.serviceReference = serviceReference;
+        this.level = level;
+        this.message = message;
+        this.exception = exception;
+        this.time = System.currentTimeMillis();
+    }
+
+    public Bundle getBundle() {
+        return this.bundle;
+    }
+
+    public ServiceReference getServiceReference() {
+        return this.serviceReference;
+    }
+
+    public int getLevel() {
+        return this.level;
+    }
+
+    public String getMessage() {
+        return this.message;
+    }
+
+    public Throwable getException() {
+        return this.exception;
+    }
+
+    public long getTime() {
+        return this.time;
+    }
+}
diff --git a/src/main/java/org/apache/sling/commons/logservice/internal/LogReaderServiceFactory.java b/src/main/java/org/apache/sling/commons/logservice/internal/LogReaderServiceFactory.java
new file mode 100644
index 0000000..79791e4
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/logservice/internal/LogReaderServiceFactory.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.commons.logservice.internal;
+
+import java.util.Enumeration;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.log.LogListener;
+import org.osgi.service.log.LogReaderService;
+
+/**
+ * The <code>LogReaderServiceFactory</code> is the service factory for
+ * <code>LogReader</code> service instances supplied to bundles.
+ * <p>
+ * <blockquote> When a bundle which registers a LogListener object is stopped or
+ * otherwise releases the Log Reader Service, the Log Reader Service must remove
+ * all of the bundle's listeners.</blockquote>
+ */
+public class LogReaderServiceFactory implements ServiceFactory {
+
+    private LogSupport logSupport;
+
+    LogReaderServiceFactory(LogSupport logSupport) {
+        this.logSupport = logSupport;
+    }
+
+    // ---------- ServiceFactory interface ------------------------------------
+
+    public Object getService(Bundle bundle, ServiceRegistration registration) {
+        return new LogReaderServiceImpl(bundle);
+    }
+
+    public void ungetService(Bundle bundle, ServiceRegistration registration,
+            Object service) {
+        ((LogReaderServiceImpl) service).shutdown();
+    }
+
+    // --------- internal LogReaderService implementation ----------------------
+
+    private class LogReaderServiceImpl implements LogReaderService {
+
+        private Bundle bundle;
+
+        /* package */LogReaderServiceImpl(Bundle bundle) {
+            this.bundle = bundle;
+        }
+
+        /* package */void shutdown() {
+            LogReaderServiceFactory.this.logSupport.removeLogListeners(this.bundle);
+        }
+
+        public void addLogListener(LogListener listener) {
+            LogReaderServiceFactory.this.logSupport.addLogListener(this.bundle,
+                listener);
+        }
+
+        public void removeLogListener(LogListener listener) {
+            LogReaderServiceFactory.this.logSupport.removeLogListener(listener);
+        }
+
+        @SuppressWarnings("rawtypes")
+        public Enumeration getLog() {
+            return LogReaderServiceFactory.this.logSupport.getLog();
+        }
+    }
+
+}
diff --git a/src/main/java/org/apache/sling/commons/logservice/internal/LogServiceFactory.java b/src/main/java/org/apache/sling/commons/logservice/internal/LogServiceFactory.java
new file mode 100644
index 0000000..e62faf8
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/logservice/internal/LogServiceFactory.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.commons.logservice.internal;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.log.LogEntry;
+import org.osgi.service.log.LogService;
+
+/**
+ * The <code>LogServiceFactory</code> implements the OSGi Log Service
+ * specification and provides the functionality for the logging system. This
+ * service should be one of the first services loaded in the system.
+ */
+public class LogServiceFactory implements ServiceFactory {
+
+    private LogSupport logSupport;
+
+    /**
+     * Initializes the logging system with settings from some startup properties
+     * before the real configuration is read after ContentBus bootstrap.
+     * 
+     * @param properties The startup properties to initialize the logging system
+     *            with.
+     */
+    LogServiceFactory(LogSupport logSupport) {
+        this.logSupport = logSupport;
+
+    }
+
+    // ---------- ServiceFactory
+
+    public Object getService(Bundle bundle, ServiceRegistration registration) {
+        return new LogServiceImpl(bundle);
+    }
+
+    public void ungetService(Bundle bundle, ServiceRegistration registration,
+            Object service) {
+        // nothing to do currently
+    }
+
+    private class LogServiceImpl implements LogService {
+
+        private Bundle bundle;
+
+        /**
+         * Initializes the logging system with settings from some startup
+         * properties before the real configuration is read after ContentBus
+         * bootstrap.
+         * 
+         * @param properties The startup properties to initialize the logging
+         *            system with.
+         */
+        /* package */LogServiceImpl(Bundle bundle) {
+            this.bundle = bundle;
+        }
+
+        // ---------- LogService
+
+        public void log(int level, String message) {
+            this.log(null, level, message, null);
+        }
+
+        public void log(int level, String message, Throwable exception) {
+            this.log(null, level, message, exception);
+        }
+
+        public void log(ServiceReference sr, int level, String message) {
+            this.log(sr, level, message, null);
+        }
+
+        public void log(ServiceReference sr, int level, String message,
+                Throwable exception) {
+            // simply fire a log event
+            LogEntry entry = new LogEntryImpl(this.bundle, sr, level, message,
+                exception);
+            LogServiceFactory.this.logSupport.fireLogEvent(entry);
+        }
+    }
+
+}
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
new file mode 100644
index 0000000..8a78926
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/logservice/internal/LogSupport.java
@@ -0,0 +1,586 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.commons.logservice.internal;
+
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.Constants;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The <code>LogReaderServiceFactory</code> TODO
+ */
+public class LogSupport implements BundleListener, ServiceListener,
+        FrameworkListener {
+
+    /**
+     * The service property name of the component name (value is
+     * "component.name"). Note: We use a private constant here to not create a
+     * unneded dependency on the org.osgi.service.component package.
+     */
+    private static final String COMPONENT_NAME = ComponentConstants.COMPONENT_NAME; // "component.name";
+
+    /**
+     * The empty enumeration currently returned on the {@link #getLog()} call
+     * because we do not currently record the log events.
+     */
+    private final Enumeration<?> EMPTY = Collections.enumeration(Collections.emptyList());
+
+    // The registered LogListeners
+    private LogListenerProxy[] listeners;
+
+    // The lock used to guard concurrent access to the listeners array
+    private final Object listenersLock = new Object();
+
+    // The loggers by bundle id used for logging messages originated from
+    // specific bundles
+    private Map<Long, Logger> loggers = new HashMap<Long, Logger>();
+
+    // the worker thread actually sending LogEvents to LogListeners
+    private LogEntryDispatcher logEntryDispatcher;
+
+    /* package */LogSupport() {
+        logEntryDispatcher = new LogEntryDispatcher(this);
+        logEntryDispatcher.start();
+    }
+
+    /* package */void shutdown() {
+
+        // terminate the dispatcher and wait for its termination here
+        logEntryDispatcher.terminate();
+        try {
+            logEntryDispatcher.join(1000L);
+        } catch (InterruptedException ie) {
+            // don't care
+        }
+
+        // drop all listeners
+        synchronized (listenersLock) {
+            listeners = null;
+        }
+    }
+
+    // ---------- LogReaderService interface -----------------------------------
+
+    /* package */void addLogListener(Bundle bundle, LogListener listener) {
+        synchronized (listenersLock) {
+            LogListenerProxy llp = new LogListenerProxy(bundle, listener);
+            if (listeners == null) {
+                listeners = new LogListenerProxy[] { llp };
+            } else if (getListener(listener) < 0) {
+                LogListenerProxy[] newListeners = new LogListenerProxy[listeners.length + 1];
+                System.arraycopy(listeners, 0, newListeners, 0,
+                    listeners.length);
+                newListeners[listeners.length] = llp;
+                listeners = newListeners;
+            }
+        }
+    }
+
+    /* package */void removeLogListener(LogListener listener) {
+        synchronized (listenersLock) {
+            // no listeners registered, nothing to do
+            if (listeners == null) {
+                return;
+            }
+
+            // listener is not registered, nothing to do
+            int idx = getListener(listener);
+            if (idx < 0) {
+                return;
+            }
+
+            LogListenerProxy[] newListeners = new LogListenerProxy[listeners.length - 1];
+            if (idx > 0) {
+                System.arraycopy(listeners, 0, newListeners, 0, idx);
+            }
+            if (idx < listeners.length) {
+                System.arraycopy(listeners, idx + 1, newListeners, 0,
+                    newListeners.length - idx);
+            }
+            listeners = newListeners;
+        }
+    }
+
+    /**
+     * Removes all registered LogListeners belonging to the given bundle. This
+     * is the task required by the specification from a Log Service
+     * implemenation:
+     * <p>
+     * <blockquote> When a bundle which registers a LogListener object is
+     * stopped or otherwise releases the Log Reader Service, the Log Reader
+     * Service must remove all of the bundle's listeners.</blockquote>
+     * <p>
+     *
+     * @param bundle The bundle whose listeners are to be removed.
+     */
+    /* package */void removeLogListeners(Bundle bundle) {
+        // grab an immediate copy of the array
+        LogListenerProxy[] current = getListeners();
+        if (current == null) {
+            return;
+        }
+
+        // check for listeners by bundle
+        for (int i = 0; i < current.length; i++) {
+            if (current[i].hasBundle(bundle)) {
+                removeLogListener(current[i]);
+            }
+        }
+    }
+
+    private int getListener(LogListener listener) {
+        if (listeners != null) {
+            for (int i = 0; i < listeners.length; i++) {
+                if (listeners[i].isSame(listener)) {
+                    return i;
+                }
+            }
+        }
+
+        // fall back to not found
+        return -1;
+    }
+
+    /**
+     * Returns the currently registered LogListeners
+     */
+    private LogListenerProxy[] getListeners() {
+        synchronized (listenersLock) {
+            return listeners;
+        }
+    }
+
+    /**
+     * Returns an empty enumeration for now because we do not implement log
+     * entry recording for the moment.
+     */
+    Enumeration<?> getLog() {
+        return EMPTY;
+    }
+
+    // ---------- Firing a log event -------------------------------------------
+
+    /**
+     * Logs the given log entry to the log file and enqueues for the dispatching
+     * to the registered LogListeners in a separate worker thread.
+     */
+    /* package */void fireLogEvent(LogEntry logEntry) {
+
+        // actually log it to SLF4J
+        logOut(logEntry);
+
+        // enqueue for asynchronous delivery
+        logEntryDispatcher.enqueLogEntry(logEntry);
+    }
+
+    // ---------- BundleListener -----------------------------------------------
+
+    /**
+     * Listens for Bundle events and logs the respective events according to the
+     * Log Service specification. In addition, all LogListener instances
+     * registered for stopped bundles are removed by this method.
+     */
+    public void bundleChanged(BundleEvent event) {
+        String message;
+        switch (event.getType()) {
+            case BundleEvent.INSTALLED:
+                message = "BundleEvent INSTALLED";
+                break;
+            case BundleEvent.STARTED:
+                message = "BundleEvent STARTED";
+                break;
+            case BundleEvent.STOPPED:
+                // this is special, as we have to fix the listener list for
+                // stopped bundles
+                removeLogListeners(event.getBundle());
+                message = "BundleEvent STOPPED";
+                break;
+            case BundleEvent.UPDATED:
+                message = "BundleEvent UPDATED";
+                break;
+            case BundleEvent.UNINSTALLED:
+                message = "BundleEvent UNINSTALLED";
+                break;
+            case BundleEvent.RESOLVED:
+                message = "BundleEvent RESOLVED";
+                break;
+            case BundleEvent.UNRESOLVED:
+                message = "BundleEvent UNRESOLVED";
+                break;
+            default:
+                message = "BundleEvent " + event.getType();
+        }
+
+        LogEntry entry = new LogEntryImpl(event.getBundle(), null,
+            LogService.LOG_INFO, message, null);
+        fireLogEvent(entry);
+    }
+
+    // ---------- ServiceListener ----------------------------------------------
+
+    /**
+     * Listens for Service events and logs the respective events according to
+     * the Log Service specification.
+     */
+    public void serviceChanged(ServiceEvent event) {
+        int level = LogService.LOG_INFO;
+        String message;
+        switch (event.getType()) {
+            case ServiceEvent.REGISTERED:
+                message = "ServiceEvent REGISTERED";
+                break;
+            case ServiceEvent.MODIFIED:
+                message = "ServiceEvent MODIFIED";
+                level = LogService.LOG_DEBUG;
+                break;
+            case ServiceEvent.UNREGISTERING:
+                message = "ServiceEvent UNREGISTERING";
+                break;
+            default:
+                message = "ServiceEvent " + event.getType();
+        }
+
+        String s = (event.getServiceReference().getBundle() == null)
+                ? null
+                : "Bundle " + event.getServiceReference().getBundle();
+        s = (s == null) ? message : s + " " + message;
+
+        LogEntry entry = new LogEntryImpl(
+            event.getServiceReference().getBundle(),
+            event.getServiceReference(), level, message, null);
+        fireLogEvent(entry);
+    }
+
+    // ---------- FrameworkListener --------------------------------------------
+
+    /**
+     * Listens for Framework events and logs the respective events according to
+     * the Log Service specification.
+     * <p>
+     * In the case of a Framework ERROR which is a ClassNotFoundException for an
+     * unresolved bundle, the message is logged at INFO level instead of ERROR
+     * level as prescribed by the spec. This is because such a situation should
+     * not really result in a Framework ERROR but the Apache Felix framework has
+     * no means of controlling this at the moment (framework 1.0.4 release).
+     */
+    public void frameworkEvent(FrameworkEvent event) {
+        int level = LogService.LOG_INFO;
+        String message;
+        Throwable exception = event.getThrowable();
+        switch (event.getType()) {
+            case FrameworkEvent.STARTED:
+                message = "FrameworkEvent STARTED";
+                break;
+            case FrameworkEvent.ERROR:
+                message = "FrameworkEvent ERROR";
+
+                // special precaution for Felix.loadBundleClass event overkill
+                // FIXME: actually, the error is ok, if the bundle failed to
+                // resolve
+                if (exception instanceof BundleException) {
+                    StackTraceElement[] ste = exception.getStackTrace();
+                    if (ste != null && ste.length > 0
+                        && "loadBundleClass".equals(ste[0].getMethodName())) {
+                        message += ": Class " + exception.getMessage()
+                            + " not found";
+                        if (event.getBundle() != null) {
+                            message += " in bundle "
+                                + event.getBundle().getSymbolicName() + " ("
+                                + event.getBundle().getBundleId() + ")";
+                        }
+                        level = LogService.LOG_INFO;
+                        exception = null; // don't care for a stack trace here
+                        break;
+                    }
+                }
+
+                level = LogService.LOG_ERROR;
+                break;
+            case FrameworkEvent.PACKAGES_REFRESHED:
+                message = "FrameworkEvent PACKAGES REFRESHED";
+                break;
+            case FrameworkEvent.STARTLEVEL_CHANGED:
+                message = "FrameworkEvent STARTLEVEL CHANGED";
+                break;
+            case FrameworkEvent.WARNING:
+                message = "FrameworkEvent WARNING";
+                break;
+            case FrameworkEvent.INFO:
+                message = "FrameworkEvent INFO";
+                break;
+            default:
+                message = "FrameworkEvent " + event.getType();
+        }
+
+        String s = (event.getBundle() == null) ? null : "Bundle "
+            + event.getBundle();
+        s = (s == null) ? message : s + " " + message;
+
+        LogEntry entry = new LogEntryImpl(event.getBundle(), null, level,
+            message, exception);
+        fireLogEvent(entry);
+    }
+
+    // ---------- Effective logging --------------------------------------------
+
+    /**
+     * Get a logger for messages orginating from the given bundle. If no bundle
+     * is specified, we use the system bundle logger.
+     *
+     * @param bundle The bundle for which a logger is to be returned.
+     * @return The Logger for the bundle.
+     */
+    private Logger getLogger(Bundle bundle) {
+        Long bundleId = new Long((bundle == null) ? 0 : bundle.getBundleId());
+        Logger log = loggers.get(bundleId);
+        if (log == null) {
+
+            String name;
+            if (bundle == null) {
+
+                // if we have no bundle, use the system bundle's name
+                name = Constants.SYSTEM_BUNDLE_SYMBOLICNAME;
+
+            } else {
+
+                // otherwise use the bundle symbolic name
+                name = bundle.getSymbolicName();
+
+                // if the bundle has no symbolic name, use the location
+                if (name == null) {
+                    name = bundle.getLocation();
+                }
+
+                // if the bundle also has no location, use the bundle Id
+                if (name == null) {
+                    name = String.valueOf(bundle.getBundleId());
+                }
+            }
+
+            log = LoggerFactory.getLogger(name);
+            loggers.put(bundleId, log);
+        }
+        return log;
+    }
+
+    /**
+     * Actually logs the given log entry to the logger for the bundle recorded
+     * in the log entry.
+     */
+    private void logOut(LogEntry logEntry) {
+        // /* package */ void logOut(Bundle bundle, ServiceReference sr, int
+        // level, String message, Throwable exception) {
+
+        // get the logger for the bundle
+        Logger log = getLogger(logEntry.getBundle());
+
+        StringBuffer msg = new StringBuffer();
+
+        ServiceReference sr = logEntry.getServiceReference();
+        if (sr != null) {
+            msg.append("Service [");
+            if (sr.getProperty(Constants.SERVICE_PID) != null) {
+                msg.append(sr.getProperty(Constants.SERVICE_PID)).append(',');
+            } else if (sr.getProperty(COMPONENT_NAME) != null) {
+                msg.append(sr.getProperty(COMPONENT_NAME)).append(',');
+            } else if (sr.getProperty(Constants.SERVICE_DESCRIPTION) != null) {
+                msg.append(sr.getProperty(Constants.SERVICE_DESCRIPTION)).append(
+                    ',');
+            }
+            msg.append(sr.getProperty(Constants.SERVICE_ID)).append("] ");
+        }
+
+        if (logEntry.getMessage() != null) {
+            msg.append(logEntry.getMessage());
+        }
+
+        Throwable exception = logEntry.getException();
+        if (exception != null) {
+            msg.append(" (").append(exception).append(')');
+        }
+
+        String message = msg.toString();
+        switch (logEntry.getLevel()) {
+            case LogService.LOG_DEBUG:
+                log.debug(message, exception);
+                break;
+            case LogService.LOG_INFO:
+                log.info(message, exception);
+                break;
+            case LogService.LOG_WARNING:
+                log.warn(message, exception);
+                break;
+            case LogService.LOG_ERROR:
+                log.error(message, exception);
+                break;
+            default:
+                if (logEntry.getLevel() > LogService.LOG_DEBUG) {
+                    log.trace(message, exception);
+                } else if (logEntry.getLevel() < LogService.LOG_ERROR) {
+                    log.error(message, exception);
+                }
+                break;
+        }
+    }
+
+    // ---------- internal class -----------------------------------------------
+
+    /**
+     * The <code>LogListenerProxy</code> class is a proxy to the actually
+     * registered <code>LogListener</code> which also records the bundle
+     * registering the listener. This allows for the removal of the log
+     * listeners registered by bundles which have not been removed before the
+     * bundle has been stopped.
+     */
+    private static class LogListenerProxy implements LogListener {
+
+        private final int runningBundle = Bundle.STARTING | Bundle.ACTIVE
+            | Bundle.STOPPING;
+
+        private final Bundle bundle;
+
+        private final LogListener delegatee;
+
+        public LogListenerProxy(Bundle bundle, LogListener delegatee) {
+            this.bundle = bundle;
+            this.delegatee = delegatee;
+        }
+
+        public void logged(LogEntry entry) {
+            if ((bundle.getState() & runningBundle) != 0) {
+                delegatee.logged(entry);
+            }
+        }
+
+        /* package */boolean isSame(LogListener listener) {
+            return listener == delegatee || listener == this;
+        }
+
+        /* package */boolean hasBundle(Bundle bundle) {
+            return this.bundle == bundle;
+        }
+    }
+
+    /**
+     * The <code>LogEntryDispatcher</code> implements the worker thread
+     * responsible for delivering log events to the log listeners.
+     */
+    private static class LogEntryDispatcher extends Thread {
+
+        // provides the actual log listeners on demand
+        private final LogSupport logSupport;
+
+        // the queue of log events to be dispatched
+        private final BlockingQueue<LogEntry> dispatchQueue;
+
+        // true as long as the thread is active
+        private boolean active;
+
+        LogEntryDispatcher(LogSupport logSupport) {
+            super("LogEntry Dispatcher");
+
+            this.logSupport = logSupport;
+            this.dispatchQueue = new LinkedBlockingQueue<LogEntry>();
+            this.active = true;
+        }
+
+        /**
+         * Add a log entry for dispatching.
+         */
+        void enqueLogEntry(LogEntry logEntry) {
+            dispatchQueue.offer(logEntry);
+        }
+
+        /**
+         * Get the next log entry for dispatching. This method blocks until an
+         * event is available or the thread is interrupted.
+         *
+         * @return The next event to dispatch
+         * @throws InterruptedException If the thread has been interrupted while
+         *             waiting for a log event to dispatch.
+         */
+        LogEntry dequeueLogEntry() throws InterruptedException {
+            return dispatchQueue.take();
+        }
+
+        /**
+         * Terminates this work thread by resetting the active flag and
+         * interrupting itself such that the {@link #dequeueLogEntry()} is
+         * aborted for the thread to terminate.
+         */
+        void terminate() {
+            active = false;
+            interrupt();
+        }
+
+        /**
+         * Runs the actual log event dispatching. This method continues to get
+         * log events from the {@link #dequeueLogEntry()} method until the
+         * active flag is reset.
+         */
+        @Override
+        public void run() {
+            while (active) {
+
+                LogEntry logEntry = null;
+                try {
+                    logEntry = dequeueLogEntry();
+                } catch (InterruptedException ie) {
+                    // don't care, this is expected
+                }
+
+                // dispatch the log entry
+                if (logEntry != null) {
+
+                    // grab an immediate copy of the array
+                    LogListener[] logListeners = logSupport.getListeners();
+
+                    // fire the events outside of the listenersLock
+                    if (logListeners != null) {
+                        for (LogListener logListener : logListeners) {
+                            try {
+                                logListener.logged(logEntry);
+                            } catch (Throwable t) {
+                                // should we really care ??
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}

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

[sling-org-apache-sling-commons-logservice] 29/38: [maven-release-plugin] prepare release org.apache.sling.commons.logservice-1.0.6

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e626db9303079a9acc4a77a13424058b11031d1e
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Wed Oct 7 11:35:46 2015 +0000

    [maven-release-plugin] prepare release org.apache.sling.commons.logservice-1.0.6
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1707260 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/pom.xml b/pom.xml
index 7e95e5c..fe2b0bf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,11 +24,11 @@
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
         <version>25</version>
-        <relativePath/>
+        <relativePath />
     </parent>
 
     <artifactId>org.apache.sling.commons.logservice</artifactId>
-    <version>1.0.5-SNAPSHOT</version>
+    <version>1.0.6</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling OSGi LogService Implementation</name>
@@ -38,9 +38,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/logservice</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.logservice-1.0.6</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.logservice-1.0.6</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.commons.logservice-1.0.6</url>
     </scm>
     
     <build>

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

[sling-org-apache-sling-commons-logservice] 09/38: Use released versions

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 48d27cbee8f5a360eec1218aa58322535d684902
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Jul 10 11:07:18 2012 +0000

    Use released versions
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1359601 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 3ecfa3c..8c46166 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>14-SNAPSHOT</version>
+        <version>13</version>
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 

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

[sling-org-apache-sling-commons-logservice] 02/38: SLING-2235 Use size limited, access ordered cache for bundle loggers and remove entries for uninstalled bundles

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 300166192e59a41779bbce54f6eba6a3fd4cff66
Author: Felix Meschberger <fm...@apache.org>
AuthorDate: Sun Oct 2 14:55:26 2011 +0000

    SLING-2235 Use size limited, access ordered cache for bundle loggers and remove entries for uninstalled bundles
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1178194 13f79535-47bb-0310-9956-ffa450edef68
---
 .../commons/logservice/internal/LogSupport.java    | 34 +++++++++++++++++++---
 1 file changed, 30 insertions(+), 4 deletions(-)

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 8a78926..d40d6e0 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
@@ -18,7 +18,7 @@ package org.apache.sling.commons.logservice.internal;
 
 import java.util.Collections;
 import java.util.Enumeration;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -67,7 +67,15 @@ public class LogSupport implements BundleListener, ServiceListener,
 
     // The loggers by bundle id used for logging messages originated from
     // specific bundles
-    private Map<Long, Logger> loggers = new HashMap<Long, Logger>();
+    @SuppressWarnings("serial")
+    private Map<Long, Logger> loggers = new LinkedHashMap<Long, Logger>(16,
+        0.75f, true) {
+        private static final int MAX_SIZE = 50;
+
+        protected boolean removeEldestEntry(Map.Entry<Long, Logger> eldest) {
+            return size() > MAX_SIZE;
+        }
+    };
 
     // the worker thread actually sending LogEvents to LogListeners
     private LogEntryDispatcher logEntryDispatcher;
@@ -233,6 +241,8 @@ public class LogSupport implements BundleListener, ServiceListener,
                 message = "BundleEvent UPDATED";
                 break;
             case BundleEvent.UNINSTALLED:
+                // remove any cached logger for the uninstalled bundle
+                ungetLogger(event.getBundle());
                 message = "BundleEvent UNINSTALLED";
                 break;
             case BundleEvent.RESOLVED:
@@ -366,7 +376,10 @@ public class LogSupport implements BundleListener, ServiceListener,
      */
     private Logger getLogger(Bundle bundle) {
         Long bundleId = new Long((bundle == null) ? 0 : bundle.getBundleId());
-        Logger log = loggers.get(bundleId);
+        Logger log;
+        synchronized (loggers) {
+            log = loggers.get(bundleId);
+        }
         if (log == null) {
 
             String name;
@@ -392,12 +405,25 @@ public class LogSupport implements BundleListener, ServiceListener,
             }
 
             log = LoggerFactory.getLogger(name);
-            loggers.put(bundleId, log);
+            synchronized (loggers) {
+                loggers.put(bundleId, log);
+            }
         }
         return log;
     }
 
     /**
+     * Removes the cached logger for the given bundle, for example if the
+     * bundle is uninstalled and thus there will be no more logs from this
+     * bundle.
+     */
+    private void ungetLogger(Bundle bundle) {
+        synchronized (loggers) {
+            loggers.remove(bundle.getBundleId());
+        }
+    }
+
+    /**
      * Actually logs the given log entry to the logger for the bundle recorded
      * in the log entry.
      */

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

[sling-org-apache-sling-commons-logservice] 32/38: fix typos

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1c3db48dccd98825725899ccc9d2795c11fc2b6c
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Fri Dec 25 12:30:50 2015 +0000

    fix typos
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1721671 13f79535-47bb-0310-9956-ffa450edef68
---
 README.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.txt b/README.txt
index 45fc4a5..1201161 100644
--- a/README.txt
+++ b/README.txt
@@ -5,7 +5,7 @@ Apache Sling OSGi LogService Implementation
 Welcome to Sling - OSGi LogService Implementation
 =================================================
 
-The "logservice" project implements the OSGi LogService imple,entation ontop
+The "logservice" project implements the OSGi LogService implementation on top
 of the SLF4J logging API. This bundle should be installed as one of the first
 modules in the OSGi framework along with the SLF4J API and implementation and
 - provided the framework supports start levels - be set to start at start

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

[sling-org-apache-sling-commons-logservice] 15/38: Update to latest parent pom

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6ff79cf0c1a02389ffb8c4cf404a0e879c4ee1c4
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Jul 19 07:04:15 2013 +0000

    Update to latest parent pom
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1504788 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 7ebcf1a..1842e53 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>16</version>
+        <version>17</version>
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 

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

[sling-org-apache-sling-commons-logservice] 34/38: Update to parent pom 29

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 80c9b2145819b408496befbf272280d8c7d0445b
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Oct 21 06:15:11 2016 +0000

    Update to parent pom 29
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1765928 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index e6f43c1..241e9a6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>26</version>
+        <version>29</version>
         <relativePath />
     </parent>
 

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

[sling-org-apache-sling-commons-logservice] 36/38: SLING-7167 Adjust READMEs

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ed9aa210c65f89fad5a5cd500459b799ddce73e9
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Mon Oct 2 14:52:48 2017 +0000

    SLING-7167 Adjust READMEs
    
    remove outdated information
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1810371 13f79535-47bb-0310-9956-ffa450edef68
---
 README.txt | 53 -----------------------------------------------------
 1 file changed, 53 deletions(-)

diff --git a/README.txt b/README.txt
index 1201161..ded02ca 100644
--- a/README.txt
+++ b/README.txt
@@ -11,56 +11,3 @@ modules in the OSGi framework along with the SLF4J API and implementation and
 - provided the framework supports start levels - be set to start at start
 level 1. This ensures the Logging bundle is loaded as early as possible thus
 providing services to the framework and preparing logging.
-
-See the Apache Sling web site (http://sling.apache.org) for
-documentation and other information. You are welcome to join the
-Sling mailing lists (http://sling.apache.org/site/project-information.html)
-to discuss this component and to use the Sling issue tracker
-(http://issues.apache.org/jira/browse/SLING) to report issues or request
-new features.
-
-Apache Sling is a project of the Apache Software Foundation
-(http://www.apache.org).
-
-License (see also LICENSE)
-==========================
-
-Collective work: Copyright 2007 The Apache Software Foundation.
-
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Getting Started
-===============
-
-This component uses a Maven 2 (http://maven.apache.org/) build
-environment. It requires a Java 5 JDK (or higher) and Maven (http://maven.apache.org/)
-2.0.7 or later. We recommend to use the latest Maven version.
-
-If you have Maven 2 installed, you can compile and
-package the jar using the following command:
-
-    mvn package
-
-See the Maven 2 documentation for other build features.
-
-The latest source code for this component is available in the
-Subversion (http://subversion.tigris.org/) source repository of
-the Apache Software Foundation. If you have Subversion installed,
-you can checkout the latest source using the following command:
-
-    svn checkout http://svn.apache.org/repos/asf/sling/trunk/commons/log
-
-See the Subversion documentation for other source control features.

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

[sling-org-apache-sling-commons-logservice] 22/38: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d39896b7ae8d5e1ce643d7f36c598022a9cf75a9
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Mar 30 12:24:52 2015 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1670075 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index a0e7d86..e0ed2cc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
     </parent>
 
     <artifactId>org.apache.sling.commons.logservice</artifactId>
-    <version>1.0.4</version>
+    <version>1.0.5-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling OSGi LogService Implementation</name>
@@ -38,9 +38,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.logservice-1.0.4</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.logservice-1.0.4</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.commons.logservice-1.0.4</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/logservice</url>
     </scm>
     
     <build>

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

[sling-org-apache-sling-commons-logservice] 17/38: Update to parent pom v19

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6eebd9ece53e652760807eb054545a932ff7b728
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Mar 31 14:39:20 2014 +0000

    Update to parent pom v19
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1583337 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 276f462..a933f03 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>18</version>
+        <version>19</version>
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 

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

[sling-org-apache-sling-commons-logservice] 08/38: Update to latest parent pom

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit b9f5deae9ef56cc4a0eb0d541a56f07d0a7bcadb
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Jul 5 09:29:47 2012 +0000

    Update to latest parent pom
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1357521 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index d012245..3ecfa3c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>13-SNAPSHOT</version>
+        <version>14-SNAPSHOT</version>
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 

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

[sling-org-apache-sling-commons-logservice] 31/38: SLING-5263 - implement some junit test cases for LogSupport.java

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c9dcca5ca72d212f26bcc26e5e59d5373c1f32bc
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Tue Dec 22 11:58:12 2015 +0000

    SLING-5263 - implement some junit test cases for LogSupport.java
    
    Applied patch submitted by Tien Nguyen, with some refactoring to reduce
    code duplication.
    
    This closes #111.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1721374 13f79535-47bb-0310-9956-ffa450edef68
---
 .../logservice/internal/LogSupportTest.java        | 136 ++++++++++++++-------
 1 file changed, 89 insertions(+), 47 deletions(-)

diff --git a/src/test/java/org/apache/sling/commons/logservice/internal/LogSupportTest.java b/src/test/java/org/apache/sling/commons/logservice/internal/LogSupportTest.java
index 269ff49..7bf0c2f 100644
--- a/src/test/java/org/apache/sling/commons/logservice/internal/LogSupportTest.java
+++ b/src/test/java/org/apache/sling/commons/logservice/internal/LogSupportTest.java
@@ -22,12 +22,16 @@ import java.lang.reflect.Field;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
+import org.osgi.framework.FrameworkEvent;
 import org.osgi.framework.ServiceEvent;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.log.LogEntry;
@@ -36,24 +40,39 @@ import org.osgi.service.startlevel.StartLevel;
 import org.slf4j.Logger;
 
 public class LogSupportTest {
-    @Test @SuppressWarnings("unchecked")
-    public void testServiceEvent() throws Exception {
+    
+    private Bundle bundle;
+    private LogSupport logSupport;
+    private Logger testLogger;
+
+    @Before
+    @SuppressWarnings("unchecked")
+    public void prepare() throws Exception {
+        
+        bundle = Mockito.mock(Bundle.class);
+        Mockito.when(bundle.getSymbolicName()).thenReturn("foo.bundle");
+        Mockito.when(bundle.getBundleId()).thenReturn(42L);
+        
         StartLevel startLevel = Mockito.mock(StartLevel.class);
-        LogSupport ls = new LogSupport(startLevel);
-        Field lf = LogSupport.class.getDeclaredField("loggers");
-        lf.setAccessible(true);
-        Map<Long, Logger> loggers = (Map<Long, Logger>) lf.get(ls);
+        logSupport = new LogSupport(startLevel);
+        Field loggerField = LogSupport.class.getDeclaredField("loggers");
+        loggerField.setAccessible(true);
+        Map<Long, Logger> loggers = (Map<Long, Logger>) loggerField.get(logSupport);
+        
+        testLogger = getMockInfoLogger();
+        loggers.put(bundle.getBundleId(), testLogger);
+    }
+    
+    @Test
+    public void testServiceEvent() throws Exception {
 
-        Bundle b = Mockito.mock(Bundle.class);
-        Mockito.when(b.getSymbolicName()).thenReturn("foo.bundle");
-        Mockito.when(b.getBundleId()).thenReturn(42L);
 
         final Map<String, Object> props = new HashMap<String, Object>();
         props.put(Constants.OBJECTCLASS, new String [] {"some.class.Name"});
         props.put(Constants.SERVICE_ID, 999L);
 
         ServiceReference sr = Mockito.mock(ServiceReference.class);
-        Mockito.when(sr.getBundle()).thenReturn(b);
+        Mockito.when(sr.getBundle()).thenReturn(bundle);
         Mockito.when(sr.getProperty(Mockito.anyString())).then(new Answer<Object>() {
             public Object answer(InvocationOnMock invocation) throws Throwable {
                 return props.get(invocation.getArguments()[0]);
@@ -62,33 +81,18 @@ public class LogSupportTest {
         Mockito.when(sr.getPropertyKeys()).thenReturn(props.keySet().toArray(new String[] {}));
         ServiceEvent se = new ServiceEvent(ServiceEvent.REGISTERED, sr);
 
-        Logger testLogger = getMockInfoLogger();
-        loggers.put(42L, testLogger);
-
-        ls.serviceChanged(se);
+        logSupport.serviceChanged(se);
 
         Mockito.verify(testLogger).info("Service [999, [some.class.Name]] ServiceEvent REGISTERED", (Throwable) null);
     }
 
-    @Test @SuppressWarnings("unchecked")
+    @Test
     public void testEarlyExit() throws Exception {
-        Bundle b = Mockito.mock(Bundle.class);
-        Mockito.when(b.getSymbolicName()).thenReturn("bar.bundle");
-        Mockito.when(b.getBundleId()).thenReturn(1L);
-
+        
         ServiceReference sr = Mockito.mock(ServiceReference.class);
-        LogEntry le = new LogEntryImpl(b, sr, LogService.LOG_DEBUG, "test", null);
-
-        StartLevel startLevel = Mockito.mock(StartLevel.class);
-        LogSupport ls = new LogSupport(startLevel);
-        Field lf = LogSupport.class.getDeclaredField("loggers");
-        lf.setAccessible(true);
-        Map<Long, Logger> loggers = (Map<Long, Logger>) lf.get(ls);
+        LogEntry le = new LogEntryImpl(bundle, sr, LogService.LOG_DEBUG, "test", null);
 
-        Logger testLogger = getMockInfoLogger();
-        loggers.put(1L, testLogger);
-
-        ls.fireLogEvent(le);
+        logSupport.fireLogEvent(le);
 
         // The log message is on DEBUG level while the logger is set to INFO level
         // we don't want the actual log.info() call to be made, neither do we want
@@ -101,29 +105,67 @@ public class LogSupportTest {
         Mockito.verifyZeroInteractions(sr);
     }
 
-    @Test @SuppressWarnings("unchecked")
+    @Test
     public void testErrorLogger() throws Exception {
-        Bundle b = Mockito.mock(Bundle.class);
-        Mockito.when(b.getSymbolicName()).thenReturn("bar.bundle");
-        Mockito.when(b.getBundleId()).thenReturn(1L);
-
+        
         Exception e = new Exception();
-        LogEntry le = new LogEntryImpl(b, null, LogService.LOG_ERROR, "my-error-msg", e);
-
-        StartLevel startLevel = Mockito.mock(StartLevel.class);
-        LogSupport ls = new LogSupport(startLevel);
-        Field lf = LogSupport.class.getDeclaredField("loggers");
-        lf.setAccessible(true);
-        Map<Long, Logger> loggers = (Map<Long, Logger>) lf.get(ls);
-
-        Logger testLogger = getMockInfoLogger();
-        loggers.put(1L, testLogger);
-
-        ls.fireLogEvent(le);
+        LogEntry le = new LogEntryImpl(bundle, null, LogService.LOG_ERROR, "my-error-msg", e);
 
+        logSupport.fireLogEvent(le);
+        
         Mockito.verify(testLogger).error("my-error-msg (java.lang.Exception)", e);
     }
+    
+	@Test
+    public void testWarningLogger() throws Exception {
+	    
+        Exception e = new Exception();
+        LogEntry le = new LogEntryImpl(bundle, null, LogService.LOG_WARNING, "my-warning-message", e);
 
+        logSupport.fireLogEvent(le);
+        
+        Mockito.verify(testLogger).warn("my-warning-message (java.lang.Exception)", e);
+    }
+	
+	@Test
+	public void testInfoLogger() throws Exception {
+	    
+        LogEntry le = new LogEntryImpl(bundle, null, LogService.LOG_INFO, "my-info-message", null);
+
+        logSupport.fireLogEvent(le);
+        
+        Mockito.verify(testLogger).info("my-info-message", (Throwable) null);
+	}
+
+	@Test
+	public void testBundleChanges() throws Exception {
+
+        logSupport.bundleChanged(new BundleEvent(BundleEvent.INSTALLED, bundle));
+
+        Mockito.verify(testLogger).info("BundleEvent INSTALLED", (Throwable) null);
+	}
+	
+	@Test
+	public void testFrameworkEventStarted() throws Exception {
+        
+        FrameworkEvent frameworkEvent = new FrameworkEvent(FrameworkEvent.STARTED, bundle, null);
+        
+        logSupport.frameworkEvent(frameworkEvent);
+        
+        Mockito.verify(testLogger).info("FrameworkEvent STARTED", (Throwable) null);
+	}
+	
+	@Test
+	public void testFrameworkEventError() throws Exception {
+
+	    BundleException bundleException = new BundleException("my bundle exception", BundleException.ACTIVATOR_ERROR);
+        FrameworkEvent frameworkEvent = new FrameworkEvent(FrameworkEvent.ERROR, bundle, bundleException);
+        
+        logSupport.frameworkEvent(frameworkEvent);
+        
+        Mockito.verify(testLogger).error("FrameworkEvent ERROR (org.osgi.framework.BundleException: my bundle exception)", bundleException);
+	}
+	
     @Test
     public void testGetLevels() {
         Logger traceLogger = Mockito.mock(Logger.class);

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

[sling-org-apache-sling-commons-logservice] 21/38: [maven-release-plugin] prepare release org.apache.sling.commons.logservice-1.0.4

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a6bf4444953b35e0efe2f4ce4cb9777fd32d9436
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Mar 30 12:24:39 2015 +0000

    [maven-release-plugin] prepare release org.apache.sling.commons.logservice-1.0.4
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1670073 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index b887eed..a0e7d86 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
     </parent>
 
     <artifactId>org.apache.sling.commons.logservice</artifactId>
-    <version>1.0.3-SNAPSHOT</version>
+    <version>1.0.4</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling OSGi LogService Implementation</name>
@@ -38,9 +38,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/logservice</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.logservice-1.0.4</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.logservice-1.0.4</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.commons.logservice-1.0.4</url>
     </scm>
     
     <build>

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

[sling-org-apache-sling-commons-logservice] 38/38: SLING-7167 Adjust READMEs

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 831c4b7dc342258b92a31879fe37464b028970f1
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Tue Oct 3 09:49:34 2017 +0000

    SLING-7167 Adjust READMEs
    
    add uniform header linking to Sling project
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1810818 13f79535-47bb-0310-9956-ffa450edef68
---
 README.md | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index ded02ca..e7eeb9a 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,6 @@
-Apache Sling OSGi LogService Implementation
+# Apache Sling OSGi LogService Implementation
 
+This module is part of the [Apache Sling](https://sling.apache.org) project.
 
 =================================================
 Welcome to Sling - OSGi LogService Implementation

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

[sling-org-apache-sling-commons-logservice] 25/38: SLING-4698 - Set parent.relativePath to empty for all modules

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1bd99ca2556532e449a40c6b93afbf01f55ffa77
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Thu May 7 10:14:40 2015 +0000

    SLING-4698 - Set parent.relativePath to empty for all modules
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1678154 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 01cbc8b..0099001 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
         <version>22</version>
-        <relativePath>../../../parent/pom.xml</relativePath>
+        <relativePath/>
     </parent>
 
     <artifactId>org.apache.sling.commons.logservice</artifactId>

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

[sling-org-apache-sling-commons-logservice] 14/38: Correct reactor pom and update to parent pom 16

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e540aae5572030a1d7ef09fd10d26cfaef8aa08f
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun May 5 14:38:24 2013 +0000

    Correct reactor pom and update to parent pom 16
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1479333 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index c40d8d9..7ebcf1a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>15</version>
+        <version>16</version>
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 

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

[sling-org-apache-sling-commons-logservice] 30/38: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 4b4598b24880c34ce979e496415144878a5ab00d
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Wed Oct 7 11:36:02 2015 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1707262 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index fe2b0bf..f7302f7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
     </parent>
 
     <artifactId>org.apache.sling.commons.logservice</artifactId>
-    <version>1.0.6</version>
+    <version>1.0.7-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling OSGi LogService Implementation</name>
@@ -38,9 +38,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.logservice-1.0.6</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.logservice-1.0.6</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.commons.logservice-1.0.6</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/logservice</url>
     </scm>
     
     <build>

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

[sling-org-apache-sling-commons-logservice] 37/38: SLING-7167 Adjust READMEs

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit be3093fd28d0d28dcaeafc6083666cc61806cd04
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Mon Oct 2 16:10:31 2017 +0000

    SLING-7167 Adjust READMEs
    
    switch from plain text to Markdown
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1810458 13f79535-47bb-0310-9956-ffa450edef68
---
 README.txt => README.md | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/README.txt b/README.md
similarity index 100%
rename from README.txt
rename to README.md

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

[sling-org-apache-sling-commons-logservice] 03/38: [maven-release-plugin] prepare release org.apache.sling.commons.logservice-1.0.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c1ff03927a9d801d4611c64617257f4d3cb74c71
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Jan 31 14:03:51 2012 +0000

    [maven-release-plugin] prepare release org.apache.sling.commons.logservice-1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1238552 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index de63690..b9fa37c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
     </parent>
 
     <artifactId>org.apache.sling.commons.logservice</artifactId>
-    <version>0.0.1-SNAPSHOT</version>
+    <version>1.0.0</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling OSGi LogService Implementation</name>
@@ -38,9 +38,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/logservice</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/logservice</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.logservice-1.0.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.logservice-1.0.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.commons.logservice-1.0.0</url>
     </scm>
     
     <build>

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

[sling-org-apache-sling-commons-logservice] 18/38: Updated to parent version 20

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 809a09e196c7f4d2f6328e562d1090ee4cfab1ad
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Fri Aug 1 19:16:26 2014 +0000

    Updated to parent version 20
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1615208 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index a933f03..3fa746f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>19</version>
+        <version>20</version>
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 

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

[sling-org-apache-sling-commons-logservice] 07/38: SLING-2486 Log bundle event synchronously and add logging for STARTING and STOPPING events

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 27d6ca7aef0b400d5ce39f0d3615c8262645d856
Author: Felix Meschberger <fm...@apache.org>
AuthorDate: Fri May 18 10:00:57 2012 +0000

    SLING-2486 Log bundle event synchronously and add logging for STARTING and STOPPING events
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1340058 13f79535-47bb-0310-9956-ffa450edef68
---
 .../commons/logservice/internal/LogSupport.java    | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

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 d40d6e0..4a703ea 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
@@ -26,13 +26,13 @@ import java.util.concurrent.LinkedBlockingQueue;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleException;
-import org.osgi.framework.BundleListener;
 import org.osgi.framework.Constants;
 import org.osgi.framework.FrameworkEvent;
 import org.osgi.framework.FrameworkListener;
 import org.osgi.framework.ServiceEvent;
 import org.osgi.framework.ServiceListener;
 import org.osgi.framework.ServiceReference;
+import org.osgi.framework.SynchronousBundleListener;
 import org.osgi.service.component.ComponentConstants;
 import org.osgi.service.log.LogEntry;
 import org.osgi.service.log.LogListener;
@@ -43,7 +43,7 @@ import org.slf4j.LoggerFactory;
 /**
  * The <code>LogReaderServiceFactory</code> TODO
  */
-public class LogSupport implements BundleListener, ServiceListener,
+public class LogSupport implements SynchronousBundleListener, ServiceListener,
         FrameworkListener {
 
     /**
@@ -228,15 +228,27 @@ public class LogSupport implements BundleListener, ServiceListener,
             case BundleEvent.INSTALLED:
                 message = "BundleEvent INSTALLED";
                 break;
+            case BundleEvent.RESOLVED:
+                message = "BundleEvent RESOLVED";
+                break;
+            case BundleEvent.STARTING:
+                message = "BundleEvent STARTING";
+                break;
             case BundleEvent.STARTED:
                 message = "BundleEvent STARTED";
                 break;
+            case BundleEvent.STOPPING:
+                message = "BundleEvent STOPPING";
+                break;
             case BundleEvent.STOPPED:
                 // this is special, as we have to fix the listener list for
                 // stopped bundles
                 removeLogListeners(event.getBundle());
                 message = "BundleEvent STOPPED";
                 break;
+            case BundleEvent.UNRESOLVED:
+                message = "BundleEvent UNRESOLVED";
+                break;
             case BundleEvent.UPDATED:
                 message = "BundleEvent UPDATED";
                 break;
@@ -245,12 +257,6 @@ public class LogSupport implements BundleListener, ServiceListener,
                 ungetLogger(event.getBundle());
                 message = "BundleEvent UNINSTALLED";
                 break;
-            case BundleEvent.RESOLVED:
-                message = "BundleEvent RESOLVED";
-                break;
-            case BundleEvent.UNRESOLVED:
-                message = "BundleEvent UNRESOLVED";
-                break;
             default:
                 message = "BundleEvent " + event.getType();
         }

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

[sling-org-apache-sling-commons-logservice] 05/38: SLING-2480 : Add config for maven-sling-plugin to m2e configuration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8500051e5802204344254c5286a2b979b1835118
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed May 16 07:39:13 2012 +0000

    SLING-2480 : Add config for maven-sling-plugin to m2e configuration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1339038 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 7186826..5a82498 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>12</version>
+        <version>13-SNAPSHOT</version>
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 

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

[sling-org-apache-sling-commons-logservice] 19/38: Update to Sling Parent POM 22 with baselining enabled

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1abc603487ae141d4a019acb7d89f7c3e9d1a498
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Oct 1 06:57:44 2014 +0000

    Update to Sling Parent POM 22 with baselining enabled
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1628622 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 3fa746f..978c77d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>20</version>
+        <version>22</version>
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 

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

[sling-org-apache-sling-commons-logservice] 16/38: Update to parent pom 18

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 11cce5cb3cd03354c66ee8adada47d12d048bdb1
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Sep 6 12:15:57 2013 +0000

    Update to parent pom 18
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1520554 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 1842e53..276f462 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>17</version>
+        <version>18</version>
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 

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

[sling-org-apache-sling-commons-logservice] 35/38: use Sling Parent 30

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6a3b4375a6a411a43e834421f86923a2d272af08
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Mon Mar 6 10:22:30 2017 +0000

    use Sling Parent 30
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1785621 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 241e9a6..ca4f107 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>29</version>
+        <version>30</version>
         <relativePath />
     </parent>
 

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

[sling-org-apache-sling-commons-logservice] 12/38: Use latest releases and update to new parent pom

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit cea6c28b80e19ac8f143afb3ba25af644ea4a7dd
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun Dec 23 06:53:35 2012 +0000

    Use latest releases and update to new parent pom
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1425425 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index ca2828e..cfcb550 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>13</version>
+        <version>14</version>
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 

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

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

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8968823d00f89df724374de5874a4d8a7b42a70c
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Apr 8 09:54:32 2015 +0000

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

diff --git a/src/main/java/org/apache/sling/commons/logservice/internal/Activator.java b/src/main/java/org/apache/sling/commons/logservice/internal/Activator.java
index 60766b5..60a4755 100644
--- a/src/main/java/org/apache/sling/commons/logservice/internal/Activator.java
+++ b/src/main/java/org/apache/sling/commons/logservice/internal/Activator.java
@@ -22,8 +22,10 @@ import java.util.Hashtable;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.log.LogReaderService;
 import org.osgi.service.log.LogService;
+import org.osgi.service.startlevel.StartLevel;
 
 /**
  * The <code>Activator</code> class is the <code>BundleActivator</code> for the
@@ -36,11 +38,17 @@ public class Activator implements BundleActivator {
 
     private LogSupport logSupport;
 
+    /** Reference to the start level service. */
+    private ServiceReference startLevelRef;
+
     /**
      * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
      */
     public void start(final BundleContext context) throws Exception {
-        logSupport = new LogSupport();
+        // get start level service, it's always there (required by the spec)
+        startLevelRef = context.getServiceReference(StartLevel.class.getName());
+
+        logSupport = new LogSupport((StartLevel)context.getService(startLevelRef));
         context.addBundleListener(logSupport);
         context.addFrameworkListener(logSupport);
         context.addServiceListener(logSupport);
@@ -66,6 +74,9 @@ public class Activator implements BundleActivator {
      * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
      */
     public void stop(final BundleContext context) throws Exception {
+        if ( startLevelRef != null ) {
+            context.ungetService(startLevelRef);
+        }
         if (logSupport != null) {
             context.removeBundleListener(logSupport);
             context.removeFrameworkListener(logSupport);
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 126e654..00be9c3 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
@@ -70,7 +70,7 @@ public class LogSupport implements SynchronousBundleListener, ServiceListener,
     // The loggers by bundle id used for logging messages originated from
     // specific bundles
     @SuppressWarnings("serial")
-    private Map<Long, Logger> loggers = new LinkedHashMap<Long, Logger>(16,
+    private final Map<Long, Logger> loggers = new LinkedHashMap<Long, Logger>(16,
         0.75f, true) {
         private static final int MAX_SIZE = 50;
 
@@ -81,11 +81,14 @@ public class LogSupport implements SynchronousBundleListener, ServiceListener,
     };
 
     // the worker thread actually sending LogEvents to LogListeners
-    private LogEntryDispatcher logEntryDispatcher;
+    private final LogEntryDispatcher logEntryDispatcher;
 
-    /* package */LogSupport() {
+    private final StartLevel startLevelService;
+
+    /* package */LogSupport(final StartLevel startLevelService) {
         logEntryDispatcher = new LogEntryDispatcher(this);
         logEntryDispatcher.start();
+        this.startLevelService = startLevelService;
     }
 
     /* package */void shutdown() {
@@ -348,12 +351,7 @@ public class LogSupport implements SynchronousBundleListener, ServiceListener,
                 message = "FrameworkEvent PACKAGES REFRESHED";
                 break;
             case 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();
+                message = "FrameworkEvent STARTLEVEL CHANGED to " + this.startLevelService.getStartLevel();
                 break;
             case FrameworkEvent.WARNING:
                 message = "FrameworkEvent WARNING";
diff --git a/src/test/java/org/apache/sling/commons/logservice/internal/LogSupportTest.java b/src/test/java/org/apache/sling/commons/logservice/internal/LogSupportTest.java
index 8c19d32..269ff49 100644
--- a/src/test/java/org/apache/sling/commons/logservice/internal/LogSupportTest.java
+++ b/src/test/java/org/apache/sling/commons/logservice/internal/LogSupportTest.java
@@ -32,12 +32,14 @@ import org.osgi.framework.ServiceEvent;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.log.LogEntry;
 import org.osgi.service.log.LogService;
+import org.osgi.service.startlevel.StartLevel;
 import org.slf4j.Logger;
 
 public class LogSupportTest {
     @Test @SuppressWarnings("unchecked")
     public void testServiceEvent() throws Exception {
-        LogSupport ls = new LogSupport();
+        StartLevel startLevel = Mockito.mock(StartLevel.class);
+        LogSupport ls = new LogSupport(startLevel);
         Field lf = LogSupport.class.getDeclaredField("loggers");
         lf.setAccessible(true);
         Map<Long, Logger> loggers = (Map<Long, Logger>) lf.get(ls);
@@ -77,7 +79,8 @@ public class LogSupportTest {
         ServiceReference sr = Mockito.mock(ServiceReference.class);
         LogEntry le = new LogEntryImpl(b, sr, LogService.LOG_DEBUG, "test", null);
 
-        LogSupport ls = new LogSupport();
+        StartLevel startLevel = Mockito.mock(StartLevel.class);
+        LogSupport ls = new LogSupport(startLevel);
         Field lf = LogSupport.class.getDeclaredField("loggers");
         lf.setAccessible(true);
         Map<Long, Logger> loggers = (Map<Long, Logger>) lf.get(ls);
@@ -107,7 +110,8 @@ public class LogSupportTest {
         Exception e = new Exception();
         LogEntry le = new LogEntryImpl(b, null, LogService.LOG_ERROR, "my-error-msg", e);
 
-        LogSupport ls = new LogSupport();
+        StartLevel startLevel = Mockito.mock(StartLevel.class);
+        LogSupport ls = new LogSupport(startLevel);
         Field lf = LogSupport.class.getDeclaredField("loggers");
         lf.setAccessible(true);
         Map<Long, Logger> loggers = (Map<Long, Logger>) lf.get(ls);

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

[sling-org-apache-sling-commons-logservice] 27/38: set parent version to 24 and add empty relativePath where missing

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c330abbf5f766a253e2b62b87d563ca3890e8a5f
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Tue Jul 7 08:09:17 2015 +0000

    set parent version to 24 and add empty relativePath where missing
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1689593 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index db41fdb..e58fd07 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>23</version>
+        <version>24</version>
         <relativePath/>
     </parent>
 

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

[sling-org-apache-sling-commons-logservice] 20/38: SLING-4510 : Sling LogService could provide more usable output. Apply patch from David Bosschaert

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 346270fa14d08f1447933af745f7493920e67f1d
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Mar 30 11:11:34 2015 +0000

    SLING-4510 : Sling LogService could provide more usable output. Apply patch from David Bosschaert
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1670052 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  11 ++
 .../commons/logservice/internal/LogSupport.java    |  36 +++--
 .../logservice/internal/LogSupportTest.java        | 155 +++++++++++++++++++++
 3 files changed, 188 insertions(+), 14 deletions(-)

diff --git a/pom.xml b/pom.xml
index 978c77d..b887eed 100644
--- a/pom.xml
+++ b/pom.xml
@@ -111,5 +111,16 @@
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>1.10.19</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>
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 4a703ea..78bf2b6 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
@@ -16,6 +16,7 @@
  */
 package org.apache.sling.commons.logservice.internal;
 
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.LinkedHashMap;
@@ -72,6 +73,7 @@ public class LogSupport implements SynchronousBundleListener, ServiceListener,
         0.75f, true) {
         private static final int MAX_SIZE = 50;
 
+        @Override
         protected boolean removeEldestEntry(Map.Entry<Long, Logger> eldest) {
             return size() > MAX_SIZE;
         }
@@ -290,11 +292,6 @@ public class LogSupport implements SynchronousBundleListener, ServiceListener,
                 message = "ServiceEvent " + event.getType();
         }
 
-        String s = (event.getServiceReference().getBundle() == null)
-                ? null
-                : "Bundle " + event.getServiceReference().getBundle();
-        s = (s == null) ? message : s + " " + message;
-
         LogEntry entry = new LogEntryImpl(
             event.getServiceReference().getBundle(),
             event.getServiceReference(), level, message, null);
@@ -362,10 +359,6 @@ public class LogSupport implements SynchronousBundleListener, ServiceListener,
                 message = "FrameworkEvent " + event.getType();
         }
 
-        String s = (event.getBundle() == null) ? null : "Bundle "
-            + event.getBundle();
-        s = (s == null) ? message : s + " " + message;
-
         LogEntry entry = new LogEntryImpl(event.getBundle(), null, level,
             message, exception);
         fireLogEvent(entry);
@@ -434,13 +427,13 @@ public class LogSupport implements SynchronousBundleListener, ServiceListener,
      * in the log entry.
      */
     private void logOut(LogEntry logEntry) {
-        // /* package */ void logOut(Bundle bundle, ServiceReference sr, int
-        // level, String message, Throwable exception) {
-
         // get the logger for the bundle
         Logger log = getLogger(logEntry.getBundle());
+        if (logEntry.getLevel() > getLevel(log))
+            // early Exit, this message will not be logged, don't do any work...
+            return;
 
-        StringBuffer msg = new StringBuffer();
+        final StringBuilder msg = new StringBuilder();
 
         ServiceReference sr = logEntry.getServiceReference();
         if (sr != null) {
@@ -453,7 +446,10 @@ public class LogSupport implements SynchronousBundleListener, ServiceListener,
                 msg.append(sr.getProperty(Constants.SERVICE_DESCRIPTION)).append(
                     ',');
             }
-            msg.append(sr.getProperty(Constants.SERVICE_ID)).append("] ");
+            msg.append(sr.getProperty(Constants.SERVICE_ID))
+                .append(", ")
+                .append(Arrays.toString((String[]) sr.getProperty(Constants.OBJECTCLASS)))
+                .append("] ");
         }
 
         if (logEntry.getMessage() != null) {
@@ -489,6 +485,18 @@ public class LogSupport implements SynchronousBundleListener, ServiceListener,
         }
     }
 
+    static int getLevel(Logger log) {
+        if (log.isTraceEnabled())
+            return LogService.LOG_DEBUG + 1; // No constant for trace in LogService
+        else if (log.isDebugEnabled())
+            return LogService.LOG_DEBUG;
+        else if (log.isInfoEnabled())
+            return LogService.LOG_INFO;
+        else if (log.isWarnEnabled())
+            return LogService.LOG_WARNING;
+        return LogService.LOG_ERROR;
+    }
+
     // ---------- internal class -----------------------------------------------
 
     /**
diff --git a/src/test/java/org/apache/sling/commons/logservice/internal/LogSupportTest.java b/src/test/java/org/apache/sling/commons/logservice/internal/LogSupportTest.java
new file mode 100644
index 0000000..8c19d32
--- /dev/null
+++ b/src/test/java/org/apache/sling/commons/logservice/internal/LogSupportTest.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.commons.logservice.internal;
+
+import static org.junit.Assert.assertEquals;
+
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogEntry;
+import org.osgi.service.log.LogService;
+import org.slf4j.Logger;
+
+public class LogSupportTest {
+    @Test @SuppressWarnings("unchecked")
+    public void testServiceEvent() throws Exception {
+        LogSupport ls = new LogSupport();
+        Field lf = LogSupport.class.getDeclaredField("loggers");
+        lf.setAccessible(true);
+        Map<Long, Logger> loggers = (Map<Long, Logger>) lf.get(ls);
+
+        Bundle b = Mockito.mock(Bundle.class);
+        Mockito.when(b.getSymbolicName()).thenReturn("foo.bundle");
+        Mockito.when(b.getBundleId()).thenReturn(42L);
+
+        final Map<String, Object> props = new HashMap<String, Object>();
+        props.put(Constants.OBJECTCLASS, new String [] {"some.class.Name"});
+        props.put(Constants.SERVICE_ID, 999L);
+
+        ServiceReference sr = Mockito.mock(ServiceReference.class);
+        Mockito.when(sr.getBundle()).thenReturn(b);
+        Mockito.when(sr.getProperty(Mockito.anyString())).then(new Answer<Object>() {
+            public Object answer(InvocationOnMock invocation) throws Throwable {
+                return props.get(invocation.getArguments()[0]);
+            }
+        });
+        Mockito.when(sr.getPropertyKeys()).thenReturn(props.keySet().toArray(new String[] {}));
+        ServiceEvent se = new ServiceEvent(ServiceEvent.REGISTERED, sr);
+
+        Logger testLogger = getMockInfoLogger();
+        loggers.put(42L, testLogger);
+
+        ls.serviceChanged(se);
+
+        Mockito.verify(testLogger).info("Service [999, [some.class.Name]] ServiceEvent REGISTERED", (Throwable) null);
+    }
+
+    @Test @SuppressWarnings("unchecked")
+    public void testEarlyExit() throws Exception {
+        Bundle b = Mockito.mock(Bundle.class);
+        Mockito.when(b.getSymbolicName()).thenReturn("bar.bundle");
+        Mockito.when(b.getBundleId()).thenReturn(1L);
+
+        ServiceReference sr = Mockito.mock(ServiceReference.class);
+        LogEntry le = new LogEntryImpl(b, sr, LogService.LOG_DEBUG, "test", null);
+
+        LogSupport ls = new LogSupport();
+        Field lf = LogSupport.class.getDeclaredField("loggers");
+        lf.setAccessible(true);
+        Map<Long, Logger> loggers = (Map<Long, Logger>) lf.get(ls);
+
+        Logger testLogger = getMockInfoLogger();
+        loggers.put(1L, testLogger);
+
+        ls.fireLogEvent(le);
+
+        // The log message is on DEBUG level while the logger is set to INFO level
+        // we don't want the actual log.info() call to be made, neither do we want
+        // any preparatory work on the log message being made (which involves
+        // inspecting the service reference).
+        Mockito.verify(testLogger).isTraceEnabled();
+        Mockito.verify(testLogger).isDebugEnabled();
+        Mockito.verify(testLogger).isInfoEnabled();
+        Mockito.verifyNoMoreInteractions(testLogger);
+        Mockito.verifyZeroInteractions(sr);
+    }
+
+    @Test @SuppressWarnings("unchecked")
+    public void testErrorLogger() throws Exception {
+        Bundle b = Mockito.mock(Bundle.class);
+        Mockito.when(b.getSymbolicName()).thenReturn("bar.bundle");
+        Mockito.when(b.getBundleId()).thenReturn(1L);
+
+        Exception e = new Exception();
+        LogEntry le = new LogEntryImpl(b, null, LogService.LOG_ERROR, "my-error-msg", e);
+
+        LogSupport ls = new LogSupport();
+        Field lf = LogSupport.class.getDeclaredField("loggers");
+        lf.setAccessible(true);
+        Map<Long, Logger> loggers = (Map<Long, Logger>) lf.get(ls);
+
+        Logger testLogger = getMockInfoLogger();
+        loggers.put(1L, testLogger);
+
+        ls.fireLogEvent(le);
+
+        Mockito.verify(testLogger).error("my-error-msg (java.lang.Exception)", e);
+    }
+
+    @Test
+    public void testGetLevels() {
+        Logger traceLogger = Mockito.mock(Logger.class);
+        Mockito.when(traceLogger.isTraceEnabled()).thenReturn(true);
+        assertEquals(5, LogSupport.getLevel(traceLogger));
+
+        Logger debugLogger = Mockito.mock(Logger.class);
+        Mockito.when(debugLogger.isDebugEnabled()).thenReturn(true);
+        assertEquals(LogService.LOG_DEBUG, LogSupport.getLevel(debugLogger));
+
+        Logger infoLogger = Mockito.mock(Logger.class);
+        Mockito.when(infoLogger.isInfoEnabled()).thenReturn(true);
+        assertEquals(LogService.LOG_INFO, LogSupport.getLevel(infoLogger));
+
+        Logger warnLogger = Mockito.mock(Logger.class);
+        Mockito.when(warnLogger.isWarnEnabled()).thenReturn(true);
+        assertEquals(LogService.LOG_WARNING, LogSupport.getLevel(warnLogger));
+
+        Logger errorLogger = Mockito.mock(Logger.class);
+        Mockito.when(errorLogger.isErrorEnabled()).thenReturn(true);
+        assertEquals(LogService.LOG_ERROR, LogSupport.getLevel(errorLogger));
+    }
+
+    private Logger getMockInfoLogger() {
+        Logger testLogger = Mockito.mock(Logger.class);
+        Mockito.when(testLogger.isTraceEnabled()).thenReturn(false);
+        Mockito.when(testLogger.isDebugEnabled()).thenReturn(false);
+        Mockito.when(testLogger.isInfoEnabled()).thenReturn(true);
+        Mockito.when(testLogger.isWarnEnabled()).thenReturn(true);
+        Mockito.when(testLogger.isErrorEnabled()).thenReturn(true);
+        return testLogger;
+    }
+}

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

[sling-org-apache-sling-commons-logservice] 13/38: Update to latest parent pom and use latest releases in launchpad

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit fae8a9e5e71d3a9cd60de1aef1b2a89051de481a
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Feb 18 08:38:52 2013 +0000

    Update to latest parent pom and use latest releases in launchpad
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1447147 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index cfcb550..c40d8d9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>14</version>
+        <version>15</version>
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 

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

[sling-org-apache-sling-commons-logservice] 28/38: Update the main reactor to parent 25

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e39b56eec01decfd521a5e4c5b4a1f3ce61a54a8
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Mon Oct 5 10:03:45 2015 +0000

    Update the main reactor to parent 25
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1706780 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index e58fd07..7e95e5c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>24</version>
+        <version>25</version>
         <relativePath/>
     </parent>
 

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

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

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ac130427018c87a9149f982c92b8cd0f24990e53
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@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>.