Skip to content

Commit

Permalink
ctf: Remove activator from o.e.tc.ctf.core
Browse files Browse the repository at this point in the history
Replace the log calls using the activator with Platform.log(), if
platform is running else use JUL logging. The later is useful when
CTF parser is used outside of Eclipse plug-ins.

[Updated] Remove activator from o.e.tc.ctf.core

Change-Id: I2e1acb4826f0452ec4e8000b685a810d8560f946
Signed-off-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/205759
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
  • Loading branch information
bhufmann authored and MatthewKhouzam committed Dec 13, 2023
1 parent ea2a0c7 commit d55f1f6
Show file tree
Hide file tree
Showing 17 changed files with 150 additions and 202 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,16 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import org.eclipse.tracecompass.internal.ctf.core.Activator;
import org.eclipse.tracecompass.internal.ctf.core.CtfCoreLoggerUtil;
import org.junit.Test;

/**
* <b><u>CtfCorePluginTest</u></b>
* <p>
* Test the CTF core plug-in activator
* Test the CTF core logger utility
*/
@SuppressWarnings("javadoc")
public class CtfCorePluginTest {

// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------

// Plug-in instantiation
private final static Activator fPlugin = Activator.getDefault();

public class CtfCoreLoggerUtilTest {

// ------------------------------------------------------------------------
// Test cases
Expand All @@ -43,19 +35,13 @@ public class CtfCorePluginTest {
@Test
public void testCtfCorePluginId() {
assertEquals(
"Plugin ID", "org.eclipse.tracecompass.ctf.core", Activator.PLUGIN_ID);
}

@Test
public void testGetDefault() {
Activator plugin = Activator.getDefault();
assertEquals("getDefault()", plugin, fPlugin);
"Plugin ID", "org.eclipse.tracecompass.ctf.core", CtfCoreLoggerUtil.PLUGIN_ID);
}

@Test
public void testLog() {
try {
Activator.log("Some message");
CtfCoreLoggerUtil.logInfo("Some message");
} catch (Exception e) {
fail();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.tracecompass.internal.ctf.core.Activator;
import org.eclipse.tracecompass.internal.ctf.core.CtfCoreLoggerUtil;
import org.osgi.framework.BundleContext;

/**
Expand Down Expand Up @@ -108,7 +108,7 @@ public static String getTemporaryDirPath() {
}
return dir.getAbsolutePath();
} catch (URISyntaxException e) {
Activator.logError(e.getLocalizedMessage(), e);
CtfCoreLoggerUtil.logError(e.getLocalizedMessage(), e);
}
}
return System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
Expand Down
3 changes: 1 addition & 2 deletions ctf/org.eclipse.tracecompass.ctf.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
Bundle-Version: 4.4.0.qualifier
Bundle-Version: 4.4.1.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.tracecompass.ctf.core;singleton:=true
Bundle-Activator: org.eclipse.tracecompass.internal.ctf.core.Activator
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: org.eclipse.core.runtime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
import java.util.List;
import java.util.regex.Pattern;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
import org.eclipse.tracecompass.internal.ctf.core.Activator;
import org.eclipse.tracecompass.internal.ctf.core.CtfCoreLoggerUtil;

/**
* A CTF structure declaration.
Expand Down Expand Up @@ -198,7 +197,7 @@ public StructDefinition createDefinition(IDefinitionScope definitionScope,
*/
public void addField(@NonNull String name, @NonNull IDeclaration declaration) {
if (hasField(name)) {
Activator.log(IStatus.WARNING, "Struct already contains a field named " + name); //$NON-NLS-1$
CtfCoreLoggerUtil.logWarning("Struct already contains a field named " + name); //$NON-NLS-1$
return;
}
/* extend by one */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.Objects;
import java.util.UUID;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.ctf.core.CTFException;
Expand All @@ -38,7 +37,7 @@
import org.eclipse.tracecompass.ctf.core.event.types.IntegerDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
import org.eclipse.tracecompass.ctf.core.event.types.StructDefinition;
import org.eclipse.tracecompass.internal.ctf.core.Activator;
import org.eclipse.tracecompass.internal.ctf.core.CtfCoreLoggerUtil;
import org.eclipse.tracecompass.internal.ctf.core.SafeMappedByteBuffer;
import org.eclipse.tracecompass.internal.ctf.core.trace.StreamInputPacketIndex;
import org.eclipse.tracecompass.internal.ctf.core.trace.StreamInputPacketIndexEntry;
Expand Down Expand Up @@ -361,7 +360,7 @@ private StructDefinition parseTracePacketHeader(
}
if (!Objects.equals(getStream().getTrace().getUUID(), uuid) && !fUUIDMismatchWarning) {
fUUIDMismatchWarning = true;
Activator.log(IStatus.WARNING, "Reading CTF trace: UUID mismatch for trace " + getStream().getTrace()); //$NON-NLS-1$
CtfCoreLoggerUtil.logWarning("Reading CTF trace: UUID mismatch for trace " + getStream().getTrace()); //$NON-NLS-1$
}
if (streamIDDef != null) {
long streamID = streamIDDef.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.types.IDeclaration;
import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
import org.eclipse.tracecompass.internal.ctf.core.Activator;
import org.eclipse.tracecompass.internal.ctf.core.CtfCoreLoggerUtil;
import org.eclipse.tracecompass.internal.ctf.core.SafeMappedByteBuffer;
import org.eclipse.tracecompass.internal.ctf.core.trace.CTFPacketReader;
import org.eclipse.tracecompass.internal.ctf.core.trace.NullPacketReader;
Expand Down Expand Up @@ -377,7 +377,7 @@ public long seek(long timestamp) throws CTFException {
goToNextPacket();
} catch (CTFException e) {
// do nothing here
Activator.log(e.getMessage());
CtfCoreLoggerUtil.logInfo(e.getMessage());
}
}
if (fPacketReader.getCurrentPacket() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.eclipse.tracecompass.ctf.core.event.types.SimpleDatatypeDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.StringDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.StructDefinition;
import org.eclipse.tracecompass.internal.ctf.core.Activator;
import org.eclipse.tracecompass.internal.ctf.core.CtfCoreLoggerUtil;
import org.eclipse.tracecompass.internal.ctf.core.SafeMappedByteBuffer;
import org.eclipse.tracecompass.internal.ctf.core.trace.CTFPacketReader;
import org.eclipse.tracecompass.internal.ctf.core.trace.StreamInputPacketIndexEntry;
Expand Down Expand Up @@ -318,7 +318,7 @@ private static void writeString(BitBuffer bb, Definition def) throws CTFExceptio
try {
bytes = stringDefinition.toString().getBytes(stringDefinition.getDeclaration().getEncoding().toString());
} catch (UnsupportedEncodingException e) {
Activator.log("Writing packet made an encoding error! " + e.getMessage()); //$NON-NLS-1$
CtfCoreLoggerUtil.logInfo("Writing packet made an encoding error! " + e.getMessage()); //$NON-NLS-1$
}
bb.put(bytes);
bb.put((byte) 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import java.util.Set;
import java.util.UUID;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.ctf.core.CTFException;
Expand All @@ -54,7 +53,7 @@
import org.eclipse.tracecompass.ctf.core.event.types.IntegerDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
import org.eclipse.tracecompass.ctf.core.event.types.StructDefinition;
import org.eclipse.tracecompass.internal.ctf.core.Activator;
import org.eclipse.tracecompass.internal.ctf.core.CtfCoreLoggerUtil;
import org.eclipse.tracecompass.internal.ctf.core.SafeMappedByteBuffer;
import org.eclipse.tracecompass.internal.ctf.core.event.metadata.MetadataStrings;
import org.eclipse.tracecompass.internal.ctf.core.event.metadata.ParseException;
Expand Down Expand Up @@ -563,7 +562,7 @@ private void validateUUID(StructDefinition packetHeaderDef) throws CTFException

if (otheruuid != null && !fUuid.equals(otheruuid) && !fUUIDMismatchWarning) {
fUUIDMismatchWarning = true;
Activator.log(IStatus.WARNING, "Reading CTF trace: UUID mismatch for trace " + this); //$NON-NLS-1$
CtfCoreLoggerUtil.logWarning("Reading CTF trace: UUID mismatch for trace " + this); //$NON-NLS-1$
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.internal.ctf.core.Activator;
import org.eclipse.tracecompass.internal.ctf.core.CtfCoreLoggerUtil;
import org.eclipse.tracecompass.internal.ctf.core.trace.StreamInputReaderTimestampComparator;

/**
Expand Down Expand Up @@ -148,7 +148,7 @@ public void close() {
try {
reader.close();
} catch (IOException e) {
Activator.logError(e.getMessage(), e);
CtfCoreLoggerUtil.logError(e.getMessage(), e);
}
}
}
Expand Down Expand Up @@ -259,7 +259,7 @@ public void update() throws CTFException {
readers.add(streamInputReaderToAdd);
}
} catch (IOException e) {
Activator.logError(e.getMessage(), e);
CtfCoreLoggerUtil.logError(e.getMessage(), e);
}
}
}
Expand Down Expand Up @@ -515,7 +515,7 @@ public void printStats(int width) {
}

sb.append("]\t" + fEventCountPerTraceFile[se.getName()] + " Events"); //$NON-NLS-1$//$NON-NLS-2$
Activator.log(sb.toString());
CtfCoreLoggerUtil.logInfo(sb.toString());
}
}

Expand Down

This file was deleted.

0 comments on commit d55f1f6

Please sign in to comment.