Author: elvisisking
Date: 2011-04-15 12:39:28 -0400 (Fri, 15 Apr 2011)
New Revision: 30594
Added:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/package-info.java
Modified:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLogger.java
branches/jbosstools-3.2.x/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 checks to see
if platform is running before calling methods that assume the Eclipse platform is
running.
Modified:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLogger.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLogger.java 2011-04-15
16:07:50 UTC (rev 30593)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLogger.java 2011-04-15
16:39:28 UTC (rev 30594)
@@ -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:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLoggerFactory.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLoggerFactory.java 2011-04-15
16:07:50 UTC (rev 30593)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/EclipseLoggerFactory.java 2011-04-15
16:39:28 UTC (rev 30594)
@@ -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:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/package-info.java
===================================================================
---
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/package-info.java
(rev 0)
+++
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/package-info.java 2011-04-15
16:39:28 UTC (rev 30594)
@@ -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:
branches/jbosstools-3.2.x/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/log/package-info.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain