Skip to content

Commit

Permalink
Change system.out.println to Activator.logWarning or Activator.logInfo
Browse files Browse the repository at this point in the history
This change is done in order to have all the warning store in the
warning log of the workspace. Also changed some of system.out.println to
be logInfo.

Change-Id: I65aa04cce27cd39cccbdb322c377c58bfb9bcc0a
Signed-off-by: Estelle Foisy <estelle.foisy@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/199478
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
  • Loading branch information
Estelle Foisy authored and MatthewKhouzam committed Feb 1, 2023
1 parent b73a546 commit 942caa6
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@ private Collection<List<BuilderEventInfo>> getModelFlows() {
eventListPerGroup.add(st.getLongestNonOverlappingRepeatedSubstringWithoutRepeat());
} else {
Collection<List<BuilderEventInfo>> lcsGroups = getLCSgroups();
System.out.println("DEBUG: Group NB = " + lcsGroups.size()); //$NON-NLS-1$ //
Activator.logInfo("DEBUG: Group NB = " + lcsGroups.size()); //$NON-NLS-1$ //
// FIXME:
// DEBUG
// OUTPUT
double groupingRate = (eventsPerTid.size() - lcsGroups.size()) * 1. / eventsPerTid.size();
System.out.println("DEBUG: Grouping rate = " + groupingRate); //$NON-NLS-1$ //
Activator.logInfo("DEBUG: Grouping rate = " + groupingRate); //$NON-NLS-1$ //
// FIXME:
// DEBUG
// OUTPUT
Expand All @@ -299,7 +299,7 @@ private Collection<List<BuilderEventInfo>> getModelFlows() {
.max((s0, s1) -> Integer.compare(s0, s1))
.orElse(0);

System.out.println("DEBUG: Max number of content = " + maxNumberOfContent); //$NON-NLS-1$ //
Activator.logInfo("DEBUG: Max number of content = " + maxNumberOfContent); //$NON-NLS-1$ //
// FIXME:
// DEBUG
// OUTPUT
Expand All @@ -308,11 +308,11 @@ private Collection<List<BuilderEventInfo>> getModelFlows() {
// names
Collection<List<BuilderEventInfo>> idealLcsGroups = getLCSgroups(new BuilderEventInfoNameEqualityRunner());
double idealGroupingRate = (eventsPerTid.size() - idealLcsGroups.size()) * 1. / eventsPerTid.size();
System.out.println("DEBUG: Ideal group NB = " + idealLcsGroups.size()); //$NON-NLS-1$ //
Activator.logInfo("DEBUG: Ideal group NB = " + idealLcsGroups.size()); //$NON-NLS-1$ //
// FIXME:
// DEBUG
// OUTPUT
System.out.println("DEBUG: Ideal grouping rate = " + idealGroupingRate); //$NON-NLS-1$ //
Activator.logInfo("DEBUG: Ideal grouping rate = " + idealGroupingRate); //$NON-NLS-1$ //
// FIXME:
// DEBUG
// OUTPUT
Expand Down Expand Up @@ -346,11 +346,11 @@ private Collection<List<BuilderEventInfo>> getModelFlows() {
}
}

System.out.println("DEBUG: Final group NB = " + lcsGroups.size()); //$NON-NLS-1$ //
Activator.logInfo("DEBUG: Final group NB = " + lcsGroups.size()); //$NON-NLS-1$ //
// FIXME:
// DEBUG
// OUTPUT
System.out.println("DEBUG: Final grouping rate = " + groupingRate); //$NON-NLS-1$ //
Activator.logInfo("DEBUG: Final grouping rate = " + groupingRate); //$NON-NLS-1$ //
// FIXME:
// DEBUG
// OUTPUT
Expand All @@ -367,10 +367,11 @@ private Collection<List<BuilderEventInfo>> getModelFlows() {
/**
* Test
*/
@SuppressWarnings("null")
public void doTest() {
System.out.println("DEBUG: Number of instances: " + eventsPerTid.size()); //$NON-NLS-1$
Activator.logInfo("DEBUG: Number of instances: " + eventsPerTid.size()); //$NON-NLS-1$
for (Entry<Integer, List<BuilderEventInfo>> entry : eventsPerTid.entrySet()) {
System.out.println("DEBUG: - instance " + entry.getKey() + ": " + entry.getValue().size() + " events"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Activator.logInfo("DEBUG: - instance " + entry.getKey() + ": " + entry.getValue().size() + " events"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
/*
* for (int i = 0; i < entry.getValue().size(); i++) {
* System.out.println(" - event "+i+": " +
Expand Down Expand Up @@ -419,7 +420,7 @@ public void doTest() {
StateMachineInstanceGroup smig = new StateMachineInstanceGroup(initialTransitions, stateMachineBackendAnalysis, lttngKernelExecutionGraphModules);
smig.buildOn(fExperiment);

System.out.println(
Activator.logInfo(
StateMachineToDot.drawStateMachine(initialTransitions));
System.exit(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ public InterruptionInterval execute(InterruptionInterval key1, InterruptionInter
}

if (validIds == null || iis.isEmpty()) {
System.out.println("Not enough information for a comparison"); //$NON-NLS-1$
Activator.getInstance().logWarning("Not enough information for a comparison"); //$NON-NLS-1$
continue;
}

Expand Down Expand Up @@ -1286,7 +1286,7 @@ private List<InterruptionDuration> getCriticalPathSteps(InstanceStepInformation
// Get the general graph for the trace
TmfGraph graph = g.getGraph();
if (graph == null) {
System.out.println("graph == null"); //$NON-NLS-1$
Activator.getInstance().logWarning("graph == null"); //$NON-NLS-1$
continue;
}
graphFound = true;
Expand All @@ -1304,7 +1304,7 @@ private List<InterruptionDuration> getCriticalPathSteps(InstanceStepInformation
}

if (lw == null) {
System.out.println("lw == null"); //$NON-NLS-1$
Activator.getInstance().logWarning("lw == null"); //$NON-NLS-1$
continue;
}
workerFound = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public StateMachineVariableAnalysis analyze(StateMachineConstraint constraint, L
// Treat only constants for now
// TODO: treat comparison between variables
if (constraint.getValueType() != ValueType.CONSTANT) {
System.out.println("TODO"); //$NON-NLS-1$
Activator.logWarning("TODO"); //$NON-NLS-1$
return null;
}

Expand Down Expand Up @@ -219,7 +219,7 @@ public StateMachineVariableAnalysis analyze(StateMachineConstraint constraint, L
}
} else {
if (validIsiList == null || validIsiList.isEmpty()) {
System.out.print("No valid instance for a full analysis"); //$NON-NLS-1$
Activator.logWarning("No valid instance for a full analysis"); //$NON-NLS-1$
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ public StateMachineVariableAnalysis analyze(StateMachineConstraint constraint, L
// Treat only constants for now
// TODO: treat comparison between variables
if (constraint.getValueType() != ValueType.CONSTANT) {
System.out.println("TODO"); //$NON-NLS-1$
Activator.logWarning("TODO"); //$NON-NLS-1$
return null;
}
if (validIsiList == null || validIsiList.isEmpty()) {
System.out.print("No valid instance"); //$NON-NLS-1$
Activator.logWarning("No valid instance"); //$NON-NLS-1$
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public List<InterruptionEventList> execute(InstanceStepInformation isi) throws S

// Can't happen
if (e == null) {
System.out.println("e is null and can't be null... what happened?!"); //$NON-NLS-1$
Activator.logWarning("e is null and can't be null... what happened?!"); //$NON-NLS-1$
return null;
}

Expand Down Expand Up @@ -312,7 +312,7 @@ public List<InterruptionEventList> execute(InstanceStepInformation isi) throws S
* error. If not, add it to the list.
*/
if (e.getTimestamp().getValue() > seek) {
System.out.println("Didn't find the event at " + seek); //$NON-NLS-1$
Activator.logWarning("Didn't find the event at " + seek); //$NON-NLS-1$
} else {
ITmfEventField content = e.getContent();
int tasktid = Integer.parseInt(content.getField(layout.fieldNextTid()).getFormattedValue());
Expand Down Expand Up @@ -390,7 +390,7 @@ public StateMachineVariableAnalysis analyze(StateMachineConstraint constraint, L
// Treat only constants for now
// TODO: treat comparison between variables
if (constraint.getValueType() != ValueType.CONSTANT) {
System.out.println("TODO"); //$NON-NLS-1$
Activator.logWarning("TODO"); //$NON-NLS-1$
return null;
}

Expand Down Expand Up @@ -418,7 +418,7 @@ public StateMachineVariableAnalysis analyze(StateMachineConstraint constraint, L
}
} else {
if (validIsiList == null || validIsiList.isEmpty()) {
System.out.print("No valid instance for a full analysis"); //$NON-NLS-1$
Activator.logWarning("No valid instance for a full analysis"); //$NON-NLS-1$
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,27 @@ public void stop(@Nullable BundleContext context) throws Exception {
return icon;
}

/**
* Logs a message with severity INFO in the runtime log of the plug-in.
*
* @param message
* A message to log
*/
public static void logInfo(String message) {
Objects.requireNonNull(plugin).getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
}

/**
* Logs a message and exception with severity WARNING in the runtime log of
* the plug-in.
*
* @param message
* A message to log
*/
public static void logWarning(@Nullable String message) {
Objects.requireNonNull(plugin).getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message));
}

/**
* Logs a message and exception with severity ERROR in the runtime log of
* the plug-in.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ protected boolean buildAnalysisSegments(@NonNull ISegmentStore<@NonNull ISegment
if (kernelAnalysisModule != null) {
IStatus status = kernelAnalysisModule.schedule();
if (!status.isOK()) {
System.out.println("kernelAnalysisModule status is not ok");
Activator.logWarning("kernelAnalysisModule status is not ok");
}
} else {

System.out.println("kernelAnalysisModule is null");
Activator.logWarning("kernelAnalysisModule is null");
}
}

Expand All @@ -184,10 +184,10 @@ protected boolean buildAnalysisSegments(@NonNull ISegmentStore<@NonNull ISegment
if (status.isOK()) {
stateMachineBackendAnalysis.waitForCompletion();
} else {
System.out.println("stateMachineAnalysisModule status is not ok");
Activator.logWarning("stateMachineAnalysisModule status is not ok");
}
} else {
System.out.println("stateMachineAnalysisModule is null");
Activator.logWarning("stateMachineAnalysisModule is null");
}
}

Expand All @@ -201,10 +201,10 @@ protected boolean buildAnalysisSegments(@NonNull ISegmentStore<@NonNull ISegment
if (criticalPathAnalysisModule != null) {
IStatus status = criticalPathAnalysisModule.schedule();
if (!status.isOK()) {
System.out.println("fModuleCriticalPath status is not ok");
Activator.logWarning("fModuleCriticalPath status is not ok");
}
} else {
System.out.println("fModuleCriticalPath is null");
Activator.logWarning("fModuleCriticalPath is null");
}
}

Expand Down Expand Up @@ -454,7 +454,7 @@ public void partActivated(@Nullable IWorkbenchPartReference partRef) {
}
}
if (print) {
System.out.println(smig.toString());
Activator.logWarning(smig.toString());
}

benchmarkObject.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private static List<StateMachineTransition> getTransitionsFromXMLState(Element e
String targetNode = targetAttribute.getNodeValue();
StateMachineNode nextNode = nodeList.get(targetNode);
if (nextNode == null) {
System.out.println("Transition to unknown node: "+targetNode); //$NON-NLS-1$
Activator.logWarning("Transition to unknown node: "+targetNode); //$NON-NLS-1$
continue;
}

Expand All @@ -117,7 +117,7 @@ private static List<StateMachineTransition> getTransitionsFromXMLState(Element e

Matcher m = CONDITION_PATTERN.matcher(condition);
if (!m.find()) {
System.out.println("Unmatching condition: "+condition); //$NON-NLS-1$
Activator.logWarning("Unmatching condition: "+condition); //$NON-NLS-1$
continue;
}

Expand Down Expand Up @@ -182,7 +182,7 @@ public static List<StateMachineTransition> getModelFromXML(String xmlPath) throw

String name = id.getNodeValue();
if (nodeList.containsKey(name)) {
System.out.println("Node "+name+" already exists"); //$NON-NLS-1$ //$NON-NLS-2$
Activator.logWarning("Node "+name+" already exists"); //$NON-NLS-1$ //$NON-NLS-2$
}

nodeList.put(name, new StateMachineNode(name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.eclipse.test.performance.PerformanceMeter;
import org.eclipse.tracecompass.analysis.os.linux.core.tid.TidAnalysisModule;
import org.eclipse.tracecompass.ctf.core.tests.shared.CtfBenchmarkTrace;
import org.eclipse.tracecompass.incubator.internal.scripting.core.Activator;
import org.eclipse.tracecompass.incubator.internal.scripting.core.ScriptExecutionHelper;
import org.eclipse.tracecompass.incubator.scripting.core.trace.ScriptEventsIterator;
import org.eclipse.tracecompass.incubator.scripting.core.trace.TraceScriptingModule;
Expand Down Expand Up @@ -139,7 +140,7 @@ public static Iterable<Object[]> getParameters() throws IOException {
private static final Runnable EMPTY = () -> {
// Do nothing much, to benchmark script initialization
int i = 0;
System.out.println(i);
Activator.getInstance().logInfo(Integer.toString(i));
};

private static final Runnable SIMPLE_COMPUTATION = () -> {
Expand Down Expand Up @@ -201,7 +202,7 @@ private static void readTrace(String absolutePathToTrace) {
schedSwitchCnt++;
}
}
System.out.println("Count sched switch: " + schedSwitchCnt);
Activator.getInstance().logInfo("Count sched switch: " + schedSwitchCnt);
} catch (TmfTraceException e) {
fail(e.getMessage());
} finally {
Expand Down Expand Up @@ -459,7 +460,7 @@ public void jythonTest() {
pmPython.start();
ScriptExecutionHelper.executeScript(Objects.requireNonNull(absoluteFilePath.toOSString()), JYTHON_ENGINE, fArguments);
pmPython.stop();
System.out.println("Did iteration " + i);
Activator.getInstance().logInfo("Did iteration " + i);
}
pmPython.commit();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.incubator.internal.ros.core.Activator;
import org.eclipse.tracecompass.incubator.internal.ros.core.trace.layout.IRosEventLayout;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.statesystem.AbstractTmfStateProvider;
Expand Down Expand Up @@ -133,7 +134,7 @@ protected static boolean isEvent(@NonNull ITmfEvent event, @NonNull String event
protected static Object getField(@NonNull ITmfEvent event, @NonNull String fieldName) {
Object val = event.getContent().getFieldValue(Object.class, fieldName);
if (val == null) {
System.out.println("woops"); //$NON-NLS-1$
Activator.getInstance().logWarning("woops"); //$NON-NLS-1$
}
return val;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -862,9 +862,8 @@ private void printInformations() {
long begin = getBeginSelectedTime();
long end = getEndSelectedTime();

System.out.println("Begin time: " + FormatTimeUtils.formatTime(begin, FormatTimeUtils.TimeFormat.CALENDAR, FormatTimeUtils.Resolution.NANOSEC)); //$NON-NLS-1$
System.out.println("End time: " + FormatTimeUtils.formatTime(end, FormatTimeUtils.TimeFormat.CALENDAR, FormatTimeUtils.Resolution.NANOSEC)); //$NON-NLS-1$
System.out.println();
Activator.getDefault().logInfo("Begin time: " + FormatTimeUtils.formatTime(begin, FormatTimeUtils.TimeFormat.CALENDAR, FormatTimeUtils.Resolution.NANOSEC)); //$NON-NLS-1$
Activator.getDefault().logInfo("End time: " + FormatTimeUtils.formatTime(end, FormatTimeUtils.TimeFormat.CALENDAR, FormatTimeUtils.Resolution.NANOSEC)); //$NON-NLS-1$

}

Expand Down

0 comments on commit 942caa6

Please sign in to comment.