Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.0.0.qualifier
+Bundle-Version: 2.1.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.tracecompass.common.core;singleton:=true
Bundle-Activator: org.eclipse.tracecompass.internal.common.core.Activator
Export-Package: org.eclipse.tracecompass.common.core,
org.eclipse.tracecompass.common.core.collect,
org.eclipse.tracecompass.common.core.format,
+ org.eclipse.tracecompass.common.core.log,
org.eclipse.tracecompass.internal.common.core;x-internal:=true
Import-Package: com.google.common.collect
--- /dev/null
+class java/util/logging/Logger
+getLogger
+ (Ljava/lang/String;)Ljava/util/logging/Logger;
+ (Ljava/lang/String;)L1java/util/logging/Logger;
+
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2016 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.common.core.log;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Utility class containing methods to support logging in Trace Compass
+ *
+ * @author Geneviève Bastien
+ * @since 2.1
+ */
+public final class TraceCompassLog {
+
+ private static final String LOGGING_PROPERTY = "org.eclipse.tracecompass.logging"; //$NON-NLS-1$
+ private static final Logger TC_PARENT_LOGGER = Logger.getLogger("org.eclipse.tracecompass"); //$NON-NLS-1$
+
+ static {
+ /*
+ * If Logging is not enabled, to avoid java's default parameters, we set
+ * the main TraceCompass logger to not use its parent's logs and set the
+ * level at OFF
+ */
+ String loggingProperty = System.getProperty(LOGGING_PROPERTY);
+ if (!"true".equals(loggingProperty)) { //$NON-NLS-1$
+ TC_PARENT_LOGGER.setUseParentHandlers(false);
+ TC_PARENT_LOGGER.setLevel(Level.OFF);
+ }
+ }
+
+ private TraceCompassLog() {
+ }
+
+ /**
+ * Get a logger by name. Calling this method instead of directly
+ * {@link Logger#getLogger(String)} insures that the main Trace Compass
+ * logger has been initialized to default value instead of using java's
+ * default parameters.
+ *
+ * @param name
+ * The name of the logger to get. It is advised to use something
+ * like {@link Class#getCanonicalName()}, as it will use the full
+ * path of the logged class and the logging can be controlled for
+ * its parent as well.
+ * @return The logger
+ */
+ public static Logger getLogger(String name) {
+ return Logger.getLogger(name);
+ }
+
+ /**
+ * Get a logger for a class
+ *
+ * @param clazz
+ * The class to get a logger for
+ * @return The logger
+ */
+ public static Logger getLogger(Class<?> clazz) {
+ return Logger.getLogger(clazz.getName());
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2016 École Polytechnique de Montréal and others
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available 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
+ *******************************************************************************/
+
+@org.eclipse.jdt.annotation.NonNullByDefault
+package org.eclipse.tracecompass.common.core.log;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.logging.Logger;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.common.core.log.TraceCompassLog;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
/** The trace to state system multi map */
private final Multimap<ITmfTrace, ITmfStateSystem> fTraceSSMap = HashMultimap.create();
+ /** Instance-specific logger, which will use the concrete class's name */
+ private final Logger fLogger = TraceCompassLog.getLogger(getClass());
+
// ------------------------------------------------------------------------
// Classes
// ------------------------------------------------------------------------
getTimeGraphViewer().setLinks(links);
getTimeGraphViewer().setMarkers(markers);
});
+ } else {
+ fLogger.info(() -> "[TimeGraphView:ZoomThreadCanceled]"); //$NON-NLS-1$
}
}
queryFullStates(ss, start, end, resolution, monitor, new IQueryHandler() {
@Override
public void handle(@NonNull List<List<ITmfStateInterval>> fullStates, @Nullable List<ITmfStateInterval> prevFullState) {
+ fLogger.config(() -> "[TimeGraphView:ZoomThreadGettingStates]"); //$NON-NLS-1$
if (!fullRange) {
for (TimeGraphEntry entry : entryList) {
zoom(checkNotNull(entry), ss, fullStates, prevFullState, monitor);
}
}
/* Refresh the arrows when zooming */
+ fLogger.config(() -> "[TimeGraphView:ZoomThreadGettingLinks]"); //$NON-NLS-1$
links.addAll(getLinkList(ss, fullStates, prevFullState, monitor));
/* Refresh the view-specific markers when zooming */
+ fLogger.config(() -> "[TimeGraphView:ZoomThreadGettingMarkers]"); //$NON-NLS-1$
markers.addAll(getViewMarkerList(ss, fullStates, prevFullState, monitor));
+ fLogger.config(() -> "[TimeGraphView:ZoomThreadDone]"); //$NON-NLS-1$
}
});
refresh();
}
for (TimeGraphEntry child : entry.getChildren()) {
if (monitor.isCanceled()) {
+ fLogger.info(() -> "[TimeGraphView:ZoomThreadCanceled]"); //$NON-NLS-1$
return;
}
zoom(child, ss, fullStates, prevFullState, monitor);
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.tracecompass.common.core.log.TraceCompassLog;
import org.eclipse.tracecompass.internal.tmf.ui.Activator;
import org.eclipse.tracecompass.tmf.core.resources.ITmfMarker;
import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
private static final Pattern RGBA_PATTERN = Pattern.compile("RGBA \\{(\\d+), (\\d+), (\\d+), (\\d+)\\}"); //$NON-NLS-1$
+ /** Instance-specific logger, which will use the concrete class's name */
+ private final Logger fLogger = TraceCompassLog.getLogger(getClass());
+
/**
* Redraw state enum
*/
@Override
public void run() {
+ fLogger.info(() -> "[TimeGraphView:BuildThreadStart] trace=" + fBuildTrace.getName()); //$NON-NLS-1$
+
buildEntryList(fBuildTrace, fParentTrace, fMonitor);
synchronized (fBuildThreadMap) {
fBuildThreadMap.remove(fBuildTrace);
}
+
+ fLogger.info(() -> "[TimeGraphView:BuildThreadEnd]"); //$NON-NLS-1$
}
public void cancel() {
@Override
public final void run() {
+ fLogger.info(() -> "[TimeGraphView:ZoomThreadStart] start=" + fZoomStartTime + ", end=" + fZoomEndTime); //$NON-NLS-1$ //$NON-NLS-2$
+
doRun();
fDirty.decrementAndGet();
+
+ fLogger.info(() -> "[TimeGraphView:ZoomThreadEnd]"); //$NON-NLS-1$
}
/**
@Override
public void doRun() {
+ fLogger.config(() -> "[TimeGraphView:ZoomThreadGettingStates]"); //$NON-NLS-1$
+
for (TimeGraphEntry entry : fZoomEntryList) {
if (getMonitor().isCanceled()) {
+ fLogger.info(() -> "[TimeGraphView:ZoomThreadCanceled]"); //$NON-NLS-1$
return;
}
if (entry == null) {
zoom(entry, getMonitor());
}
/* Refresh the arrows when zooming */
+ fLogger.config(() -> "[TimeGraphView:ZoomThreadGettingLinks]"); //$NON-NLS-1$
List<ILinkEvent> events = getLinkList(getZoomStartTime(), getZoomEndTime(), getResolution(), getMonitor());
+
/* Refresh the view-specific markers when zooming */
+ fLogger.config(() -> "[TimeGraphView:ZoomThreadGettingMarkers]"); //$NON-NLS-1$
List<IMarkerEvent> markers = new ArrayList<>(getViewMarkerList(getZoomStartTime(), getZoomEndTime(), getResolution(), getMonitor()));
/* Refresh the trace-specific markers when zooming */
markers.addAll(getTraceMarkerList(getZoomStartTime(), getZoomEndTime(), getResolution(), getMonitor()));
fViewContext.put(fTrace, new ViewContext(fCurrentSortColumn, fSortDirection, fTimeGraphWrapper.getSelection()));
}
fTrace = trace;
+
+ fLogger.info(() -> "[TimeGraphView:LoadingTrace] trace=" + trace.getName()); //$NON-NLS-1$
+
restoreViewContext();
fEditorFile = TmfTraceManager.getInstance().getTraceEditorFile(trace);
synchronized (fEntryListMap) {
* Refresh the display
*/
protected void refresh() {
+ fLogger.info(() -> "[TimeGraphView:RefreshRequested]"); //$NON-NLS-1$
final boolean zoomThread = Thread.currentThread() instanceof ZoomThread;
TmfUiRefreshHandler.getInstance().queueUpdate(this, new Runnable() {
@Override
public void run() {
+ fLogger.info(() -> "[TimeGraphView:RefreshStart]"); //$NON-NLS-1$
if (fTimeGraphWrapper.isDisposed()) {
return;
}
startZoomThread(startTime, endTime);
}
fDirty.decrementAndGet();
+ fLogger.info(() -> "[TimeGraphView:RefreshEnd]"); //$NON-NLS-1$
}
});
}
return;
}
}
+ fLogger.info(() -> "[TimeGraphView:RedrawRequested]"); //$NON-NLS-1$
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
+ fLogger.info(() -> "[TimeGraphView:RedrawStart]"); //$NON-NLS-1$
if (fTimeGraphWrapper.isDisposed()) {
return;
}
fRedrawState = State.IDLE;
}
}
+ fLogger.info(() -> "[TimeGraphView:RedrawEnd]"); //$NON-NLS-1$
}
});
}