Author: xcoulon
Date: 2012-02-23 05:01:06 -0500 (Thu, 23 Feb 2012)
New Revision: 39043
Modified:
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/.options
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/Logger.java
Log:
Fixed - JBIDE-11006 - JAXRS builder now installed is logged
https://issues.jboss.org/browse/JBIDE-11006
Modified:
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/.options
===================================================================
---
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/.options 2012-02-23
09:44:37 UTC (rev 39042)
+++
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/.options 2012-02-23
10:01:06 UTC (rev 39043)
@@ -1,3 +1,4 @@
# This file enables runtime tracing
+org.jboss.tools.ws.jaxrs.core/info=true
org.jboss.tools.ws.jaxrs.core/debug=true
org.jboss.tools.ws.jaxrs.core/trace=false
\ No newline at end of file
Modified:
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/Logger.java
===================================================================
---
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/Logger.java 2012-02-23
09:44:37 UTC (rev 39042)
+++
branches/jbosstools-3.3.0.Beta1/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/Logger.java 2012-02-23
10:01:06 UTC (rev 39043)
@@ -35,6 +35,9 @@
*/
public final class Logger {
+ /** The 'info' level name, matching the .options file. */
+ private static final String INFO = JBossJaxrsCorePlugin.PLUGIN_ID + "/info";
+
/** The 'debug' level name, matching the .options file. */
private static final String DEBUG = JBossJaxrsCorePlugin.PLUGIN_ID +
"/debug";
@@ -63,9 +66,9 @@
* the throwable cause
*/
public static void error(final String message, final Throwable t) {
- if(JBossJaxrsCorePlugin.getDefault() != null) {
- JBossJaxrsCorePlugin.getDefault().getLog()
- .log(new Status(Status.ERROR, JBossJaxrsCorePlugin.PLUGIN_ID, message, t));
+ if (JBossJaxrsCorePlugin.getDefault() != null) {
+ JBossJaxrsCorePlugin.getDefault().getLog()
+ .log(new Status(Status.ERROR, JBossJaxrsCorePlugin.PLUGIN_ID, message, t));
} else {
// at least write in the .log file
t.printStackTrace();
@@ -108,20 +111,22 @@
}
/**
- * Logs a message with an 'info' severity.
+ * Logs a message with an 'info' severity, if the 'INFO' tracing option
is enabled, to avoid unwanted extra
+ * messages in the error log.
*
* @param message
* the message to log
*/
public static void info(String message) {
- JBossJaxrsCorePlugin.getDefault().getLog()
- .log(new Status(Status.INFO, JBossJaxrsCorePlugin.PLUGIN_ID, message));
+ if (isOptionEnabled(INFO)) {
+ JBossJaxrsCorePlugin.getDefault().getLog()
+ .log(new Status(Status.INFO, JBossJaxrsCorePlugin.PLUGIN_ID, message));
+ }
}
/**
- * Outputs a debug message in the trace file (not the error view of the
- * runtime workbench). Traces must be activated for this plugin in order to
- * see the output messages.
+ * Outputs a debug message in the trace file (not the error view of the runtime
workbench). Traces must be activated
+ * for this plugin in order to see the output messages.
*
* @param message
* the message to trace.
@@ -132,9 +137,8 @@
}
/**
- * Outputs a 'debug' level message in the .log file (not the error view of
- * the runtime workbench). Traces must be activated for this plugin in order
- * to see the output messages.
+ * Outputs a 'debug' level message in the .log file (not the error view of the
runtime workbench). Traces must be
+ * activated for this plugin in order to see the output messages.
*
* @param message
* the message to trace.
@@ -144,9 +148,8 @@
}
/**
- * Outputs a 'trace' level message in the .log file (not the error view of
- * the runtime workbench). Traces must be activated for this plugin in order
- * to see the output messages.
+ * Outputs a 'trace' level message in the .log file (not the error view of the
runtime workbench). Traces must be
+ * activated for this plugin in order to see the output messages.
*
* @param message
* the message to trace.
@@ -157,10 +160,8 @@
private static void log(final String level, final String message, final Object... items)
{
try {
- String debugOption = Platform.getDebugOption(level);
- String valuedMessage = message;
- if (JBossJaxrsCorePlugin.getDefault() != null &&
JBossJaxrsCorePlugin.getDefault().isDebugging()
- && "true".equalsIgnoreCase(debugOption)) {
+ if (isOptionEnabled(level)) {
+ String valuedMessage = message;
if (items != null) {
for (Object item : items) {
valuedMessage = valuedMessage.replaceFirst("\\{\\}", (item != null ?
item.toString()
@@ -177,4 +178,10 @@
}
}
}
+
+ private static boolean isOptionEnabled(String level) {
+ final String debugOption = Platform.getDebugOption(level);
+ return JBossJaxrsCorePlugin.getDefault() != null &&
JBossJaxrsCorePlugin.getDefault().isDebugging()
+ && "true".equalsIgnoreCase(debugOption);
+ }
}