common: Allow null messages in Activator logging helpers
authorAlexandre Montplaisir <alexmonthy@efficios.com>
Mon, 22 Feb 2016 22:49:48 +0000 (17:49 -0500)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Fri, 26 Feb 2016 02:11:06 +0000 (21:11 -0500)
A very common message is e.getMessage(), which is not technically
guaranteed to be non-null, it would depend on the exception.

Allow the log messages to be null, we can convert them to empty
strings as needed.

Change-Id: I34695fd96368837547e8f74841668cb0b5c0c9a8
Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Reviewed-on: https://git.eclipse.org/r/67183
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
common/org.eclipse.tracecompass.common.core/src/org/eclipse/tracecompass/common/core/TraceCompassActivator.java

index 5b494affce2e20ee2210266e9545989a2cd4dff9..5e2cc18feae4f427e61104f21b209ec21fd0686d 100644 (file)
@@ -13,6 +13,7 @@
 package org.eclipse.tracecompass.common.core;
 
 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString;
 
 import java.util.Collections;
 import java.util.HashMap;
@@ -134,8 +135,8 @@ public abstract class TraceCompassActivator extends Plugin {
      * @param message
      *            A message to log
      */
-    public void logInfo(String message) {
-        getLog().log(new Status(IStatus.INFO, fPluginId, message));
+    public void logInfo(@Nullable String message) {
+        getLog().log(new Status(IStatus.INFO, fPluginId, nullToEmptyString(message)));
     }
 
     /**
@@ -147,8 +148,8 @@ public abstract class TraceCompassActivator extends Plugin {
      * @param exception
      *            A exception to log
      */
-    public void logInfo(String message, Throwable exception) {
-        getLog().log(new Status(IStatus.INFO, fPluginId, message, exception));
+    public void logInfo(@Nullable String message, Throwable exception) {
+        getLog().log(new Status(IStatus.INFO, fPluginId, nullToEmptyString(message), exception));
     }
 
     /**
@@ -158,8 +159,8 @@ public abstract class TraceCompassActivator extends Plugin {
      * @param message
      *            A message to log
      */
-    public void logWarning(String message) {
-        getLog().log(new Status(IStatus.WARNING, fPluginId, message));
+    public void logWarning(@Nullable String message) {
+        getLog().log(new Status(IStatus.WARNING, fPluginId, nullToEmptyString(message)));
     }
 
     /**
@@ -171,8 +172,8 @@ public abstract class TraceCompassActivator extends Plugin {
      * @param exception
      *            A exception to log
      */
-    public void logWarning(String message, Throwable exception) {
-        getLog().log(new Status(IStatus.WARNING, fPluginId, message, exception));
+    public void logWarning(@Nullable String message, Throwable exception) {
+        getLog().log(new Status(IStatus.WARNING, fPluginId, nullToEmptyString(message), exception));
     }
 
     /**
@@ -182,8 +183,8 @@ public abstract class TraceCompassActivator extends Plugin {
      * @param message
      *            A message to log
      */
-    public void logError(String message) {
-        getLog().log(new Status(IStatus.ERROR, fPluginId, message));
+    public void logError(@Nullable String message) {
+        getLog().log(new Status(IStatus.ERROR, fPluginId, nullToEmptyString(message)));
     }
 
     /**
@@ -195,8 +196,8 @@ public abstract class TraceCompassActivator extends Plugin {
      * @param exception
      *            A exception to log
      */
-    public void logError(String message, Throwable exception) {
-        getLog().log(new Status(IStatus.ERROR, fPluginId, message, exception));
+    public void logError(@Nullable String message, Throwable exception) {
+        getLog().log(new Status(IStatus.ERROR, fPluginId, nullToEmptyString(message), exception));
     }
 
 }
This page took 0.028799 seconds and 5 git commands to generate.