[maven-release-plugin]  copy for tag org.apache.felix.eventadmin-1.2.8

git-svn-id: https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.eventadmin-1.2.8@1040730 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/changelog.txt b/changelog.txt
index 358a84c..dda8c3d 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,3 +1,10 @@
+Changes from 1.2.6 to 1.2.8
+---------------------------
+
+** Improvement
+    * [FELIX-2655] - allow event admin log level to be configurable
+
+
 Changes from 1.2.4 to 1.2.6
 ---------------------------
 
diff --git a/pom.xml b/pom.xml
index 8d10fd2..70b2790 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,12 +29,12 @@
     <description>
 	    This bundle provides an implementation of the OSGi R4 EventAdmin service.
     </description>
-    <version>1.2.7-SNAPSHOT</version>
+    <version>1.2.8</version>
     <artifactId>org.apache.felix.eventadmin</artifactId>
     <scm>
-      <connection>scm:svn:http://svn.apache.org/repos/asf/felix/trunk/eventadmin/impl</connection>
-      <developerConnection>scm:svn:http://svn.apache.org/repos/asf/felix/trunk/eventadmin/impl</developerConnection>
-      <url>http://svn.apache.org/repos/asf/felix/eventadmin/impl</url>
+      <connection>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.eventadmin-1.2.8</connection>
+      <developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.eventadmin-1.2.8</developerConnection>
+      <url>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.eventadmin-1.2.8</url>
     </scm>
     <dependencies>
         <dependency>
diff --git a/src/main/java/org/apache/felix/eventadmin/impl/Configuration.java b/src/main/java/org/apache/felix/eventadmin/impl/Configuration.java
index 94c8c16..858b092 100644
--- a/src/main/java/org/apache/felix/eventadmin/impl/Configuration.java
+++ b/src/main/java/org/apache/felix/eventadmin/impl/Configuration.java
@@ -107,6 +107,7 @@
     static final String PROP_TIMEOUT = "org.apache.felix.eventadmin.Timeout";
     static final String PROP_REQUIRE_TOPIC = "org.apache.felix.eventadmin.RequireTopic";
     static final String PROP_IGNORE_TIMEOUT = "org.apache.felix.eventadmin.IgnoreTimeout";
+    static final String PROP_LOG_LEVEL = "org.apache.felix.eventadmin.LogLevel";
 
     /** The bundle context. */
     private final BundleContext m_bundleContext;
@@ -121,6 +122,8 @@
 
     private String[] m_ignoreTimeout;
 
+    private int m_logLevel;
+
     // The thread pool used - this is a member because we need to close it on stop
     private volatile DefaultThreadPool m_sync_pool;
 
@@ -250,6 +253,10 @@
                     m_ignoreTimeout[i] = st.nextToken();
                 }
             }
+            m_logLevel = getIntProperty(PROP_LOG_LEVEL,
+                    m_bundleContext.getProperty(PROP_LOG_LEVEL),
+                    LogWrapper.LOG_WARNING, // default log level is WARNING
+                    LogWrapper.LOG_ERROR);
         }
         else
         {
@@ -272,6 +279,10 @@
                 LogWrapper.getLogger().log(LogWrapper.LOG_WARNING,
                         "Value for property: " + PROP_IGNORE_TIMEOUT + " is neither a string nor a string array - Using default");
             }
+            m_logLevel = getIntProperty(PROP_LOG_LEVEL,
+                    config.get(PROP_LOG_LEVEL),
+                    LogWrapper.LOG_WARNING, // default log level is WARNING
+                    LogWrapper.LOG_ERROR);
         }
         // a timeout less or equals to 100 means : disable timeout
         if ( m_timeout <= 100 )
@@ -282,6 +293,9 @@
 
     private void startOrUpdate()
     {
+        LogWrapper.getLogger().setLogLevel(m_logLevel);
+        LogWrapper.getLogger().log(LogWrapper.LOG_DEBUG,
+                PROP_LOG_LEVEL + "=" + m_logLevel);
         LogWrapper.getLogger().log(LogWrapper.LOG_DEBUG,
                 PROP_CACHE_SIZE + "=" + m_cacheSize);
         LogWrapper.getLogger().log(LogWrapper.LOG_DEBUG,
diff --git a/src/main/java/org/apache/felix/eventadmin/impl/util/LogWrapper.java b/src/main/java/org/apache/felix/eventadmin/impl/util/LogWrapper.java
index 85ab3b1..7e7f0e8 100644
--- a/src/main/java/org/apache/felix/eventadmin/impl/util/LogWrapper.java
+++ b/src/main/java/org/apache/felix/eventadmin/impl/util/LogWrapper.java
@@ -43,6 +43,10 @@
  * use it if present. Additionally, all log methods prefix the log message with
  * <tt>EventAdmin: </tt>.
  *
+ * There is one difference in behavior from the standard OSGi LogService.
+ * This logger has a {@link #m_logLevel} property which decides what messages
+ * get logged.
+ *
  * @see org.osgi.service.log.LogService
  *
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
@@ -88,6 +92,15 @@
     private BundleContext m_context;
 
     private ServiceListener m_logServiceListener;
+
+    /**
+     * Current log level. Message with log level less than or equal to
+     * current log level will be logged.
+     * The default value is {@link #LOG_WARNING}
+     *
+     * @see #setLogLevel(int)
+     */
+    private int m_logLevel = LOG_WARNING;
     /*
      * A thread save variant of the double checked locking singleton.
      */
@@ -230,6 +243,11 @@
         // The method will remove any unregistered service reference as well.
         synchronized(m_loggerRefs)
         {
+            if (level > m_logLevel)
+            {
+                return; // don't log
+            }
+
             final String logMsg = "EventAdmin: " + msg;
 
             if (!m_loggerRefs.isEmpty())
@@ -277,6 +295,11 @@
         // The method will remove any unregistered service reference as well.
         synchronized(m_loggerRefs)
         {
+            if (level > m_logLevel)
+            {
+                return; // don't log
+            }
+
             final String logMsg = "EventAdmin: " + msg;
 
             if (!m_loggerRefs.isEmpty())
@@ -324,6 +347,11 @@
         // The method will remove any unregistered service reference as well.
         synchronized(m_loggerRefs)
         {
+            if (level > m_logLevel)
+            {
+                return; // don't log
+            }
+
             final String logMsg = "EventAdmin: " + msg;
 
             if (!m_loggerRefs.isEmpty())
@@ -373,6 +401,11 @@
         // The method will remove any unregistered service reference as well.
         synchronized(m_loggerRefs)
         {
+            if (level > m_logLevel)
+            {
+                return; // don't log
+            }
+            
             final String logMsg = "EventAdmin: " + msg;
 
             if (!m_loggerRefs.isEmpty())
@@ -446,4 +479,30 @@
                 System.out.println("UNKNOWN[" + level + "]: " + s);
         }
     }
+
+    /**
+     * Change the current log level. Log level decides what messages gets
+     * logged. Any message with a log level higher than the currently set
+     * log level is not logged.
+     *
+     * @param logLevel new log level
+     */
+    public void setLogLevel(int logLevel)
+    {
+        synchronized (m_loggerRefs)
+        {
+            m_logLevel = logLevel;
+        }
+    }
+
+    /**
+     * @return current log level.
+     */
+    public int getLogLevel()
+    {
+        synchronized (m_loggerRefs)
+        {
+            return m_logLevel;
+        }
+    }
 }