diff --git a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/CtfCorePluginTest.java b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/CtfCoreLoggerUtilTest.java similarity index 66% rename from ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/CtfCorePluginTest.java rename to ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/CtfCoreLoggerUtilTest.java index 07378eab90..64bb04b1d3 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/CtfCorePluginTest.java +++ b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/CtfCoreLoggerUtilTest.java @@ -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; /** * CtfCorePluginTest *

- * 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 @@ -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(); } diff --git a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/CtfCoreTestPlugin.java b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/CtfCoreTestPlugin.java index c947ec4eb7..fbdf8c9977 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/CtfCoreTestPlugin.java +++ b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/CtfCoreTestPlugin.java @@ -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; /** @@ -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$ diff --git a/ctf/org.eclipse.tracecompass.ctf.core/META-INF/MANIFEST.MF b/ctf/org.eclipse.tracecompass.ctf.core/META-INF/MANIFEST.MF index de0aecde33..21dc33b2d0 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/META-INF/MANIFEST.MF +++ b/ctf/org.eclipse.tracecompass.ctf.core/META-INF/MANIFEST.MF @@ -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, diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/StructDeclaration.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/StructDeclaration.java index 8f9874ec95..e40459ca02 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/StructDeclaration.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/StructDeclaration.java @@ -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. @@ -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 */ diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInput.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInput.java index c02d844cd8..9f925f0961 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInput.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInput.java @@ -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; @@ -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; @@ -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(); diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInputReader.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInputReader.java index b4983edf32..a739497a13 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInputReader.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInputReader.java @@ -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; @@ -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) { diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamPacketOutputWriter.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamPacketOutputWriter.java index e559d8eaac..c9c2baed39 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamPacketOutputWriter.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamPacketOutputWriter.java @@ -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; @@ -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); diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTrace.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTrace.java index d24b55fb50..37c0f3ef90 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTrace.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTrace.java @@ -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; @@ -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; @@ -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$ } } diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTraceReader.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTraceReader.java index 2756cc2b81..e9c64a9a67 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTraceReader.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTraceReader.java @@ -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; /** @@ -148,7 +148,7 @@ public void close() { try { reader.close(); } catch (IOException e) { - Activator.logError(e.getMessage(), e); + CtfCoreLoggerUtil.logError(e.getMessage(), e); } } } @@ -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); } } } @@ -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()); } } diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/Activator.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/Activator.java deleted file mode 100644 index 7c52f9af2a..0000000000 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/Activator.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2015 Ericsson, Ecole Polytechnique de Montreal and others - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License 2.0 which - * accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Francois Chouinard - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.tracecompass.internal.ctf.core; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Status; -import org.osgi.framework.BundleContext; - -/** - * Activator - *

- * The activator class controls the plug-in life cycle. - */ -public class Activator extends Plugin { - - // ------------------------------------------------------------------------ - // Attributes - // ------------------------------------------------------------------------ - - /** - * The plug-in ID - */ - public static final String PLUGIN_ID = "org.eclipse.tracecompass.ctf.core"; //$NON-NLS-1$ - - /** - * The shared instance - */ - private static Activator fPlugin; - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - /** - * Constructor - */ - public Activator() { - setDefault(this); - } - - // ------------------------------------------------------------------------ - // Accessors - // ------------------------------------------------------------------------ - - /** - * Get the default activator - * @return the default activator - */ - public static Activator getDefault() { - return fPlugin; - } - - /** - * Sets the default activator - * - * @param plugin the default activator - */ - private static void setDefault(Activator plugin) { - fPlugin = plugin; - } - - // ------------------------------------------------------------------------ - // Plugin - // ------------------------------------------------------------------------ - - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - setDefault(this); - } - - @Override - public void stop(BundleContext context) throws Exception { - setDefault(null); - super.stop(context); - } - - // ------------------------------------------------------------------------ - // Logging - // ------------------------------------------------------------------------ - - /** - * Log a message - * - * @param msg - * The message to log - */ - public static void log(String msg) { - log(msg, null); - } - - /** - * Log a message with an exception - * - * @param msg - * The message - * @param e - * The exception - */ - public static void log(String msg, Exception e) { - getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, IStatus.OK, msg, e)); - } - - /** - * Log an error, with an associated exception - * - * @param msg - * The error message - * @param e - * The cause - */ - public static void logError(String msg, Exception e) { - getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, msg, e)); - } - - /** - * Log a message - * - * @param severity - * Desired severity of the message in the log, one of - * {@link IStatus#INFO}, {@link IStatus#WARNING} or - * {@link IStatus#ERROR} - * @param msg - * The message to log - */ - public static void log(int severity, String msg) { - getDefault().getLog().log(new Status(severity, PLUGIN_ID, msg)); - } - - -} diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/CtfCoreLoggerUtil.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/CtfCoreLoggerUtil.java new file mode 100644 index 0000000000..3004ef51a2 --- /dev/null +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/CtfCoreLoggerUtil.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * Copyright (c) 2011, 2023 Ericsson, Ecole Polytechnique de Montreal and others + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License 2.0 which + * accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Francois Chouinard - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.tracecompass.internal.ctf.core; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; + +/** + * The class for adding logging Utility to the CTF plug-in. + */ +public class CtfCoreLoggerUtil { + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + /** + * Flag to indicate if platform is running + */ + public static final boolean IS_PLATFORM_RUNNING; + private static Logger LOGGER; + static { + boolean result = false; + try { + result = Platform.isRunning(); + } catch (Exception exception) { + // Assume that we aren't running. + } + IS_PLATFORM_RUNNING = result; + if (!result) { + LOGGER = Logger.getLogger(CtfCoreLoggerUtil.class.getName()); + } + } + + + /** + * The plug-in ID + */ + public static final String PLUGIN_ID = "org.eclipse.tracecompass.ctf.core"; //$NON-NLS-1$ + + // ------------------------------------------------------------------------ + // Constructors + // ------------------------------------------------------------------------ + + /** + * Constructor + */ + private CtfCoreLoggerUtil() { + // Do nothing + } + + // ------------------------------------------------------------------------ + // Logging + // ------------------------------------------------------------------------ + + /** + * Log a info message + * + * @param msg + * The message + */ + public static void logInfo(String msg) { + if (IS_PLATFORM_RUNNING) { + Platform.getLog(CtfCoreLoggerUtil.class).log(new Status(IStatus.INFO, PLUGIN_ID, msg)); + } else { + LOGGER.log(Level.INFO, msg); + } + } + + /** + * Log an error, with an associated exception + * + * @param msg + * The error message + * @param e + * The cause + */ + public static void logError(String msg, Exception e) { + if (IS_PLATFORM_RUNNING) { + Platform.getLog(CtfCoreLoggerUtil.class).log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, msg, e)); + } else { + LOGGER.log(Level.SEVERE, msg, e); + } + } + + /** + * Log an error, with an associated exception + * + * @param msg + * The error message + */ + public static void logWarning(String msg) { + if (IS_PLATFORM_RUNNING) { + Platform.getLog(CtfCoreLoggerUtil.class).log(new Status(IStatus.WARNING, PLUGIN_ID, msg)); + } else { + LOGGER.log(Level.WARNING, msg); + } + } +} diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/ClockParser.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/ClockParser.java index cbbed76d2a..b5c79de217 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/ClockParser.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/ClockParser.java @@ -13,10 +13,9 @@ import java.util.List; -import org.eclipse.core.runtime.IStatus; import org.eclipse.tracecompass.ctf.core.event.CTFClock; import org.eclipse.tracecompass.ctf.parser.CTFParser; -import org.eclipse.tracecompass.internal.ctf.core.Activator; +import org.eclipse.tracecompass.internal.ctf.core.CtfCoreLoggerUtil; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.ICommonTreeParser; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.JsonClockMetadataNode; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.ParseException; @@ -181,7 +180,7 @@ public CTFClock parse(ICTFMetadataNode clock, ICommonTreeParserParameter unused) try { numValue = Long.parseLong(text); } catch (NumberFormatException e) { - Activator.log(IStatus.WARNING, "Number conversion issue with " + text + ". Assigning " + key + " = 0."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + CtfCoreLoggerUtil.logWarning("Number conversion issue with " + text + ". Assigning " + key + " = 0."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ numValue = Long.valueOf(0L); } ctfClock.addAttribute(key, numValue); diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/enumeration/EnumeratorParser.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/enumeration/EnumeratorParser.java index 269e0e7218..d76633ba8a 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/enumeration/EnumeratorParser.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/enumeration/EnumeratorParser.java @@ -19,18 +19,18 @@ import java.util.Map.Entry; import java.util.Set; -import org.eclipse.core.runtime.IStatus; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.tracecompass.ctf.core.event.types.EnumDeclaration; import org.eclipse.tracecompass.ctf.core.event.types.IntegerDeclaration; import org.eclipse.tracecompass.ctf.parser.CTFParser; -import org.eclipse.tracecompass.internal.ctf.core.Activator; +import org.eclipse.tracecompass.internal.ctf.core.CtfCoreLoggerUtil; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.ICommonTreeParser; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.JsonStructureFieldMemberMetadataNode; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.ParseException; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.tsdl.UnaryIntegerParser; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.tsdl.UnaryStringParser; import org.eclipse.tracecompass.internal.ctf.core.event.types.ICTFMetadataNode; + import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -150,7 +150,7 @@ private static void setEnumeration(EnumDeclaration enumDeclaration, long low, lo throw new ParseException("enum low value greater than high value"); //$NON-NLS-1$ } if (valueSpecified && !enumDeclaration.add(low, high, label)) { - Activator.log(IStatus.WARNING, "enum declarator values overlap. " + enumDeclaration.getLabels() + " and " + label); //$NON-NLS-1$ //$NON-NLS-2$ + CtfCoreLoggerUtil.logWarning("enum declarator values overlap. " + enumDeclaration.getLabels() + " and " + label); //$NON-NLS-1$ //$NON-NLS-2$ } else if (!valueSpecified && !enumDeclaration.add(label)) { throw new ParseException("enum cannot add element " + label); //$NON-NLS-1$ } diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/integer/IntegerDeclarationParser.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/integer/IntegerDeclarationParser.java index 28105b2a34..716eba4ef6 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/integer/IntegerDeclarationParser.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/integer/IntegerDeclarationParser.java @@ -18,14 +18,13 @@ import java.nio.ByteOrder; import java.util.List; -import org.eclipse.core.runtime.IStatus; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.tracecompass.ctf.core.event.types.Encoding; import org.eclipse.tracecompass.ctf.core.event.types.IntegerDeclaration; import org.eclipse.tracecompass.ctf.core.trace.CTFTrace; import org.eclipse.tracecompass.ctf.parser.CTFParser; -import org.eclipse.tracecompass.internal.ctf.core.Activator; +import org.eclipse.tracecompass.internal.ctf.core.CtfCoreLoggerUtil; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.CTFAntlrMetadataNode; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.CTFJsonMetadataNode; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.ICommonTreeParser; @@ -205,7 +204,7 @@ public IntegerDeclaration parse(ICTFMetadataNode integer, ICommonTreeParserParam clock = ClockMapParser.INSTANCE.parse(rightNode, null); break; default: - Activator.log(IStatus.WARNING, Messages.IOStructGen_UnknownIntegerAttributeWarning + " " + left); //$NON-NLS-1$ + CtfCoreLoggerUtil.logWarning(Messages.IOStructGen_UnknownIntegerAttributeWarning + " " + left); //$NON-NLS-1$ break; } } else { diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/stream/StreamDeclarationParser.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/stream/StreamDeclarationParser.java index f35cc7ae08..d0632a0965 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/stream/StreamDeclarationParser.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/stream/StreamDeclarationParser.java @@ -15,7 +15,6 @@ import java.util.List; -import org.eclipse.core.runtime.IStatus; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.tracecompass.ctf.core.CTFStrings; import org.eclipse.tracecompass.ctf.core.event.metadata.DeclarationScope; @@ -24,7 +23,7 @@ import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration; import org.eclipse.tracecompass.ctf.core.trace.CTFTrace; import org.eclipse.tracecompass.ctf.parser.CTFParser; -import org.eclipse.tracecompass.internal.ctf.core.Activator; +import org.eclipse.tracecompass.internal.ctf.core.CtfCoreLoggerUtil; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.AbstractScopedCommonTreeParser; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.CTFJsonMetadataNode; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.JsonDataStreamMetadataNode; @@ -243,7 +242,7 @@ public CTFStream parse(ICTFMetadataNode streamDecl, ICommonTreeParserParameter p stream.setPacketContext((StructDeclaration) packetContextDecl); } else { - Activator.log(IStatus.WARNING, Messages.IOStructGen_UnknownStreamAttributeWarning + ' ' + left); + CtfCoreLoggerUtil.logWarning(Messages.IOStructGen_UnknownStreamAttributeWarning + ' ' + left); } } return stream; diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/trace/TraceDeclarationParser.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/trace/TraceDeclarationParser.java index 75eb534b66..9587c0106e 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/trace/TraceDeclarationParser.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/trace/TraceDeclarationParser.java @@ -18,7 +18,6 @@ import java.util.List; import java.util.UUID; -import org.eclipse.core.runtime.IStatus; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.tracecompass.ctf.core.event.metadata.DeclarationScope; import org.eclipse.tracecompass.ctf.core.event.types.EnumDeclaration; @@ -29,7 +28,7 @@ import org.eclipse.tracecompass.ctf.core.event.types.VariantDeclaration; import org.eclipse.tracecompass.ctf.core.trace.CTFTrace; import org.eclipse.tracecompass.ctf.parser.CTFParser; -import org.eclipse.tracecompass.internal.ctf.core.Activator; +import org.eclipse.tracecompass.internal.ctf.core.CtfCoreLoggerUtil; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.AbstractScopedCommonTreeParser; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.CTFAntlrMetadataNode; import org.eclipse.tracecompass.internal.ctf.core.event.metadata.JsonPreambleMetadataNode; @@ -220,7 +219,7 @@ public CTFTrace parse(ICTFMetadataNode traceDecl, ICommonTreeParserParameter par trace.setPacketHeader((StructDeclaration) packetHeaderDecl); } else { - Activator.log(IStatus.WARNING, Messages.IOStructGen_UnknownTraceAttributeWarning + " " + left); //$NON-NLS-1$ + CtfCoreLoggerUtil.logWarning(Messages.IOStructGen_UnknownTraceAttributeWarning + " " + left); //$NON-NLS-1$ } } return trace; diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/StreamInputPacketIndex.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/StreamInputPacketIndex.java index 49a19b3f21..8ae9939576 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/StreamInputPacketIndex.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/StreamInputPacketIndex.java @@ -25,10 +25,9 @@ import java.util.Comparator; import java.util.List; -import org.eclipse.core.runtime.IStatus; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.ctf.core.trace.ICTFPacketDescriptor; -import org.eclipse.tracecompass.internal.ctf.core.Activator; +import org.eclipse.tracecompass.internal.ctf.core.CtfCoreLoggerUtil; /** * StreamInputPacketIndex @@ -95,7 +94,7 @@ public synchronized boolean append(@NonNull ICTFPacketDescriptor entry) { ICTFPacketDescriptor entryToAdd = entry; /* Validate consistent entry. */ if (entryToAdd.getTimestampBegin() > entryToAdd.getTimestampEnd()) { - Activator.log(IStatus.WARNING, "Packet at offset " + entryToAdd.getOffsetBytes() + //$NON-NLS-1$ + CtfCoreLoggerUtil.logWarning("Packet at offset " + entryToAdd.getOffsetBytes() + //$NON-NLS-1$ " begin timestamp is after end timestamp"); //$NON-NLS-1$ entryToAdd = new StreamInputPacketIndexEntry(entryToAdd, Long.MAX_VALUE); }