[jbosstools-commits] JBoss Tools SVN: r30587 - trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Apr 15 11:35:03 EDT 2011


Author: elvisisking
Date: 2011-04-15 11:35:03 -0400 (Fri, 15 Apr 2011)
New Revision: 30587

Added:
   trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/package-info.java
Modified:
   trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLogger.java
   trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLoggerFactory.java
Log:
JBIDE-8733 Problems With EclipseLogger When Running JUnit Tests. Logger now checking to see if platform is running before calling a method that requires a running Eclipse.

Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLogger.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLogger.java	2011-04-15 15:32:27 UTC (rev 30586)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLogger.java	2011-04-15 15:35:03 UTC (rev 30587)
@@ -26,15 +26,26 @@
  */
 public final class EclipseLogger implements Logger {
 
-    private static boolean DEBUG_MODE = Platform.inDebugMode()
-                                        && Boolean.parseBoolean(Platform.getDebugOption(IUiConstants.PLUGIN_ID + "/debug")); //$NON-NLS-1$
+    private static boolean initialized = false;
 
-    private static ILog LOGGER = Platform.getLog(Platform.getBundle(IUiConstants.PLUGIN_ID));
+    private static boolean DEBUG_MODE = Platform.isRunning();
 
+    private static ILog LOGGER; // will be null when platform is not running
+
     private String name;
 
     EclipseLogger( String name ) {
         this.name = name;
+
+        if (!initialized) {
+            initialized = true;
+
+            if (Platform.isRunning()) {
+                DEBUG_MODE = Platform.inDebugMode()
+                        && Boolean.parseBoolean(Platform.getDebugOption(IUiConstants.PLUGIN_ID + "/debug")); //$NON-NLS-1$
+                LOGGER = Platform.getLog(Platform.getBundle(IUiConstants.PLUGIN_ID));
+            }
+        }
     }
 
     /**
@@ -194,7 +205,7 @@
     @Override
     public void error( String message,
                        Throwable e ) {
-        if (isErrorEnabled()) {
+        if (isErrorEnabled() && (LOGGER != null)) {
             LOGGER.log(new Status(IStatus.ERROR, IUiConstants.PLUGIN_ID, message, e));
         }
     }
@@ -321,7 +332,7 @@
     @Override
     public void info( String message,
                       Throwable e ) {
-        if (isInfoEnabled()) {
+        if (isInfoEnabled() && (LOGGER != null)) {
             LOGGER.log(new Status(IStatus.INFO, IUiConstants.PLUGIN_ID, message, e));
         }
     }
@@ -655,7 +666,7 @@
     @Override
     public void warn( String message,
                       Throwable e ) {
-        if (isWarnEnabled()) {
+        if (isWarnEnabled() && (LOGGER != null)) {
             LOGGER.log(new Status(IStatus.WARNING, IUiConstants.PLUGIN_ID, message, e));
         }
     }

Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLoggerFactory.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLoggerFactory.java	2011-04-15 15:32:27 UTC (rev 30586)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLoggerFactory.java	2011-04-15 15:35:03 UTC (rev 30587)
@@ -13,33 +13,22 @@
 
 import java.util.HashMap;
 import java.util.Map;
+
 import org.slf4j.ILoggerFactory;
 import org.slf4j.Logger;
 
 public final class EclipseLoggerFactory implements ILoggerFactory {
 
-    // ===========================================================================================================================
-    // Class Fields
-    // ===========================================================================================================================
-
     /**
      * The shared instance of the factory.
      */
     static final EclipseLoggerFactory INSTANCE = new EclipseLoggerFactory();
 
-    // ===========================================================================================================================
-    // Methods
-    // ===========================================================================================================================
-
     /**
      * Map of loggers keyed by logger name.
      */
     private Map<String, Logger> loggerMap;
 
-    // ===========================================================================================================================
-    // Constructors
-    // ===========================================================================================================================
-
     /**
      * Constructs the factory.
      */
@@ -47,10 +36,6 @@
         this.loggerMap = new HashMap<String, Logger>();
     }
 
-    // ===========================================================================================================================
-    // Methods
-    // ===========================================================================================================================
-
     /**
      * {@inheritDoc}
      * 

Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/package-info.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/package-info.java	                        (rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/package-info.java	2011-04-15 15:35:03 UTC (rev 30587)
@@ -0,0 +1,15 @@
+/*
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.
+ *
+ * This software is made available by Red Hat, Inc. under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution and is
+ * available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ */
+/**
+ * The ModeShape REST Client Eclipse log package maps SLF4J logging from the ModeShape library to the Ecipse log.
+ */
+package org.jboss.tools.modeshape.rest.log;
\ No newline at end of file


Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/package-info.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain



More information about the jbosstools-commits mailing list