1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-03 14:25:37 +02:00

[cleanup] get rid of warning messages

This commit is contained in:
David Dykstal 2006-12-05 02:36:27 +00:00
parent 2af9a8635d
commit f9210cdc57
7 changed files with 191 additions and 204 deletions

View file

@ -24,13 +24,13 @@ public interface IRemoteSystemsLogging {
/**
* Name of the key that controls the logging level.<br>
*/
public static final String PLUGIN_ID = "org.eclipse.rse.logging";
public static final String PLUGIN_ID = "org.eclipse.rse.logging"; //$NON-NLS-1$
/**
* Name of the key that controls the logging level.<br>
* (value is "debug_level").
*/
public static final String DEBUG_LEVEL = "debug_level";
public static final String DEBUG_LEVEL = "debug_level"; //$NON-NLS-1$
/**
* Set debug_level to this value to get Error messages.<br>

View file

@ -146,7 +146,7 @@ public class Logger implements IPropertyChangeListener {
*/
public synchronized void logError(String message, Throwable ex) {
if (debug_level >= IRemoteSystemsLogging.LOG_ERROR) {
if (message == null) message = "";
if (message == null) message = ""; //$NON-NLS-1$
Status errorStatus = new Status(IStatus.ERROR, pluginId, IStatus.OK, message, ex);
systemsPluginLog.log(errorStatus);
}
@ -168,7 +168,7 @@ public class Logger implements IPropertyChangeListener {
*/
public synchronized void logInfo(String message, Throwable ex) {
if (debug_level >= IRemoteSystemsLogging.LOG_INFO) {
if (message == null) message = "";
if (message == null) message = ""; //$NON-NLS-1$
Status infoStatus = new Status(IStatus.INFO, pluginId, IStatus.OK, message, ex);
systemsPluginLog.log(infoStatus);
}
@ -190,7 +190,7 @@ public class Logger implements IPropertyChangeListener {
*/
public synchronized void logWarning(String message, Throwable ex) {
if (debug_level >= IRemoteSystemsLogging.LOG_WARNING) {
if (message == null) message = "";
if (message == null) message = ""; //$NON-NLS-1$
Status warningStatus = new Status(IStatus.WARNING, pluginId, IStatus.OK, message, ex);
systemsPluginLog.log(warningStatus);
}

View file

@ -42,7 +42,7 @@ class RemoteSystemLogListener implements ILogListener, IPropertyChangeListener {
* @param plugin The plugin for which to create a log listener.
*/
public RemoteSystemLogListener(Plugin plugin) {
IPath path = plugin.getStateLocation().addTrailingSeparator().append(".log");
IPath path = plugin.getStateLocation().addTrailingSeparator().append(".log"); //$NON-NLS-1$
outputFile = path.toFile();
if ((outputFile != null) && (outputFile.exists())) {
outputFile.delete();
@ -60,7 +60,7 @@ class RemoteSystemLogListener implements ILogListener, IPropertyChangeListener {
log = new PrintWriter(new BufferedWriter(new FileWriter(outputFile.toString(), true)), true);
} catch (Exception e) {
log = null;
System.err.println("Exception in RemoteSystemLogListener.initialize(): " + e.getMessage());
System.err.println("Exception in RemoteSystemLogListener.initialize(): " + e.getMessage()); //$NON-NLS-1$
e.printStackTrace();
}
}
@ -74,18 +74,18 @@ class RemoteSystemLogListener implements ILogListener, IPropertyChangeListener {
log.println(date);
int severity = status.getSeverity();
if (severity == IStatus.ERROR) {
log.print("ERROR");
log.print("ERROR"); //$NON-NLS-1$
} else if (severity == IStatus.WARNING) {
log.print("WARNING");
log.print("WARNING"); //$NON-NLS-1$
} else if (severity == IStatus.INFO) {
log.print("INFO");
log.print("INFO"); //$NON-NLS-1$
} else if (severity == IStatus.OK) {
log.print("DEBUG");
log.print("DEBUG"); //$NON-NLS-1$
}
log.print(" ");
log.print(" "); //$NON-NLS-1$
log.print(status.getPlugin());
log.print(" ");
log.print(" "); //$NON-NLS-1$
log.println(status.getMessage());
if (status.getException() != null) status.getException().printStackTrace(log);
if (status.isMultiStatus()) {
@ -94,7 +94,7 @@ class RemoteSystemLogListener implements ILogListener, IPropertyChangeListener {
loggingChild(children[i]);
}
}
log.println("--------------------------------------------");
log.println("--------------------------------------------"); //$NON-NLS-1$
}
}
@ -110,7 +110,7 @@ class RemoteSystemLogListener implements ILogListener, IPropertyChangeListener {
if (log == null)
return;
else {
log.print("\t\t");
log.print("\t\t"); //$NON-NLS-1$
log.println(status.getMessage());
if (status.getException() != null) status.getException().printStackTrace(log);
if (status.isMultiStatus()) {

View file

@ -59,7 +59,7 @@ public class RemoteSystemsLoggingPlugin extends Plugin {
ResourceBundle bundle = RemoteSystemsLoggingPlugin.getDefault().getResourceBundle();
return bundle.getString(key);
} catch (Exception e) {
out.logError("could not get resource string for: " + key, e);
out.logError("could not get resource string for: " + key, e); //$NON-NLS-1$
return key;
}
}
@ -70,12 +70,12 @@ public class RemoteSystemsLoggingPlugin extends Plugin {
public ResourceBundle getResourceBundle() {
if (resourceBundle == null) {
try {
IPath path = new Path("$nl$/RemoteSystemsLogging.properties");
IPath path = new Path("$nl$/RemoteSystemsLogging.properties"); //$NON-NLS-1$
URL url = FileLocator.find(getBundle(), path, null);
resourceBundle = new PropertyResourceBundle(url.openStream());
} catch (Exception x) {
resourceBundle = null;
out.logInfo("RemoteSystemsLoggingPlugin - unable to log resourcebundle");
out.logInfo("RemoteSystemsLoggingPlugin - unable to log resourcebundle"); //$NON-NLS-1$
}
}
return resourceBundle;
@ -87,7 +87,7 @@ public class RemoteSystemsLoggingPlugin extends Plugin {
public void start(BundleContext context) throws Exception {
super.start(context);
out = LoggerFactory.getLogger(this);
out.logInfo("loading RemoteSystemsLoggingPlugin class.");
out.logInfo("loading RemoteSystemsLoggingPlugin class."); //$NON-NLS-1$
}
/* (non-Javadoc)

View file

@ -19,12 +19,15 @@ package org.eclipse.rse.logging.performance;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.text.MessageFormat;
import java.util.Calendar;
import java.util.EmptyStackException;
import java.util.HashMap;
import java.util.Stack;
import java.util.StringTokenizer;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@ -50,52 +53,51 @@ import org.w3c.dom.Element;
* A performance measurement class for benchmarking.
* This performance framework provides stopwatch functions
* for calculating elapsed time for an operation.
* <p>
* This class should be used only at development time since
* it prints to System.out
* and contains non-translated strings.
* <p>
* It is highly likely that this class will be deprecated in 2.0.
* Use TPTPs tools for performance monitoring and logging.
* <pre>
* Usage example
* Method_A {
* String key = PerformanceLogger.register("RSE","WDSC","5120");
* PerformanceLogger.start(key, "OP1"); //CallerID is OP1
* Method_B();
* PerformanceLogger.stop(key);
* }
*
* Usuage example
* Method_A {
* String key = PerformanceLogger.register("RSE","WDSC","5120");
* PerformanceLogger.start(key, "OP1"); //CallerID is OP1
* Method_B();
* PerformanceLogger.stop(key);
* }
* Method_B {
* PerformanceLogger.start("RSE"); //"RSE" component, CalleID="class.method"
* // Do something
* PerformanceLogger.stop("RSE");
* }
*
* Method_B {
* PerformanceLogger.start("RSE"); //"RSE" component, CalleID="class.method"
* // Do something
* PerformanceLogger.stop("RSE");
* }
*
* Method_C {
* Method_C {
* PerformanceLogger.start(); //Use the default component for recording
* // Do something
* PerformanceLogger.stop();
* }
* }
*</pre>
*/
public class PerformanceLogger {
public final static boolean _ENABLE_PERFORMANCE_LOGGING_IBM_INTERNAL_ = false;
public final static int OPTION_GET_ALL = 1;
public final static int OPTION_GET_FEATURE = 2;
public final static int OPTION_GET_VERSION = 3;
final static String ELEMENT_TASK = "Task";
final static String ATTRIBUTE_NAME_TASKID = "CallerID";
final static String DEFAULT_COMPONENT = "_PERFORMANCELOGGER_";
static boolean ENABLE_PERFORMANCE_LOGGING = false; /*for user logging enabling*/
private final static Object[] EMPTY = {};
private final static String ELEMENT_TASK = "Task"; //$NON-NLS-1$
private final static String ATTRIBUTE_NAME_TASKID = "CallerID"; //$NON-NLS-1$
private final static String DEFAULT_COMPONENT = "_PERFORMANCELOGGER_"; //$NON-NLS-1$
private static boolean ENABLE_PERFORMANCE_LOGGING = false; /*for user logging enabling */
//static long currentAssignedID = -1;
static long samplingTime = -1; /* Elapsed time for normalization operatin */
static boolean _initialized = false;
static HashMap perfLogRegistry = new HashMap();
private static long samplingTime = -1; /* Elapsed time for normalization operation */
private static boolean _initialized = false;
private static HashMap perfLogRegistry = new HashMap();
/*
* Static initializer to normalize this logger.
@ -106,37 +108,23 @@ public class PerformanceLogger {
static class StartData {
long startTime = -1;
long stopTime = -1;
String userID = null;
String startThread = null;
String startMethod = null;
String stopThread = null;
String stopMethod = null;
Element node = null;
}
class ComponentData {
String component = null;
String timeStamp = null;
String feature = null;
String version = null;
String XMLFileID = null;
File XMLFile = null;
Document doc = null;
Stack taskStack = new Stack();
ComponentData(String comp_id) {
@ -144,16 +132,25 @@ public class PerformanceLogger {
}
}
private static void printMessage(String message, Object[] data) {
System.out.println(MessageFormat.format(message, data));
}
private static void printMessage(String message, Object value) {
printMessage(message, new Object[] {value});
}
private static void printMessage(String message) {
printMessage(message, EMPTY);
}
/**
* Enable performance logging
* The flag ENABLE_PERFORMANCE_LOGGING is enabled(true or false)
* @param enable : true or false
* @param enable true or false
*/
public static void enablePerformanceLogging(boolean enable) {
if (enable)
ENABLE_PERFORMANCE_LOGGING = true;
else
ENABLE_PERFORMANCE_LOGGING = false;
ENABLE_PERFORMANCE_LOGGING = enable;
}
/**
@ -164,24 +161,18 @@ public class PerformanceLogger {
return ENABLE_PERFORMANCE_LOGGING;
}
/* public static String register(String comp_id) : registering a component using default
* @param
* - comp_id: Component to be registered
* @return
* compont comp_id registered with no product info
/** public static String register(String comp_id) : registering a component using default
* @param comp_id Component to be registered
* @return component registered with no product info
*/
public static String register(String comp_id) {
return register(comp_id, "", "");
return register(comp_id, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
}
/* public static String register(String feature, String version) : method for registering a component using default
* @param
* - feature: Identifier for Product Feature attribute in XML
* - version: Identifier for Product Version attribute in XML
* @return
* - return default component key
* - Default component XML file created
*
/** Registers component using default component id
* @param feature Identifier for Product Feature attribute in XML
* @param version Identifier for Product Version attribute in XML
* @return default component key
*/
public static String register(String feature, String version) {
return register(DEFAULT_COMPONENT, feature, version);
@ -198,12 +189,12 @@ public class PerformanceLogger {
public static String register(String comp_id, String feature, String version) {
if ((comp_id == null) || (comp_id.length() == 0)) {
System.out.println("PerformanceLogger:register(): Cannot register null component id.");
printMessage("PerformanceLogger:register(): Cannot register null or empty component id."); //$NON-NLS-1$
return comp_id;
}
if (perfLogRegistry.containsKey(comp_id)) {
System.out.println("PerformanceLogger:register(): component \"" + comp_id + "\" already registered");
printMessage("PerformanceLogger:register(): component {0} already registered", comp_id); //$NON-NLS-1$
return comp_id;
}
@ -211,8 +202,10 @@ public class PerformanceLogger {
Calendar time = Calendar.getInstance();
compData.timeStamp = time.getTime().toString();
String userID = System.getProperty("user.name");
compData.XMLFileID = comp_id + "_" + userID + "_" + feature.replace(' ', '_') + "_" + version.replace(' ', '_') + "_perf." + compData.timeStamp.replace(' ', '_').replace(':', '_') + ".xml";
String userID = System.getProperty("user.name"); //$NON-NLS-1$
String idTemplate = "{0}_{1}_{2}_{3}_perf.{4}.xml"; //$NON-NLS-1$
String id = MessageFormat.format(idTemplate, new Object[] {comp_id, userID, feature, version, compData.timeStamp});
compData.XMLFileID = id.replace(' ', '_').replace(':', '_');
compData.XMLFile = new File(compData.XMLFileID);
compData.feature = feature;
compData.version = version;
@ -220,7 +213,7 @@ public class PerformanceLogger {
compData.taskStack = new Stack();
perfLogRegistry.put(comp_id, compData);
_initialized = true;
System.out.println("SystemPerformanceLogger: XML file created is \"" + compData.XMLFile.getAbsolutePath() + "\".");
printMessage("PerformanceLogger: XML file created is {0}.", compData.XMLFile.getAbsolutePath()); //$NON-NLS-1$
return comp_id;
}
@ -231,7 +224,7 @@ public class PerformanceLogger {
*/
public static void deRegister() {
perfLogRegistry.remove(DEFAULT_COMPONENT);
System.out.println("SystemPerformanceLogger: default component de-registered");
printMessage("SystemPerformanceLogger: default component de-registered"); //$NON-NLS-1$
}
/**
@ -242,20 +235,20 @@ public class PerformanceLogger {
*/
public static void deRegister(String key) {
perfLogRegistry.remove(key);
System.out.println("SystemPerformanceLogger: component \"" + key + "\" de-registered");
printMessage("SystemPerformanceLogger: component {0} de-registered", key); //$NON-NLS-1$
}
/**
* Set the normalization unit for this run.based on a standard method for class instance initialization.
* Set the normalization unit for this run. Based on a standard method for class instance initialization.
* @return a string containing the unit.
*/
public static String normalize() {
/*
* Execute some standard code and time it to generate our normalization interval.
* Return the value to attempt to make it is not optimized by the compiler.
* Return the value to attempt to make sure it is not optimized by the compiler.
*/
long startTime = System.currentTimeMillis();
Double q = null;
Double q = new Double(0);
int i = 0;
int n = 1000000;
for (i = 0; i < n; i++) {
@ -266,7 +259,8 @@ public class PerformanceLogger {
double val = q.doubleValue() / i;
long stopTime = System.currentTimeMillis();
samplingTime = stopTime - startTime;
String result = "SystemPerformanceLogger::Normalization Elapsed time = " + samplingTime + " " + val;
String template = "SystemPerformanceLogger::Normalization Elapsed time = {0} {1}"; //$NON-NLS-1$
String result = MessageFormat.format(template, new Object[] {new Long(samplingTime), new Double(val)});
return result;
}
@ -278,11 +272,10 @@ public class PerformanceLogger {
*/
public static long start() {
if (_initialized == false) {
register(DEFAULT_COMPONENT, "", "");
register(DEFAULT_COMPONENT, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
}
/*Use the class method name for CallerID*/
String methodPath = getMethodName(true);
return start(DEFAULT_COMPONENT, methodPath);
}
@ -294,7 +287,6 @@ public class PerformanceLogger {
public static long start(String comp_id) {
String methodPath = getMethodName(true);
return start(comp_id, methodPath);
}
/**
@ -308,7 +300,7 @@ public class PerformanceLogger {
public static long start(String comp_id, String call_id) {
if (perfLogRegistry.containsKey(comp_id) == false) {
System.out.println("PerformanceLogger:start(): component \"" + comp_id + "\" not registered");
printMessage("PerformanceLogger:start(): component {0} not registered", comp_id); //$NON-NLS-1$
return -1;
}
@ -326,8 +318,8 @@ public class PerformanceLogger {
Element root = cd.doc.getDocumentElement();
Element task = cd.doc.createElement(ELEMENT_TASK);
task.setAttribute(ATTRIBUTE_NAME_TASKID, td.userID);
task.setAttribute("StartAt", td.startMethod);
task.setAttribute("StartThread", td.startThread);
task.setAttribute("StartAt", td.startMethod); //$NON-NLS-1$
task.setAttribute("StartThread", td.startThread); //$NON-NLS-1$
td.node = task;
@ -340,7 +332,7 @@ public class PerformanceLogger {
sd.node.appendChild(task);
}
} catch (DOMException e) {
System.out.println("PerformanceLogger::updateXMLFileatStart DOM Error:" + e.toString());
printMessage("PerformanceLogger::updateXMLFileatStart DOM Error: {0}", e); //$NON-NLS-1$
}
/*Read the current time save it on stack */
@ -369,23 +361,21 @@ public class PerformanceLogger {
long st = System.currentTimeMillis();
ComponentData cd = (ComponentData) perfLogRegistry.get(comp_id);
if (cd == null) {
System.out.println("SystemPerformanceLogger::stop(): invalid registration key");
printMessage("SystemPerformanceLogger::stop(): invalid registration key"); //$NON-NLS-1$
return 0;
}
StartData td = null;
long result = 0;
try {
td = (StartData) cd.taskStack.pop();
StartData td = (StartData) cd.taskStack.pop();
td.stopTime = st;
td.stopThread = Thread.currentThread().toString();
td.stopMethod = getMethodName(false);
updateXMLFileAtStop(cd, td);
//System.out.println("SystemPerformanceLogger::stop(): timer \"" + td.userID + "\" stopped. Elapsed time = " +
// (td.stopTime-td.startTime) + " millis.");
result = td.stopTime;
} catch (EmptyStackException e) {
System.out.println("SystemPerformanceLogger:: Probably too many stop() function calls. - " + e);
printMessage("SystemPerformanceLogger:: Probably too many stop() function calls. - {0}", e); //$NON-NLS-1$
}
return td.stopTime;
return result;
}
/**
@ -394,46 +384,42 @@ public class PerformanceLogger {
*/
private static void generateXMLFile(ComponentData cd) {
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cd.XMLFile), "UTF8"));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cd.XMLFile), "UTF8")); //$NON-NLS-1$
// DOMImplementation impl = new DOMImplementationImpl();
// cd.doc = impl.createDocument(null, "Benchmark", null);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = null;
try {
builder = factory.newDocumentBuilder();
} catch (ParserConfigurationException e1) {
}
DocumentBuilder builder = factory.newDocumentBuilder();
DOMImplementation impl = builder.getDOMImplementation();
cd.doc = impl.createDocument(null, "Benchmark", null);
cd.doc = impl.createDocument(null, "Benchmark", null); //$NON-NLS-1$
// get root element and set attributes
Element root = cd.doc.getDocumentElement();
root.setAttribute("BenchmarkID", cd.XMLFileID);
root.setAttribute("TimeStamp", cd.timeStamp);
root.setAttribute("BenchmarkID", cd.XMLFileID); //$NON-NLS-1$
root.setAttribute("TimeStamp", cd.timeStamp); //$NON-NLS-1$
Element system = cd.doc.createElement("System");
Element product = cd.doc.createElement("Product");
Element system = cd.doc.createElement("System"); //$NON-NLS-1$
Element product = cd.doc.createElement("Product"); //$NON-NLS-1$
product.setAttribute("Feature", cd.feature);
product.setAttribute("Version", cd.version);
product.setAttribute("Feature", cd.feature); //$NON-NLS-1$
product.setAttribute("Version", cd.version); //$NON-NLS-1$
root.appendChild(product);
system.setAttribute("OSName", System.getProperty("os.name"));
system.setAttribute("OSVersion", System.getProperty("os.version"));
system.setAttribute("JavaVersion", System.getProperty("java.version"));
system.setAttribute("JavaVMVersion", System.getProperty("java.vm.version"));
system.setAttribute("JavaClassPath", System.getProperty("java.class.path"));
system.setAttribute("JavaLibraryPath", System.getProperty("java.library.path"));
system.setAttribute("OSName", System.getProperty("os.name")); //$NON-NLS-1$ //$NON-NLS-2$
system.setAttribute("OSVersion", System.getProperty("os.version")); //$NON-NLS-1$ //$NON-NLS-2$
system.setAttribute("JavaVersion", System.getProperty("java.version")); //$NON-NLS-1$ //$NON-NLS-2$
system.setAttribute("JavaVMVersion", System.getProperty("java.vm.version")); //$NON-NLS-1$ //$NON-NLS-2$
system.setAttribute("JavaClassPath", System.getProperty("java.class.path")); //$NON-NLS-1$ //$NON-NLS-2$
system.setAttribute("JavaLibraryPath", System.getProperty("java.library.path")); //$NON-NLS-1$ //$NON-NLS-2$
root.appendChild(system);
Element norm = cd.doc.createElement("_NORMALIZATION_VALUES");
Element norm = cd.doc.createElement("_NORMALIZATION_VALUES"); //$NON-NLS-1$
Long ems = new Long(samplingTime);
norm.setAttribute("ElapsedTime", ems.toString());
norm.setAttribute("ElapsedTime", ems.toString()); //$NON-NLS-1$
root.appendChild(norm);
/* Insert comments for Task tag */
Comment cmt1 = cd.doc.createComment("Each Task element represents one start/stop timer operation");
Comment cmt2 = cd.doc.createComment("Time recorded is in milliseconds");
Comment cmt3 = cd.doc.createComment("NormalizedFactor is the performance indicator. A larger value than the previous run might indicate performance degradation.");
Comment cmt1 = cd.doc.createComment("Each Task element represents one start/stop timer operation"); //$NON-NLS-1$
Comment cmt2 = cd.doc.createComment("Time recorded is in milliseconds"); //$NON-NLS-1$
Comment cmt3 = cd.doc.createComment("NormalizedFactor is the performance indicator. A larger value than the previous run might indicate performance degradation."); //$NON-NLS-1$
root.appendChild(cmt1);
root.appendChild(cmt2);
root.appendChild(cmt3);
@ -442,7 +428,7 @@ public class PerformanceLogger {
Source source = new DOMSource(cd.doc);
Result result = new StreamResult(writer);
Transformer t = TransformerFactory.newInstance().newTransformer();
t.setOutputProperty(OutputKeys.INDENT, "yes");
t.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
t.transform(source, result);
} catch (TransformerConfigurationException e2) {
} catch (TransformerFactoryConfigurationError e2) {
@ -458,10 +444,12 @@ public class PerformanceLogger {
// serializer.serialize(cd.doc);
// writer.close();
} catch (java.io.IOException e) {
System.out.println("PerformanceLogger::updateXML IO Error:" + e.toString());
} catch (IOException e) {
printMessage("PerformanceLogger::updateXML IO Error: {0}", e); //$NON-NLS-1$
} catch (ParserConfigurationException e) {
printMessage("PerformanceLogger::updateXML Parser Configuration Error: {0}", e); //$NON-NLS-1$
} catch (DOMException e) {
System.out.println("PerformanceLogger::updateXML DOM Error:" + e.toString());
printMessage("PerformanceLogger::updateXML DOM Error: {0}", e); //$NON-NLS-1$
}
}
@ -472,7 +460,7 @@ public class PerformanceLogger {
private static void updateXMLFileAtStop(ComponentData cd, StartData td) {
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cd.XMLFile), "UTF8"));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cd.XMLFile), "UTF8")); //$NON-NLS-1$
cd.doc.getDocumentElement();
Element task = td.node;
@ -481,7 +469,7 @@ public class PerformanceLogger {
Long sms = new Long(td.startTime);
Long tms = new Long(td.stopTime);
/*Calculate the normalization factor*/
String normalizedFactor = "invalid";
String normalizedFactor = "invalid"; //$NON-NLS-1$
if (samplingTime > 0) {
Long sam = new Long(samplingTime);
Double val = new Double(ems.doubleValue() / sam.doubleValue());
@ -489,20 +477,20 @@ public class PerformanceLogger {
}
/* Update the document */
task.setAttribute("ElapsedTime", ems.toString());
task.setAttribute("NormalizedFactor", normalizedFactor);
task.setAttribute("StartTime", sms.toString());
task.setAttribute("StopTime", tms.toString());
task.setAttribute("StartAt", td.startMethod);
task.setAttribute("StartThread", td.startThread);
task.setAttribute("StopAt", td.stopMethod);
task.setAttribute("StopThread", td.stopThread);
task.setAttribute("ElapsedTime", ems.toString()); //$NON-NLS-1$
task.setAttribute("NormalizedFactor", normalizedFactor); //$NON-NLS-1$
task.setAttribute("StartTime", sms.toString()); //$NON-NLS-1$
task.setAttribute("StopTime", tms.toString()); //$NON-NLS-1$
task.setAttribute("StartAt", td.startMethod); //$NON-NLS-1$
task.setAttribute("StartThread", td.startThread); //$NON-NLS-1$
task.setAttribute("StopAt", td.stopMethod); //$NON-NLS-1$
task.setAttribute("StopThread", td.stopThread); //$NON-NLS-1$
try {
Source source = new DOMSource(cd.doc);
Result result = new StreamResult(writer);
Transformer t = TransformerFactory.newInstance().newTransformer();
t.setOutputProperty(OutputKeys.INDENT, "yes");
t.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
t.transform(source, result);
} catch (TransformerConfigurationException e2) {
} catch (TransformerFactoryConfigurationError e2) {
@ -519,9 +507,9 @@ public class PerformanceLogger {
// serializer.serialize(cd.doc);
// writer.close();
} catch (java.io.IOException e) {
System.out.println("PerformanceLogger::updateXMLFileAtStop IO Error:" + e.toString());
printMessage("PerformanceLogger::updateXMLFileAtStop IO Error: {0}", e); //$NON-NLS-1$
} catch (DOMException e) {
System.out.println("PerformanceLogger::updateXMLFileAtStop DOM Error:" + e.toString());
printMessage("PerformanceLogger::updateXMLFileAtStop DOM Error: {0}", e); //$NON-NLS-1$
}
}
@ -539,7 +527,7 @@ public class PerformanceLogger {
public static String getCurrentProductInfo(int req, String comp_id) {
ComponentData cd = (ComponentData) perfLogRegistry.get(comp_id);
if (cd == null) {
System.out.println("PerformanceLogger::getCurrentProductInfo invalid comp_id");
printMessage("PerformanceLogger::getCurrentProductInfo invalid comp_id"); //$NON-NLS-1$
return null;
}
@ -573,10 +561,10 @@ public class PerformanceLogger {
StringWriter strwriter = new StringWriter(100);
e.printStackTrace(new java.io.PrintWriter(strwriter));
String stack = strwriter.toString();
java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(stack, "\r\n");
StringTokenizer tokenizer = new StringTokenizer(stack, "\r\n"); //$NON-NLS-1$
/*
* Here to parse the exception string to get the caller which is the current method location
* to be obtained. The Exception stack should show the PerformanceLogger start() in the satck first:
* to be obtained. The Exception stack should show the PerformanceLogger start() in the stack first:
* -java.lang.Exception
* -at org.eclipse.rse.logging.performance.PerformanceLogger.start(PerformanceLogger.java:151)
* -at org.eclipse.rse.logging.performance.PerformanceLogger.start(PerformanceLogger.java:135)
@ -585,24 +573,25 @@ public class PerformanceLogger {
for (int i = 0; tokenizer.hasMoreTokens(); i++) {
methodPath = tokenizer.nextToken();
if ((methodPath.indexOf("java.lang.Throwable") == -1) && (methodPath.indexOf("logging.performance.PerformanceLogger") == -1)) break;
if ((methodPath.indexOf("java.lang.Throwable") == -1) && (methodPath.indexOf("logging.performance.PerformanceLogger") == -1)) break; //$NON-NLS-1$ //$NON-NLS-2$
}
methodPath = methodPath.substring(4);
if (parsed) {
try {
int i = methodPath.indexOf('(');
if (i != -1) methodPath = methodPath.substring(0, i); //strip of the substring enclosed in ()
//Now we have "org.eclipse.rse.logging.performance.PerformanceLogger.start"
i = methodPath.lastIndexOf('.'); //Get the method name after the last period (.)
String methodName = methodPath.substring(i + 1); //Now we have the method name "start"
String className = methodPath.substring(0, i); //remove method name from the string
//We are left with "org.eclipse.rse.logging.performance.PerformanceLogger"
i = className.lastIndexOf('.');
if (i != -1) className = className.substring(i + 1); //Now we have the class name "PerformanceLogger"
methodPath = className + "." + methodName;
} catch (IndexOutOfBoundsException ex) {
System.out.println("PerformanceLogger:getMethodName exception" + ex.toString());
if (methodPath != null) {
methodPath = methodPath.substring(4);
if (parsed) {
try {
int i = methodPath.indexOf('(');
if (i != -1) methodPath = methodPath.substring(0, i); //strip of the substring enclosed in ()
//Now we have "org.eclipse.rse.logging.performance.PerformanceLogger.start"
i = methodPath.lastIndexOf('.'); //Get the method name after the last period (.)
String methodName = methodPath.substring(i + 1); //Now we have the method name "start"
String className = methodPath.substring(0, i); //remove method name from the string
//We are left with "org.eclipse.rse.logging.performance.PerformanceLogger"
i = className.lastIndexOf('.');
if (i != -1) className = className.substring(i + 1); //Now we have the class name "PerformanceLogger"
methodPath = className + "." + methodName; //$NON-NLS-1$
} catch (IndexOutOfBoundsException ex) {
printMessage("PerformanceLogger:getMethodName exception {0}", ex); //$NON-NLS-1$
}
}
}
return methodPath; /*delete " at" in the beginning of the string */
@ -622,11 +611,11 @@ public class PerformanceLogger {
* </ul>
*/
public static void listSystemProfile() {
System.out.println("java version : " + System.getProperty("java.version"));
System.out.println("OS name : " + System.getProperty("os.name"));
System.out.println("OS version : " + System.getProperty("os.version"));
System.out.println("working dir : " + System.getProperty("user.dir"));
System.out.println("home dir : " + System.getProperty("home.dir"));
System.out.println("java version : " + System.getProperty("java.version")); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println("OS name : " + System.getProperty("os.name")); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println("OS version : " + System.getProperty("os.version")); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println("working dir : " + System.getProperty("user.dir")); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println("home dir : " + System.getProperty("home.dir")); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@ -648,44 +637,44 @@ public class PerformanceLogger {
}
PerformanceLogger.enablePerformanceLogging(true);
String key = PerformanceLogger.register("", "WDSC", "5120");
key = PerformanceLogger.register("RSE", "WDSC", "5120");
PerformanceLogger.deRegister("XXX"); //not registered key previously
System.out.println("Product info : " + PerformanceLogger.getCurrentProductInfo(PerformanceLogger.OPTION_GET_FEATURE, key) + " "
String key = PerformanceLogger.register("", "WDSC", "5120"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
key = PerformanceLogger.register("RSE", "WDSC", "5120"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
PerformanceLogger.deRegister("XXX"); //not registered key previously //$NON-NLS-1$
System.out.println("Product info : " + PerformanceLogger.getCurrentProductInfo(PerformanceLogger.OPTION_GET_FEATURE, key) + " " //$NON-NLS-1$ //$NON-NLS-2$
+ PerformanceLogger.getCurrentProductInfo(PerformanceLogger.OPTION_GET_VERSION, key));
PerformanceLogger.start(key, "NOT_NESTED_1");
PerformanceLogger.start(key, "NOT_NESTED_1"); //$NON-NLS-1$
for (i = 0; i < 1000000; i++) {
//empty performance test loop
}
PerformanceLogger.stop(key);
PerformanceLogger.start(key, "NESTED_ONE");
PerformanceLogger.start(key, "NESTED_ONE"); //$NON-NLS-1$
for (i = 0; i < 500; i++) {
//empty performance test loop
}
PerformanceLogger.start(key, "NESTED_ONE_CHILD");
PerformanceLogger.start(key, "NESTED_ONE_CHILD"); //$NON-NLS-1$
for (i = 0; i < 300; i++) {
//empty performance test loop
}
PerformanceLogger.stop(key);
PerformanceLogger.stop(key);
PerformanceLogger.start(key, "NOT_NESTED_2");
PerformanceLogger.start(key, "NOT_NESTED_2"); //$NON-NLS-1$
for (i = 0; i < 2000000; i++) {
//empty performance test loop
}
PerformanceLogger.stop(key);
PerformanceLogger.start(key, "NESTED_THREE");
PerformanceLogger.start(key, "NESTED_THREE"); //$NON-NLS-1$
for (i = 0; i < 300; i++) {
//empty performance test loop
}
PerformanceLogger.start(key, "NESTED_TWO_CHILD1");
PerformanceLogger.start(key, "NESTED_TWO_CHILD2");
PerformanceLogger.start(key, "NESTED_TWO_CHILD1"); //$NON-NLS-1$
PerformanceLogger.start(key, "NESTED_TWO_CHILD2"); //$NON-NLS-1$
for (i = 0; i < 4000; i++) {
//empty performance test loop
}
PerformanceLogger.start(key, "NESTED_TWO_CHILD3");
PerformanceLogger.start(key, "NESTED_TWO_CHILD3"); //$NON-NLS-1$
for (i = 0; i < 6000; i++) {
//empty performance test loop
}
@ -694,7 +683,7 @@ public class PerformanceLogger {
PerformanceLogger.stop(key);
PerformanceLogger.stop(key);
PerformanceLogger.start("ABC"); //Expect error: not registered
PerformanceLogger.start("ABC"); //Expect error: not registered //$NON-NLS-1$
PerformanceLogger.start(key); //record timer in the previous registered component
for (i = 0; i < 3000000; i++) {
//empty performance test loop

View file

@ -25,8 +25,8 @@ import java.util.Set;
*/
public class LabelUtil {
private final static String upperLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private final static String lowerLetters = "abcdefghijklmnopqrstuvwxyz";
private final static String upperLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //$NON-NLS-1$
private final static String lowerLetters = "abcdefghijklmnopqrstuvwxyz"; //$NON-NLS-1$
private final static char lpar = '(';
private final static char rpar = ')';
private final static char trigger = '&';

View file

@ -17,7 +17,6 @@
package org.eclipse.rse.logging.ui;
import java.text.MessageFormat;
import java.util.Set;
import org.eclipse.core.runtime.Plugin;
@ -33,7 +32,6 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
@ -116,15 +114,15 @@ public abstract class LoggingPreferencePage extends PreferencePage implements IW
* @param text the text for the new label
* @return the new label
*/
private Label createLabel(Composite parent, int span, String text) {
Label label = new Label(parent, SWT.LEFT);
label.setText(text);
GridData data = new GridData();
data.horizontalSpan = span;
data.horizontalAlignment = GridData.FILL;
label.setLayoutData(data);
return label;
}
// private Label createLabel(Composite parent, int span, String text) {
// Label label = new Label(parent, SWT.LEFT);
// label.setText(text);
// GridData data = new GridData();
// data.horizontalSpan = span;
// data.horizontalAlignment = GridData.FILL;
// label.setLayoutData(data);
// return label;
// }
/**
* Method declared on PreferencePage
@ -137,7 +135,7 @@ public abstract class LoggingPreferencePage extends PreferencePage implements IW
// createLabel(composite_tab, 1, topLabel1);
String topLabel2 = LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_TOPLABEL2;
Group group1 = createGroup(composite_tab, 1, 1, topLabel2);
Set used = LabelUtil.usedFromString("ad"); // the mnemonics already used on preference page (in English)
Set used = LabelUtil.usedFromString("ad"); //$NON-NLS-1$ // the mnemonics already used on preference page (in English)
String text = LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_ERRORS_ONLY;
radioButton0 = createRadioButton(group1, LabelUtil.assignMnemonic(text, used));
text = LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_WARNINGS_ERRORS;
@ -149,7 +147,7 @@ public abstract class LoggingPreferencePage extends PreferencePage implements IW
radioButton3 = createRadioButton(group1, LabelUtil.assignMnemonic(text, used));
}
initializeValues();
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.eclipse.rse.logging.rsel0000");
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.eclipse.rse.logging.rsel0000"); //$NON-NLS-1$
return composite_tab;
}