tmf.ui: Add JUL statements to CommonXLineChart
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Tue, 19 Jul 2016 19:37:54 +0000 (15:37 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Wed, 12 Oct 2016 13:20:45 +0000 (09:20 -0400)
Change-Id: I0ad7a2b0304ce19f7e8719d2a0f3998216bb066b
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/78275
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/linecharts/TmfCommonXLineChartViewer.java

index 72a89a297d2beeb6543b6e32bdfe940cb68bb909..1bf9e503bb89ca718ba9b99fabf08e5e5d28c1ab 100644 (file)
@@ -15,13 +15,16 @@ package org.eclipse.tracecompass.tmf.ui.viewers.xycharts.linecharts;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.logging.Logger;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
+import org.eclipse.tracecompass.common.core.log.TraceCompassLog;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentInfo;
@@ -52,6 +55,9 @@ public abstract class TmfCommonXLineChartViewer extends TmfXYChartViewer {
 
     /* The desired number of points per pixel */
     private static final double RESOLUTION = 1.0;
+    private static final Logger LOGGER = TraceCompassLog.getLogger(TmfCommonXLineChartViewer.class);
+    private static final String LOG_STRING_WITH_PARAM = "[TmfCommonXLineChart:%s] viewerId=%s, %s"; //$NON-NLS-1$
+    private static final String LOG_STRING = "[TmfCommonXLineChart:%s] viewerId=%s"; //$NON-NLS-1$
 
     private static final int[] LINE_COLORS = { SWT.COLOR_BLUE, SWT.COLOR_RED, SWT.COLOR_GREEN,
             SWT.COLOR_MAGENTA, SWT.COLOR_CYAN,
@@ -103,6 +109,25 @@ public abstract class TmfCommonXLineChartViewer extends TmfXYChartViewer {
         reinitialize();
     }
 
+    /**
+     * Formats a log message for this class
+     *
+     * @param event
+     *            The event to log, that will be appended to the class name to
+     *            make the full event name
+     * @param parameters
+     *            The string of extra parameters to add to the log message, in
+     *            the format name=value[, name=value]*, or <code>null</code> for
+     *            no params
+     * @return The complete log message for this class
+     */
+    private String getLogMessage(String event, @Nullable String parameters) {
+        if (parameters == null) {
+            return String.format(LOG_STRING, event, getClass().getName());
+        }
+        return String.format(LOG_STRING_WITH_PARAM, event, getClass().getName(), parameters);
+    }
+
     /**
      * Forces a reinitialization of the data sources, even if it has already
      * been initialized for this trace before
@@ -113,6 +138,7 @@ public abstract class TmfCommonXLineChartViewer extends TmfXYChartViewer {
             // Don't use TmfUiRefreshHandler (bug 467751)
             @Override
             public void run() {
+                LOGGER.info(() -> getLogMessage("InitializeThreadStart", "tid=" + getId())); //$NON-NLS-1$ //$NON-NLS-2$
                 initializeDataSource();
                 if (!getSwtChart().isDisposed()) {
                     getDisplay().asyncExec(new Runnable() {
@@ -126,6 +152,7 @@ public abstract class TmfCommonXLineChartViewer extends TmfXYChartViewer {
                         }
                     });
                 }
+                LOGGER.info(() -> getLogMessage("InitializeThreadEnd", "tid=" + getId())); //$NON-NLS-1$ //$NON-NLS-2$
             }
         };
         thread.start();
@@ -152,16 +179,21 @@ public abstract class TmfCommonXLineChartViewer extends TmfXYChartViewer {
 
         @Override
         public void run() {
+            LOGGER.info(() -> getLogMessage("UpdateThreadStart", "numRequests=" + fNumRequests + ", tid=" + getId())); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
             Display.getDefault().syncExec(new Runnable() {
                 @Override
                 public void run() {
+                    LOGGER.info(() -> getLogMessage("UpdateDataStart", "tid=" + getId())); //$NON-NLS-1$ //$NON-NLS-2$
                     updateData(getWindowStartTime(), getWindowEndTime(), fNumRequests, fMonitor);
+                    LOGGER.info(() -> getLogMessage("UpdateDataEnd", "tid=" + getId())); //$NON-NLS-1$ //$NON-NLS-2$
                 }
             });
             updateThreadFinished(this);
+            LOGGER.info(() -> getLogMessage("UpdateThreadEnd", "tid=" + getId())); //$NON-NLS-1$ //$NON-NLS-2$
         }
 
         public void cancel() {
+            LOGGER.info(() -> getLogMessage("UpdateThreadCanceled", "tid=" + getId())); //$NON-NLS-1$ //$NON-NLS-2$
             fMonitor.setCanceled(true);
         }
     }
This page took 0.025558 seconds and 5 git commands to generate.