Commits

Sebastian Sdorra committed 208f53b

improve logging of new event api

Comments (0)

Files changed (1)

scm-core/src/main/java/sonia/scm/event/ScmEventBus.java

 
 import org.apache.shiro.concurrent.SubjectAwareExecutorService;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 //~--- JDK imports ------------------------------------------------------------
 
 import java.util.concurrent.Executors;
 public class ScmEventBus extends EventBus
 {
 
+  /**
+   * the logger for ScmEventBus
+   */
+  private static final Logger logger =
+    LoggerFactory.getLogger(ScmEventBus.class);
+
   /** Field description */
   private static ScmEventBus instance = new ScmEventBus();
 
   @Override
   public void post(Object event)
   {
+    logger.trace("post {} to event bus", event);
     asyncEventBus.post(event);
     eventBus.post(event);
   }
    */
   public void register(Object object, boolean async)
   {
+    logger.debug("register {} to event bus, async = {}", object, async);
+
     if (async)
     {
       asyncEventBus.register(object);
   @Override
   public void unregister(Object object)
   {
-    asyncEventBus.unregister(object);
-    eventBus.unregister(object);
+    logger.debug("unregister {} from event bus", object);
+    unregister(asyncEventBus, object);
+    unregister(eventBus, object);
+  }
+
+  /**
+   * Method description
+   *
+   *
+   * @param bus
+   * @param object
+   */
+  private void unregister(EventBus bus, Object object)
+  {
+    try
+    {
+      bus.unregister(object);
+    }
+    catch (IllegalArgumentException ex)
+    {
+      logger.debug("object {} was not registered at {}", object, bus);
+    }
   }
 
   //~--- fields ---------------------------------------------------------------
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.