mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-08 09:35:23 +02:00
Bug 148484 - Refactor logging plugin
This commit is contained in:
parent
568e8c931c
commit
891609edee
21 changed files with 888 additions and 1199 deletions
|
@ -12,15 +12,18 @@ Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||||
Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
|
|
||||||
Contributors:
|
Contributors:
|
||||||
{Name} (company) - description of contribution.
|
Michael Berger (IBM Canada) - 148434 Better user assistance for logging preference page.
|
||||||
-->
|
-->
|
||||||
<?NLS TYPE="org.eclipse.help.contexts"?>
|
<?NLS TYPE="org.eclipse.help.contexts"?>
|
||||||
|
|
||||||
<contexts>
|
<contexts>
|
||||||
|
<!-- RSE logging -->
|
||||||
<context id="pref0000">
|
<context id="rsel0000">
|
||||||
<description>Settings for the logging of messages.</description>
|
<description>This is the RSE Logging preference page.
|
||||||
|
You can specify what severity of messages you wish to log - from informational messages, to warnings, to errors.
|
||||||
</context>
|
The debug setting provides the most detail.
|
||||||
|
Messages are logged to the .log file in the .metadata folder of the workspace.
|
||||||
|
</description>
|
||||||
|
</context>
|
||||||
|
|
||||||
</contexts>
|
</contexts>
|
|
@ -9,5 +9,6 @@ Require-Bundle: org.eclipse.ui,
|
||||||
org.eclipse.core.runtime
|
org.eclipse.core.runtime
|
||||||
Eclipse-LazyStart: true
|
Eclipse-LazyStart: true
|
||||||
Export-Package: org.eclipse.rse.logging,
|
Export-Package: org.eclipse.rse.logging,
|
||||||
org.eclipse.rse.logging.performance
|
org.eclipse.rse.logging.performance,
|
||||||
|
org.eclipse.rse.logging.ui
|
||||||
Bundle-Vendor: Eclipse.org
|
Bundle-Vendor: Eclipse.org
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
bin.includes = HelpContexts.xml,\
|
bin.includes = HelpContexts.xml,\
|
||||||
RemoteSystemsLogging.properties,\
|
|
||||||
plugin.properties,\
|
plugin.properties,\
|
||||||
plugin.xml,\
|
plugin.xml,\
|
||||||
style/,\
|
style/,\
|
||||||
|
|
|
@ -31,7 +31,7 @@ Contributors:
|
||||||
|
|
||||||
<!-- Preferences -->
|
<!-- Preferences -->
|
||||||
<extension point="org.eclipse.core.runtime.preferences">
|
<extension point="org.eclipse.core.runtime.preferences">
|
||||||
<initializer class="org.eclipse.rse.logging.LoggingPreferenceInitializer"/>
|
<initializer class="org.eclipse.rse.internal.logging.LoggingPreferenceInitializer"/>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
/********************************************************************************
|
|
||||||
* Copyright (c) 2002, 2006 IBM Corporation. All rights reserved.
|
|
||||||
* This program and the accompanying materials are made available under the terms
|
|
||||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
|
||||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*
|
|
||||||
* Initial Contributors:
|
|
||||||
* The following IBM employees contributed to the Remote System Explorer
|
|
||||||
* component that contains this file: David McKnight, Kushal Munir,
|
|
||||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* {Name} (company) - description of contribution.
|
|
||||||
********************************************************************************/
|
|
||||||
|
|
||||||
package org.eclipse.rse.internal.logging;
|
|
||||||
|
|
||||||
import java.util.Hashtable;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Plugin;
|
|
||||||
import org.eclipse.rse.logging.Logger;
|
|
||||||
|
|
||||||
public class LoggerController {
|
|
||||||
|
|
||||||
private static Hashtable pluginTable = new Hashtable();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return an previously cached Logger instance.<br>
|
|
||||||
* It will return null if no Logger instance has been created
|
|
||||||
* for this plugin before.
|
|
||||||
*/
|
|
||||||
public static Logger getInst(Plugin plugin) {
|
|
||||||
if (pluginTable.containsKey(plugin))
|
|
||||||
return (Logger) pluginTable.get(plugin);
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerInst(Plugin plugin, Logger logger) {
|
|
||||||
pluginTable.put(plugin, logger);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void freeInst(Plugin plugin) {
|
|
||||||
// get cached instance if one exists.
|
|
||||||
Logger logger = getInst(plugin);
|
|
||||||
// no luck, this means we have an incorrect free, do nothing.
|
|
||||||
if (logger == null)
|
|
||||||
return;
|
|
||||||
logger.freeResources();
|
|
||||||
pluginTable.remove(plugin);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -14,9 +14,12 @@
|
||||||
* {Name} (company) - description of contribution.
|
* {Name} (company) - description of contribution.
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.logging;
|
package org.eclipse.rse.internal.logging;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.Preferences;
|
||||||
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
||||||
|
import org.eclipse.rse.logging.IRemoteSystemsLogging;
|
||||||
|
import org.eclipse.rse.logging.RemoteSystemsLoggingPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class initializes logging preferences.
|
* This class initializes logging preferences.
|
||||||
|
@ -34,6 +37,7 @@ public class LoggingPreferenceInitializer extends AbstractPreferenceInitializer
|
||||||
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
|
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
|
||||||
*/
|
*/
|
||||||
public void initializeDefaultPreferences() {
|
public void initializeDefaultPreferences() {
|
||||||
RemoteSystemsLoggingPlugin.getDefault().initializeDefaultPreferences();
|
Preferences prefs = RemoteSystemsLoggingPlugin.getDefault().getPluginPreferences();
|
||||||
|
prefs.setDefault(IRemoteSystemsLogging.DEBUG_LEVEL, IRemoteSystemsLogging.LOG_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,59 +0,0 @@
|
||||||
/********************************************************************************
|
|
||||||
* Copyright (c) 2006 IBM Corporation. All rights reserved.
|
|
||||||
* This program and the accompanying materials are made available under the terms
|
|
||||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
|
||||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*
|
|
||||||
* Initial Contributors:
|
|
||||||
* The following IBM employees contributed to the Remote System Explorer
|
|
||||||
* component that contains this file: David McKnight, Kushal Munir,
|
|
||||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* {Name} (company) - description of contribution.
|
|
||||||
********************************************************************************/
|
|
||||||
|
|
||||||
package org.eclipse.rse.logging;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Plugin;
|
|
||||||
import org.osgi.framework.BundleContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The main plugin class to be used in the desktop.
|
|
||||||
*/
|
|
||||||
public class Activator extends Plugin {
|
|
||||||
|
|
||||||
//The shared instance.
|
|
||||||
private static Activator plugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The constructor.
|
|
||||||
*/
|
|
||||||
public Activator() {
|
|
||||||
plugin = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called upon plug-in activation
|
|
||||||
*/
|
|
||||||
public void start(BundleContext context) throws Exception {
|
|
||||||
super.start(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called when the plug-in is stopped
|
|
||||||
*/
|
|
||||||
public void stop(BundleContext context) throws Exception {
|
|
||||||
super.stop(context);
|
|
||||||
plugin = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the shared instance.
|
|
||||||
*/
|
|
||||||
public static Activator getDefault() {
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -21,59 +21,39 @@ package org.eclipse.rse.logging;
|
||||||
*/
|
*/
|
||||||
public interface IRemoteSystemsLogging {
|
public interface IRemoteSystemsLogging {
|
||||||
|
|
||||||
|
|
||||||
// All attributes here are static final.
|
|
||||||
/**
|
/**
|
||||||
* Name of the key that controls the logging level.<br>
|
* Name of the key that controls the logging level.<br>
|
||||||
*/
|
*/
|
||||||
String PLUGIN_ID = "org.eclipse.rse.logging";
|
public static final String PLUGIN_ID = "org.eclipse.rse.logging";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the key that controls the logging level.<br>
|
* Name of the key that controls the logging level.<br>
|
||||||
* (value is "debug_level").
|
* (value is "debug_level").
|
||||||
*/
|
*/
|
||||||
String DEBUG_LEVEL = "debug_level";
|
public static final String DEBUG_LEVEL = "debug_level";
|
||||||
|
|
||||||
/**
|
|
||||||
* Name of the key that controls the log location.<br>
|
|
||||||
* (value is "log_location").
|
|
||||||
*/
|
|
||||||
String LOG_LOCATION = "log_location";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set debug_level to this value to get Error messages.<br>
|
* Set debug_level to this value to get Error messages.<br>
|
||||||
* (value is 0).
|
* (value is 0).
|
||||||
*/
|
*/
|
||||||
int LOG_ERROR = 0;
|
public static final int LOG_ERROR = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set debug_level to this value to get Warning messages.<br>
|
* Set debug_level to this value to get Warning messages.<br>
|
||||||
* (value is 1).
|
* (value is 1).
|
||||||
*/
|
*/
|
||||||
int LOG_WARNING = 1;
|
public static final int LOG_WARNING = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set debug_level to this value to get Information messages.<br>
|
* Set debug_level to this value to get Information messages.<br>
|
||||||
* (value is 2).
|
* (value is 2).
|
||||||
*/
|
*/
|
||||||
int LOG_INFO = 2;
|
public static final int LOG_INFO = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set debug_level to this value to get Debug messages.<br>
|
* Set debug_level to this value to get Debug messages.<br>
|
||||||
* (value is 3).
|
* (value is 3).
|
||||||
*/
|
*/
|
||||||
int LOG_DEBUG = 3;
|
public static final int LOG_DEBUG = 3;
|
||||||
|
|
||||||
/**
|
|
||||||
* Set log_location to this value to log to a file.<br>
|
|
||||||
* (value is "Log_To_File").
|
|
||||||
*/
|
|
||||||
String LOG_TO_FILE = "Log_To_File";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set log_location to this value to log to a Std out.<br>
|
|
||||||
* (value is "Log_To_StdOut").
|
|
||||||
*/
|
|
||||||
String LOG_TO_STDOUT = "Log_To_StdOut";
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -19,15 +19,11 @@ package org.eclipse.rse.logging;
|
||||||
import org.eclipse.core.runtime.ILog;
|
import org.eclipse.core.runtime.ILog;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.MultiStatus;
|
import org.eclipse.core.runtime.MultiStatus;
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
import org.eclipse.core.runtime.Plugin;
|
import org.eclipse.core.runtime.Plugin;
|
||||||
import org.eclipse.core.runtime.Preferences;
|
import org.eclipse.core.runtime.Preferences;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
|
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
|
||||||
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
|
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
|
||||||
import org.eclipse.rse.internal.logging.RemoteSystemLogListener;
|
|
||||||
import org.osgi.framework.Bundle;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic Logger class for handling Remote Systems logging and tracing.<br>
|
* Generic Logger class for handling Remote Systems logging and tracing.<br>
|
||||||
|
@ -59,8 +55,7 @@ import org.osgi.framework.Bundle;
|
||||||
* out.logInfo("loading myPlugin class.");<br>
|
* out.logInfo("loading myPlugin class.");<br>
|
||||||
* //out.logWarning("This is a warning message.");<br>
|
* //out.logWarning("This is a warning message.");<br>
|
||||||
* //out.logError("This is an error.", new Exception());<br>
|
* //out.logError("This is an error.", new Exception());<br>
|
||||||
* //if (Logger.DEBUG)<br>
|
* //out.logDebugMessage(<br>
|
||||||
* // out.logDebugMessage(<br>
|
|
||||||
* // "myPlugin",<br>
|
* // "myPlugin",<br>
|
||||||
* // "this is a debug message from class myPlugin.");<br>
|
* // "this is a debug message from class myPlugin.");<br>
|
||||||
* ......<br>
|
* ......<br>
|
||||||
|
@ -77,69 +72,41 @@ import org.osgi.framework.Bundle;
|
||||||
*/
|
*/
|
||||||
public class Logger implements IPropertyChangeListener {
|
public class Logger implements IPropertyChangeListener {
|
||||||
|
|
||||||
public static final String Copyright =
|
|
||||||
"(C) Copyright IBM Corp. 2002, 2003. All Rights Reserved.";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This SHOULD be set to false in production.<br>
|
|
||||||
* Used to compile out developement debug messages.<br>
|
|
||||||
*/
|
|
||||||
public final static boolean DEBUG = false;
|
|
||||||
|
|
||||||
// Cashed workbenchPlugin Log, LogListener instances
|
|
||||||
private ILog systemsPluginLog = null;
|
private ILog systemsPluginLog = null;
|
||||||
private RemoteSystemLogListener logListener = null;
|
private RemoteSystemLogListener logListener = null;
|
||||||
|
|
||||||
// Cashed Plugin ID, and plugin
|
|
||||||
private String pluginId = null;
|
private String pluginId = null;
|
||||||
Plugin systemPlugin = null;
|
private Plugin systemPlugin = null;
|
||||||
|
private int debug_level = IRemoteSystemsLogging.LOG_ERROR;
|
||||||
|
|
||||||
// Controls logging level
|
/**
|
||||||
private int debug_level = 0;
|
* Creates a new Logger. Invoked by the LoggerFactory.
|
||||||
|
* @param systemPlugin The preferences for this plugin will determine the detail
|
||||||
// Captures initialization errors
|
* logged by this logger. This allows different levels of detail to be logged in the
|
||||||
private boolean init_ok = true;
|
* workbench.
|
||||||
|
* @see LoggerFactory#getInst(Plugin);
|
||||||
protected Logger(Plugin systemPlugin) {
|
*/
|
||||||
|
Logger(Plugin systemPlugin) {
|
||||||
this.systemPlugin = systemPlugin;
|
this.systemPlugin = systemPlugin;
|
||||||
this.pluginId = systemPlugin.getBundle().getSymbolicName();
|
this.pluginId = systemPlugin.getBundle().getSymbolicName();
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the Logger. The logger uses an ILog from the platform for this particular plugin, and
|
||||||
|
* establishes a listener on that log to format the items placed in the log.
|
||||||
|
*/
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
try {
|
|
||||||
|
|
||||||
systemsPluginLog = systemPlugin.getLog();
|
systemsPluginLog = systemPlugin.getLog();
|
||||||
if (logListener == null)
|
|
||||||
logListener = new RemoteSystemLogListener(systemPlugin);
|
logListener = new RemoteSystemLogListener(systemPlugin);
|
||||||
systemsPluginLog.addLogListener(logListener);
|
systemsPluginLog.addLogListener(logListener);
|
||||||
|
|
||||||
// get the debug level from plugin Preference store.
|
|
||||||
// note: logListener must be initialized before calling getPreference store!
|
|
||||||
Preferences store = systemPlugin.getPluginPreferences();
|
Preferences store = systemPlugin.getPluginPreferences();
|
||||||
debug_level = store.getInt(IRemoteSystemsLogging.DEBUG_LEVEL);
|
debug_level = store.getInt(IRemoteSystemsLogging.DEBUG_LEVEL);
|
||||||
|
|
||||||
store.addPropertyChangeListener(this);
|
store.addPropertyChangeListener(this);
|
||||||
store.addPropertyChangeListener(logListener);
|
store.addPropertyChangeListener(logListener);
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Errors occured during initialize, disable logging.
|
|
||||||
// should never be here. Use Platform logger instead.
|
|
||||||
Bundle bundle = Platform.getBundle(Platform.PI_RUNTIME);
|
|
||||||
Platform.getLog(bundle).log(
|
|
||||||
new Status(
|
|
||||||
IStatus.ERROR,
|
|
||||||
IRemoteSystemsLogging.PLUGIN_ID,
|
|
||||||
IStatus.OK,
|
|
||||||
"could not create Logger for " + pluginId,
|
|
||||||
e));
|
|
||||||
init_ok = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a Debug message. This is intended to be wrapped as follows:<br>
|
* Log a Debug message. This is intended to be used as follows:<br>
|
||||||
* if (Logger.DEBUG)<br>
|
|
||||||
* Logger.logDebugMessage("someClassName", "someMessage");<br>
|
* Logger.logDebugMessage("someClassName", "someMessage");<br>
|
||||||
* <br>
|
* <br>
|
||||||
* and the output will be:<br>
|
* and the output will be:<br>
|
||||||
|
@ -153,16 +120,10 @@ public class Logger implements IPropertyChangeListener {
|
||||||
* Note that since this message is only for developer debugging, it does not
|
* Note that since this message is only for developer debugging, it does not
|
||||||
* need to be localized to proper local.<br>
|
* need to be localized to proper local.<br>
|
||||||
*/
|
*/
|
||||||
|
public synchronized void logDebugMessage(String className, String message) {
|
||||||
public synchronized void logDebugMessage(
|
if (debug_level >= IRemoteSystemsLogging.LOG_DEBUG) {
|
||||||
String className,
|
MultiStatus debugStatus = new MultiStatus(pluginId, IStatus.OK, className, null);
|
||||||
String message) {
|
Status infoStatus = new Status(IStatus.OK, pluginId, IStatus.OK, message, null);
|
||||||
if ((init_ok) && (debug_level >= IRemoteSystemsLogging.LOG_DEBUG)) {
|
|
||||||
// ie: print all INFO, WARNING and ERROR messages
|
|
||||||
MultiStatus debugStatus =
|
|
||||||
new MultiStatus(pluginId, IStatus.OK, className, null);
|
|
||||||
Status infoStatus =
|
|
||||||
new Status(IStatus.OK, pluginId, IStatus.OK, message, null);
|
|
||||||
debugStatus.add(infoStatus);
|
debugStatus.add(infoStatus);
|
||||||
systemsPluginLog.log(debugStatus);
|
systemsPluginLog.log(debugStatus);
|
||||||
}
|
}
|
||||||
|
@ -173,16 +134,11 @@ public class Logger implements IPropertyChangeListener {
|
||||||
* be localized to proper local.<br>
|
* be localized to proper local.<br>
|
||||||
* ie: Resource.getString() should already have been called
|
* ie: Resource.getString() should already have been called
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public synchronized void logError(String message, Throwable ex) {
|
public synchronized void logError(String message, Throwable ex) {
|
||||||
if ((init_ok) && (debug_level >= IRemoteSystemsLogging.LOG_ERROR)) {
|
if (debug_level >= IRemoteSystemsLogging.LOG_ERROR) {
|
||||||
// ie: print only ERROR messages
|
if (message == null) message = "";
|
||||||
if (message == null)
|
Status errorStatus = new Status(IStatus.ERROR, pluginId, IStatus.OK, message, ex);
|
||||||
message = "";
|
|
||||||
Status errorStatus =
|
|
||||||
new Status(IStatus.ERROR, pluginId, IStatus.OK, message, ex);
|
|
||||||
systemsPluginLog.log(errorStatus);
|
systemsPluginLog.log(errorStatus);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,8 +147,7 @@ public class Logger implements IPropertyChangeListener {
|
||||||
* be localized to proper local.<br>
|
* be localized to proper local.<br>
|
||||||
* ie: Resource.getString() should already have been called
|
* ie: Resource.getString() should already have been called
|
||||||
*/
|
*/
|
||||||
public synchronized void logInfo(String message)
|
public synchronized void logInfo(String message) {
|
||||||
{
|
|
||||||
logInfo(message, null);
|
logInfo(message, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,18 +156,12 @@ public class Logger implements IPropertyChangeListener {
|
||||||
* be localized to proper local.<br>
|
* be localized to proper local.<br>
|
||||||
* ie: Resource.getString() should already have been called
|
* ie: Resource.getString() should already have been called
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public synchronized void logInfo(String message, Throwable ex) {
|
public synchronized void logInfo(String message, Throwable ex) {
|
||||||
if ((init_ok) && (debug_level >= IRemoteSystemsLogging.LOG_INFO)) {
|
if (debug_level >= IRemoteSystemsLogging.LOG_INFO) {
|
||||||
if (message == null)
|
if (message == null) message = "";
|
||||||
message = "";
|
Status infoStatus = new Status(IStatus.INFO, pluginId, IStatus.OK, message, ex);
|
||||||
// ie: print all INFO, WARNING and ERROR messages
|
|
||||||
Status infoStatus =
|
|
||||||
new Status(IStatus.INFO, pluginId, IStatus.OK, message, ex);
|
|
||||||
systemsPluginLog.log(infoStatus);
|
systemsPluginLog.log(infoStatus);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -220,8 +169,7 @@ public class Logger implements IPropertyChangeListener {
|
||||||
* be localized to proper local.<br>
|
* be localized to proper local.<br>
|
||||||
* ie: Resource.getString() should already have been called
|
* ie: Resource.getString() should already have been called
|
||||||
*/
|
*/
|
||||||
public synchronized void logWarning(String message)
|
public synchronized void logWarning(String message) {
|
||||||
{
|
|
||||||
logWarning(message, null);
|
logWarning(message, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,20 +179,11 @@ public class Logger implements IPropertyChangeListener {
|
||||||
* ie: Resource.getString() should already have been called
|
* ie: Resource.getString() should already have been called
|
||||||
*/
|
*/
|
||||||
public synchronized void logWarning(String message, Throwable ex) {
|
public synchronized void logWarning(String message, Throwable ex) {
|
||||||
if ((init_ok) && (debug_level >= IRemoteSystemsLogging.LOG_WARNING)) {
|
if (debug_level >= IRemoteSystemsLogging.LOG_WARNING) {
|
||||||
if (message == null)
|
if (message == null) message = "";
|
||||||
message = "";
|
Status warningStatus = new Status(IStatus.WARNING, pluginId, IStatus.OK, message, ex);
|
||||||
// ie: print all WARNING and ERROR messages
|
|
||||||
Status warningStatus =
|
|
||||||
new Status(
|
|
||||||
IStatus.WARNING,
|
|
||||||
pluginId,
|
|
||||||
IStatus.OK,
|
|
||||||
message,
|
|
||||||
ex);
|
|
||||||
systemsPluginLog.log(warningStatus);
|
systemsPluginLog.log(warningStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void setDebugLevel(int level) {
|
public synchronized void setDebugLevel(int level) {
|
||||||
|
@ -260,10 +199,9 @@ public class Logger implements IPropertyChangeListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle changes from Preferences page.
|
* Handle changes from a Preferences page.
|
||||||
*/
|
*/
|
||||||
public synchronized void propertyChange(PropertyChangeEvent event) {
|
public synchronized void propertyChange(PropertyChangeEvent event) {
|
||||||
// refresh the debug level from plugin Preference store
|
|
||||||
Preferences prefs = systemPlugin.getPluginPreferences();
|
Preferences prefs = systemPlugin.getPluginPreferences();
|
||||||
debug_level = prefs.getInt(IRemoteSystemsLogging.DEBUG_LEVEL);
|
debug_level = prefs.getInt(IRemoteSystemsLogging.DEBUG_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
|
|
||||||
package org.eclipse.rse.logging;
|
package org.eclipse.rse.logging;
|
||||||
|
|
||||||
|
import java.util.Hashtable;
|
||||||
import org.eclipse.core.runtime.Plugin;
|
import org.eclipse.core.runtime.Plugin;
|
||||||
import org.eclipse.rse.internal.logging.LoggerController;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory class for creating Logger instances.<br>
|
* Factory class for creating Logger instances.<br>
|
||||||
|
@ -27,39 +27,31 @@ import org.eclipse.rse.internal.logging.LoggerController;
|
||||||
*/
|
*/
|
||||||
public class LoggerFactory {
|
public class LoggerFactory {
|
||||||
|
|
||||||
|
private static Hashtable pluginTable = new Hashtable();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a Logger instance for the given plugin.<br> Note that there is only
|
* Returns the Logger instance for a given plugin. There is only
|
||||||
* a singelton instance of the Logger class per plugin. You are guarenteed the
|
* one instance of the Logger class per plugin.
|
||||||
* same instance if one has previously been created.
|
|
||||||
*/
|
*/
|
||||||
public static Logger getInst(Plugin plugin) {
|
public static Logger getLogger(Plugin plugin) {
|
||||||
|
Logger logger = (Logger) pluginTable.get(plugin);
|
||||||
// get cached instance from controller if one exists.
|
if (logger == null) {
|
||||||
Logger inst = LoggerController.getInst(plugin);
|
logger = new Logger(plugin);
|
||||||
// no luck, create it and register it with the controller, and create
|
pluginTable.put(plugin, logger);
|
||||||
// preference page.
|
|
||||||
if (inst == null) {
|
|
||||||
inst = new Logger(plugin);
|
|
||||||
LoggerController.registerInst(plugin, inst);
|
|
||||||
// Check to see if the Logging plugin out instance has been created yet.
|
|
||||||
// If it has, use it to log
|
|
||||||
if (RemoteSystemsLoggingPlugin.out != null)
|
|
||||||
RemoteSystemsLoggingPlugin.out.logInfo(
|
|
||||||
"Created Logger instance for "
|
|
||||||
+ plugin.getBundle().getSymbolicName());
|
|
||||||
}
|
}
|
||||||
|
return logger;
|
||||||
return inst;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees resources used by the Logger instance for the given plugin.<br>
|
* Frees resources used by the Logger instance for the given plugin.<br>
|
||||||
* This methods must be called as part of the the plugin shutdown life cycle.
|
* This methods must be called as part of the the plugin shutdown life cycle.
|
||||||
*/
|
*/
|
||||||
public static void freeInst(Plugin plugin) {
|
public static void freeLogger(Plugin plugin) {
|
||||||
// delegate to controller
|
Logger logger = (Logger) pluginTable.get(plugin);
|
||||||
LoggerController.freeInst(plugin);
|
if (logger != null) {
|
||||||
|
logger.freeResources();
|
||||||
|
pluginTable.remove(plugin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* {Name} (company) - description of contribution.
|
* {Name} (company) - description of contribution.
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.logging;
|
package org.eclipse.rse.logging;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -26,27 +26,22 @@ import org.eclipse.core.runtime.ILogListener;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Plugin;
|
import org.eclipse.core.runtime.Plugin;
|
||||||
import org.eclipse.core.runtime.Preferences;
|
|
||||||
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
|
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
|
||||||
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
|
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
|
||||||
import org.eclipse.rse.logging.IRemoteSystemsLogging;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log Listener is a sink for messages coming from Logger.
|
* Log Listener is a sink for messages coming from Logger.
|
||||||
*/
|
*/
|
||||||
public class RemoteSystemLogListener implements ILogListener, IPropertyChangeListener {
|
class RemoteSystemLogListener implements ILogListener, IPropertyChangeListener {
|
||||||
|
|
||||||
private PrintWriter log = null;
|
private PrintWriter log = null;
|
||||||
private File outputFile = null;
|
private File outputFile = null;
|
||||||
private boolean log_to_stdout = false;
|
|
||||||
private Plugin plugin = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new log listener for a plugin.
|
* Create a new log listener for a plugin.
|
||||||
* @param plugin The plugin for which to create a log listener.
|
* @param plugin The plugin for which to create a log listener.
|
||||||
*/
|
*/
|
||||||
public RemoteSystemLogListener(Plugin plugin) {
|
public RemoteSystemLogListener(Plugin plugin) {
|
||||||
this.plugin = plugin;
|
|
||||||
IPath path = plugin.getStateLocation().addTrailingSeparator().append(".log");
|
IPath path = plugin.getStateLocation().addTrailingSeparator().append(".log");
|
||||||
outputFile = path.toFile();
|
outputFile = path.toFile();
|
||||||
if ((outputFile != null) && (outputFile.exists())) {
|
if ((outputFile != null) && (outputFile.exists())) {
|
||||||
|
@ -61,13 +56,8 @@ public class RemoteSystemLogListener implements ILogListener, IPropertyChangeLis
|
||||||
*/
|
*/
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
try {
|
try {
|
||||||
Preferences store = plugin.getPluginPreferences();
|
freeResources();
|
||||||
String log_location = store.getString(IRemoteSystemsLogging.LOG_LOCATION);
|
log = new PrintWriter(new BufferedWriter(new FileWriter(outputFile.toString(), true)), true);
|
||||||
if ((log_location != null) && (log_location.equalsIgnoreCase(IRemoteSystemsLogging.LOG_TO_STDOUT))) {
|
|
||||||
doLogToView();
|
|
||||||
} else {
|
|
||||||
doLogToFile();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log = null;
|
log = null;
|
||||||
System.err.println("Exception in RemoteSystemLogListener.initialize(): " + e.getMessage());
|
System.err.println("Exception in RemoteSystemLogListener.initialize(): " + e.getMessage());
|
||||||
|
@ -75,35 +65,11 @@ public class RemoteSystemLogListener implements ILogListener, IPropertyChangeLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs to standard output.
|
|
||||||
*/
|
|
||||||
private void doLogToView() {
|
|
||||||
// make sure we free resources first
|
|
||||||
freeResources();
|
|
||||||
// log
|
|
||||||
log = new PrintWriter(System.out, true);
|
|
||||||
// cach last state
|
|
||||||
log_to_stdout = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doLogToFile() throws Exception {
|
|
||||||
// make sure we free resources first
|
|
||||||
freeResources();
|
|
||||||
// log
|
|
||||||
log =
|
|
||||||
new PrintWriter(
|
|
||||||
new BufferedWriter(new FileWriter(outputFile.toString(), true)),
|
|
||||||
true);
|
|
||||||
// cache last state
|
|
||||||
log_to_stdout = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logging(IStatus status) {
|
public void logging(IStatus status) {
|
||||||
if (log == null)
|
if (log == null)
|
||||||
return;
|
return;
|
||||||
else {
|
else {
|
||||||
// Need a to string here, because we need to be able to compate dates.
|
// Need a to string here, because we need to be able to compare dates.
|
||||||
String date = new Date().toString();
|
String date = new Date().toString();
|
||||||
log.println(date);
|
log.println(date);
|
||||||
int severity = status.getSeverity();
|
int severity = status.getSeverity();
|
||||||
|
@ -119,18 +85,15 @@ public class RemoteSystemLogListener implements ILogListener, IPropertyChangeLis
|
||||||
|
|
||||||
log.print(" ");
|
log.print(" ");
|
||||||
log.print(status.getPlugin());
|
log.print(status.getPlugin());
|
||||||
// removed for now because we do not use Error codes.
|
|
||||||
//log.print(" ");
|
|
||||||
//log.print(status.getCode());
|
|
||||||
log.print(" ");
|
log.print(" ");
|
||||||
log.println(status.getMessage());
|
log.println(status.getMessage());
|
||||||
if (status.getException() != null)
|
if (status.getException() != null) status.getException().printStackTrace(log);
|
||||||
status.getException().printStackTrace(log);
|
|
||||||
if (status.isMultiStatus()) {
|
if (status.isMultiStatus()) {
|
||||||
IStatus[] children = status.getChildren();
|
IStatus[] children = status.getChildren();
|
||||||
for (int i = 0; i < children.length; i++)
|
for (int i = 0; i < children.length; i++) {
|
||||||
loggingChild(children[i]);
|
loggingChild(children[i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
log.println("--------------------------------------------");
|
log.println("--------------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,8 +112,7 @@ public class RemoteSystemLogListener implements ILogListener, IPropertyChangeLis
|
||||||
else {
|
else {
|
||||||
log.print("\t\t");
|
log.print("\t\t");
|
||||||
log.println(status.getMessage());
|
log.println(status.getMessage());
|
||||||
if (status.getException() != null)
|
if (status.getException() != null) status.getException().printStackTrace(log);
|
||||||
status.getException().printStackTrace(log);
|
|
||||||
if (status.isMultiStatus()) {
|
if (status.isMultiStatus()) {
|
||||||
IStatus[] children = status.getChildren();
|
IStatus[] children = status.getChildren();
|
||||||
for (int i = 0; i < children.length; i++)
|
for (int i = 0; i < children.length; i++)
|
||||||
|
@ -168,14 +130,7 @@ public class RemoteSystemLogListener implements ILogListener, IPropertyChangeLis
|
||||||
}
|
}
|
||||||
|
|
||||||
public void freeResources() {
|
public void freeResources() {
|
||||||
if (log == null)
|
if (log == null) return;
|
||||||
return;
|
|
||||||
|
|
||||||
// make sure to not close std_out. A closed stream can *not*
|
|
||||||
// br re-opened!
|
|
||||||
if (log_to_stdout)
|
|
||||||
return;
|
|
||||||
|
|
||||||
log.flush();
|
log.flush();
|
||||||
log.close();
|
log.close();
|
||||||
log = null;
|
log = null;
|
|
@ -24,23 +24,15 @@ import org.eclipse.core.runtime.FileLocator;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Plugin;
|
import org.eclipse.core.runtime.Plugin;
|
||||||
import org.eclipse.core.runtime.Preferences;
|
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remote Systems Logging plugin.
|
* Remote Systems Logging plugin.
|
||||||
*/
|
*/
|
||||||
public class RemoteSystemsLoggingPlugin extends Plugin {
|
public class RemoteSystemsLoggingPlugin extends Plugin {
|
||||||
|
|
||||||
|
private static RemoteSystemsLoggingPlugin singleton;
|
||||||
//The shared instance.
|
|
||||||
private static RemoteSystemsLoggingPlugin inst;
|
|
||||||
|
|
||||||
//Resource bundle.
|
|
||||||
private ResourceBundle resourceBundle;
|
private ResourceBundle resourceBundle;
|
||||||
|
|
||||||
// The cached Logger inst.
|
|
||||||
public static Logger out = null;
|
public static Logger out = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,17 +40,14 @@ public class RemoteSystemsLoggingPlugin extends Plugin {
|
||||||
*/
|
*/
|
||||||
public RemoteSystemsLoggingPlugin() {
|
public RemoteSystemsLoggingPlugin() {
|
||||||
super();
|
super();
|
||||||
|
singleton = this;
|
||||||
if (inst == null) {
|
|
||||||
inst = this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the shared plugin instance.
|
* Returns the shared plugin instance.
|
||||||
*/
|
*/
|
||||||
public static RemoteSystemsLoggingPlugin getDefault() {
|
public static RemoteSystemsLoggingPlugin getDefault() {
|
||||||
return inst;
|
return singleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,9 +68,7 @@ public class RemoteSystemsLoggingPlugin extends Plugin {
|
||||||
* Returns the plugin's resource bundle.
|
* Returns the plugin's resource bundle.
|
||||||
*/
|
*/
|
||||||
public ResourceBundle getResourceBundle() {
|
public ResourceBundle getResourceBundle() {
|
||||||
|
|
||||||
if (resourceBundle == null) {
|
if (resourceBundle == null) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IPath path = new Path("$nl$/RemoteSystemsLogging.properties");
|
IPath path = new Path("$nl$/RemoteSystemsLogging.properties");
|
||||||
URL url = FileLocator.find(getBundle(), path, null);
|
URL url = FileLocator.find(getBundle(), path, null);
|
||||||
|
@ -91,35 +78,23 @@ public class RemoteSystemsLoggingPlugin extends Plugin {
|
||||||
out.logInfo("RemoteSystemsLoggingPlugin - unable to log resourcebundle");
|
out.logInfo("RemoteSystemsLoggingPlugin - unable to log resourcebundle");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return resourceBundle;
|
return resourceBundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/* (non-Javadoc)
|
||||||
* Sets default preference values.
|
* @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
|
||||||
*/
|
|
||||||
public void initializeDefaultPreferences() {
|
|
||||||
Preferences prefs = getPluginPreferences();
|
|
||||||
prefs.setDefault(IRemoteSystemsLogging.DEBUG_LEVEL, IRemoteSystemsLogging.LOG_ERROR);
|
|
||||||
prefs.setDefault(IRemoteSystemsLogging.LOG_LOCATION, IRemoteSystemsLogging.LOG_TO_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
|
|
||||||
*/
|
*/
|
||||||
public void start(BundleContext context) throws Exception {
|
public void start(BundleContext context) throws Exception {
|
||||||
super.start(context);
|
super.start(context);
|
||||||
|
out = LoggerFactory.getLogger(this);
|
||||||
// don't need a preference page for this plugin.
|
|
||||||
out = LoggerFactory.getInst(this);
|
|
||||||
out.logInfo("loading RemoteSystemsLoggingPlugin class.");
|
out.logInfo("loading RemoteSystemsLoggingPlugin class.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/* (non-Javadoc)
|
||||||
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
|
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
|
||||||
*/
|
*/
|
||||||
public void stop(BundleContext context) throws Exception {
|
public void stop(BundleContext context) throws Exception {
|
||||||
LoggerFactory.freeInst(this);
|
LoggerFactory.freeLogger(this);
|
||||||
super.stop(context);
|
super.stop(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -46,52 +46,55 @@ import org.w3c.dom.DOMImplementation;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A performance measurement class for benchmarking.
|
* A performance measurement class for benchmarking.
|
||||||
* This performance framework provides stopwatch functions
|
* This performance framework provides stopwatch functions
|
||||||
* for calculating elapsed time for an operation.
|
* for calculating elapsed time for an operation.
|
||||||
*
|
*
|
||||||
* Usuage example
|
* Usuage example
|
||||||
* Method_A {
|
* Method_A {
|
||||||
* String key = PerformanceLogger.register("RSE","WDSC","5120");
|
* String key = PerformanceLogger.register("RSE","WDSC","5120");
|
||||||
* PerformanceLogger.start(key, "OP1"); //CallerID is OP1
|
* PerformanceLogger.start(key, "OP1"); //CallerID is OP1
|
||||||
* Method_B();
|
* Method_B();
|
||||||
* PerformanceLogger.stop(key);
|
* PerformanceLogger.stop(key);
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* Method_B {
|
* Method_B {
|
||||||
* PerformanceLogger.start("RSE"); //"RSE" component, CalleID="class.method"
|
* PerformanceLogger.start("RSE"); //"RSE" component, CalleID="class.method"
|
||||||
* // Do something
|
* // Do something
|
||||||
* PerformanceLogger.stop("RSE");
|
* PerformanceLogger.stop("RSE");
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* Method_C {
|
* Method_C {
|
||||||
* PerformanceLogger.start(); //Use the default component for recording
|
* PerformanceLogger.start(); //Use the default component for recording
|
||||||
* // Do something
|
* // Do something
|
||||||
* PerformanceLogger.stop();
|
* PerformanceLogger.stop();
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PerformanceLogger
|
public class PerformanceLogger {
|
||||||
{
|
|
||||||
|
|
||||||
public final static boolean _ENABLE_PERFORMANCE_LOGGING_IBM_INTERNAL_ = false;
|
public final static boolean _ENABLE_PERFORMANCE_LOGGING_IBM_INTERNAL_ = false;
|
||||||
|
|
||||||
public final static int OPTION_GET_ALL = 1;
|
public final static int OPTION_GET_ALL = 1;
|
||||||
|
|
||||||
public final static int OPTION_GET_FEATURE = 2;
|
public final static int OPTION_GET_FEATURE = 2;
|
||||||
|
|
||||||
public final static int OPTION_GET_VERSION = 3;
|
public final static int OPTION_GET_VERSION = 3;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
final static String ELEMENT_TASK = "Task";
|
final static String ELEMENT_TASK = "Task";
|
||||||
|
|
||||||
final static String ATTRIBUTE_NAME_TASKID = "CallerID";
|
final static String ATTRIBUTE_NAME_TASKID = "CallerID";
|
||||||
|
|
||||||
final static String DEFAULT_COMPONENT = "_PERFORMANCELOGGER_";
|
final static String DEFAULT_COMPONENT = "_PERFORMANCELOGGER_";
|
||||||
|
|
||||||
static boolean ENABLE_PERFORMANCE_LOGGING = false; /*for user logging enabling*/
|
static boolean ENABLE_PERFORMANCE_LOGGING = false; /*for user logging enabling*/
|
||||||
|
|
||||||
//static long currentAssignedID = -1;
|
//static long currentAssignedID = -1;
|
||||||
static long samplingTime = -1; /* Elapsed time for normalization operatin */
|
static long samplingTime = -1; /* Elapsed time for normalization operatin */
|
||||||
|
|
||||||
static boolean _initialized = false;
|
static boolean _initialized = false;
|
||||||
|
|
||||||
static HashMap perfLogRegistry = new HashMap();
|
static HashMap perfLogRegistry = new HashMap();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -101,27 +104,41 @@ public class PerformanceLogger
|
||||||
normalize();
|
normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
static class StartData
|
static class StartData {
|
||||||
{
|
|
||||||
long startTime = -1;
|
long startTime = -1;
|
||||||
|
|
||||||
long stopTime = -1;
|
long stopTime = -1;
|
||||||
|
|
||||||
String userID = null;
|
String userID = null;
|
||||||
|
|
||||||
String startThread = null;
|
String startThread = null;
|
||||||
|
|
||||||
String startMethod = null;
|
String startMethod = null;
|
||||||
|
|
||||||
String stopThread = null;
|
String stopThread = null;
|
||||||
|
|
||||||
String stopMethod = null;
|
String stopMethod = null;
|
||||||
|
|
||||||
Element node = null;
|
Element node = null;
|
||||||
}
|
}
|
||||||
class ComponentData
|
|
||||||
{
|
class ComponentData {
|
||||||
String component = null;
|
String component = null;
|
||||||
|
|
||||||
String timeStamp = null;
|
String timeStamp = null;
|
||||||
|
|
||||||
String feature = null;
|
String feature = null;
|
||||||
|
|
||||||
String version = null;
|
String version = null;
|
||||||
|
|
||||||
String XMLFileID = null;
|
String XMLFileID = null;
|
||||||
|
|
||||||
File XMLFile = null;
|
File XMLFile = null;
|
||||||
|
|
||||||
Document doc = null;
|
Document doc = null;
|
||||||
|
|
||||||
Stack taskStack = new Stack();
|
Stack taskStack = new Stack();
|
||||||
|
|
||||||
ComponentData(String comp_id) {
|
ComponentData(String comp_id) {
|
||||||
component = comp_id;
|
component = comp_id;
|
||||||
}
|
}
|
||||||
|
@ -134,7 +151,7 @@ public class PerformanceLogger
|
||||||
* @return
|
* @return
|
||||||
* The flag ENABLE_PERFORMANCE_LOGGING is enable(true or false)
|
* The flag ENABLE_PERFORMANCE_LOGGING is enable(true or false)
|
||||||
*/
|
*/
|
||||||
public static void enablePerformanceLogging(boolean enable){
|
public static void enablePerformanceLogging(boolean enable) {
|
||||||
if (enable)
|
if (enable)
|
||||||
ENABLE_PERFORMANCE_LOGGING = true;
|
ENABLE_PERFORMANCE_LOGGING = true;
|
||||||
else
|
else
|
||||||
|
@ -146,7 +163,7 @@ public class PerformanceLogger
|
||||||
* @return
|
* @return
|
||||||
* boolean ENABLE_PERFORMANCE_LOGGING
|
* boolean ENABLE_PERFORMANCE_LOGGING
|
||||||
*/
|
*/
|
||||||
public static boolean isPerformanceLoggingEnabled(){
|
public static boolean isPerformanceLoggingEnabled() {
|
||||||
return ENABLE_PERFORMANCE_LOGGING;
|
return ENABLE_PERFORMANCE_LOGGING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +174,7 @@ public class PerformanceLogger
|
||||||
* compont comp_id registered with no product info
|
* compont comp_id registered with no product info
|
||||||
*/
|
*/
|
||||||
public static String register(String comp_id) {
|
public static String register(String comp_id) {
|
||||||
return register(comp_id,"","");
|
return register(comp_id, "", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public static String register(String feature, String version) : method for registering a component using default
|
/* public static String register(String feature, String version) : method for registering a component using default
|
||||||
|
@ -170,7 +187,7 @@ public class PerformanceLogger
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static String register(String feature, String version) {
|
public static String register(String feature, String version) {
|
||||||
return register(DEFAULT_COMPONENT,feature,version);
|
return register(DEFAULT_COMPONENT, feature, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,9 +200,9 @@ public class PerformanceLogger
|
||||||
* - comp_id as the registered key
|
* - comp_id as the registered key
|
||||||
* - An XML file is created by concatenating comp_id, feature and version with time stamp appended
|
* - An XML file is created by concatenating comp_id, feature and version with time stamp appended
|
||||||
*/
|
*/
|
||||||
public static String register(String comp_id, String feature, String version){
|
public static String register(String comp_id, String feature, String version) {
|
||||||
|
|
||||||
if ( (comp_id == null) || (comp_id.length() == 0) ) {
|
if ((comp_id == null) || (comp_id.length() == 0)) {
|
||||||
System.out.println("PerformanceLogger:register(): Cannot register null component id.");
|
System.out.println("PerformanceLogger:register(): Cannot register null component id.");
|
||||||
return comp_id;
|
return comp_id;
|
||||||
}
|
}
|
||||||
|
@ -200,7 +217,7 @@ public class PerformanceLogger
|
||||||
Calendar time = Calendar.getInstance();
|
Calendar time = Calendar.getInstance();
|
||||||
compData.timeStamp = time.getTime().toString();
|
compData.timeStamp = time.getTime().toString();
|
||||||
String userID = System.getProperty("user.name");
|
String userID = System.getProperty("user.name");
|
||||||
compData.XMLFileID = comp_id+"_" + userID + "_" + feature.replace(' ', '_') + "_"+version.replace(' ', '_') + "_perf." + compData.timeStamp.replace(' ', '_').replace(':', '_') + ".xml";
|
compData.XMLFileID = comp_id + "_" + userID + "_" + feature.replace(' ', '_') + "_" + version.replace(' ', '_') + "_perf." + compData.timeStamp.replace(' ', '_').replace(':', '_') + ".xml";
|
||||||
compData.XMLFile = new File(compData.XMLFileID);
|
compData.XMLFile = new File(compData.XMLFileID);
|
||||||
compData.feature = feature;
|
compData.feature = feature;
|
||||||
compData.version = version;
|
compData.version = version;
|
||||||
|
@ -249,14 +266,14 @@ public class PerformanceLogger
|
||||||
Double q = null;
|
Double q = null;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int n = 1000000;
|
int n = 1000000;
|
||||||
for ( i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
Double dd = new Double(n);
|
Double dd = new Double(n);
|
||||||
Double dr = new Double(n+i);
|
Double dr = new Double(n + i);
|
||||||
q = new Double(dd.doubleValue() / dr.doubleValue());
|
q = new Double(dd.doubleValue() / dr.doubleValue());
|
||||||
}
|
}
|
||||||
double val = q.doubleValue() / i;
|
double val = q.doubleValue() / i;
|
||||||
long stopTime = System.currentTimeMillis();
|
long stopTime = System.currentTimeMillis();
|
||||||
samplingTime = stopTime-startTime;
|
samplingTime = stopTime - startTime;
|
||||||
String result = "SystemPerformanceLogger::Normalization Elapsed time = " + samplingTime + " " + val;
|
String result = "SystemPerformanceLogger::Normalization Elapsed time = " + samplingTime + " " + val;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -269,7 +286,7 @@ public class PerformanceLogger
|
||||||
*/
|
*/
|
||||||
public static long start() {
|
public static long start() {
|
||||||
if (_initialized == false) {
|
if (_initialized == false) {
|
||||||
register(DEFAULT_COMPONENT,"","");
|
register(DEFAULT_COMPONENT, "", "");
|
||||||
}
|
}
|
||||||
/*Use the class method name for CallerID*/
|
/*Use the class method name for CallerID*/
|
||||||
/*
|
/*
|
||||||
|
@ -310,7 +327,7 @@ public class PerformanceLogger
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ComponentData cd = (ComponentData)perfLogRegistry.get(comp_id);
|
ComponentData cd = (ComponentData) perfLogRegistry.get(comp_id);
|
||||||
StartData td = new StartData();
|
StartData td = new StartData();
|
||||||
|
|
||||||
td.userID = call_id;
|
td.userID = call_id;
|
||||||
|
@ -330,17 +347,14 @@ public class PerformanceLogger
|
||||||
td.node = task;
|
td.node = task;
|
||||||
|
|
||||||
/* Check if start() is nested by checking if the TaskStack is empty */
|
/* Check if start() is nested by checking if the TaskStack is empty */
|
||||||
if ( cd.taskStack.isEmpty() ) { /*Empty==>not a nested start()*/
|
if (cd.taskStack.isEmpty()) { /*Empty==>not a nested start()*/
|
||||||
root.appendChild(task);
|
root.appendChild(task);
|
||||||
}
|
} else { /*Not empty ==> this start() is nested*/
|
||||||
else { /*Not empty ==> this start() is nested*/
|
|
||||||
|
|
||||||
StartData sd = (StartData)cd.taskStack.peek(); /*Peek the parent CallID on the stack*/
|
StartData sd = (StartData) cd.taskStack.peek(); /*Peek the parent CallID on the stack*/
|
||||||
sd.node.appendChild(task);
|
sd.node.appendChild(task);
|
||||||
}
|
}
|
||||||
}
|
} catch (DOMException e) {
|
||||||
catch (DOMException e)
|
|
||||||
{
|
|
||||||
System.out.println("PerformanceLogger::updateXMLFileatStart DOM Error:" + e.toString());
|
System.out.println("PerformanceLogger::updateXMLFileatStart DOM Error:" + e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,29 +382,27 @@ public class PerformanceLogger
|
||||||
public static long stop(String comp_id) {
|
public static long stop(String comp_id) {
|
||||||
|
|
||||||
long st = System.currentTimeMillis();
|
long st = System.currentTimeMillis();
|
||||||
ComponentData cd = (ComponentData)perfLogRegistry.get(comp_id);
|
ComponentData cd = (ComponentData) perfLogRegistry.get(comp_id);
|
||||||
if (cd == null) {
|
if (cd == null) {
|
||||||
System.out.println("SystemPerformanceLogger::stop(): invalid registration key");
|
System.out.println("SystemPerformanceLogger::stop(): invalid registration key");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
StartData td = null;
|
StartData td = null;
|
||||||
try {
|
try {
|
||||||
td = (StartData)cd.taskStack.pop();
|
td = (StartData) cd.taskStack.pop();
|
||||||
td.stopTime = st;
|
td.stopTime = st;
|
||||||
td.stopThread = Thread.currentThread().toString();
|
td.stopThread = Thread.currentThread().toString();
|
||||||
td.stopMethod = getMethodName(false);
|
td.stopMethod = getMethodName(false);
|
||||||
updateXMLFileAtStop(cd,td);
|
updateXMLFileAtStop(cd, td);
|
||||||
|
|
||||||
//System.out.println("SystemPerformanceLogger::stop(): timer \"" + td.userID + "\" stopped. Elapsed time = " +
|
//System.out.println("SystemPerformanceLogger::stop(): timer \"" + td.userID + "\" stopped. Elapsed time = " +
|
||||||
// (td.stopTime-td.startTime) + " millis.");
|
// (td.stopTime-td.startTime) + " millis.");
|
||||||
}
|
} catch (EmptyStackException e) {
|
||||||
catch (EmptyStackException e) {
|
|
||||||
System.out.println("SystemPerformanceLogger:: Probably too many stop() function calls. - " + e);
|
System.out.println("SystemPerformanceLogger:: Probably too many stop() function calls. - " + e);
|
||||||
}
|
}
|
||||||
return td.stopTime;
|
return td.stopTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* private void generateXMLFile(ComponentData cd): create XML file
|
* private void generateXMLFile(ComponentData cd): create XML file
|
||||||
* @param
|
* @param
|
||||||
|
@ -398,11 +410,11 @@ public class PerformanceLogger
|
||||||
* @return
|
* @return
|
||||||
* - An XML file is created with "Product" and "System" tags.
|
* - An XML file is created with "Product" and "System" tags.
|
||||||
*/
|
*/
|
||||||
private static void generateXMLFile(ComponentData cd){
|
private static void generateXMLFile(ComponentData cd) {
|
||||||
try {
|
try {
|
||||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cd.XMLFile), "UTF8"));
|
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cd.XMLFile), "UTF8"));
|
||||||
// DOMImplementation impl = new DOMImplementationImpl();
|
// DOMImplementation impl = new DOMImplementationImpl();
|
||||||
// cd.doc = impl.createDocument(null, "Benchmark", null);
|
// cd.doc = impl.createDocument(null, "Benchmark", null);
|
||||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
DocumentBuilder builder = null;
|
DocumentBuilder builder = null;
|
||||||
try {
|
try {
|
||||||
|
@ -423,17 +435,17 @@ public class PerformanceLogger
|
||||||
product.setAttribute("Version", cd.version);
|
product.setAttribute("Version", cd.version);
|
||||||
root.appendChild(product);
|
root.appendChild(product);
|
||||||
|
|
||||||
system.setAttribute("OSName",System.getProperty("os.name"));
|
system.setAttribute("OSName", System.getProperty("os.name"));
|
||||||
system.setAttribute("OSVersion",System.getProperty("os.version"));
|
system.setAttribute("OSVersion", System.getProperty("os.version"));
|
||||||
system.setAttribute("JavaVersion",System.getProperty("java.version"));
|
system.setAttribute("JavaVersion", System.getProperty("java.version"));
|
||||||
system.setAttribute("JavaVMVersion",System.getProperty("java.vm.version"));
|
system.setAttribute("JavaVMVersion", System.getProperty("java.vm.version"));
|
||||||
system.setAttribute("JavaClassPath",System.getProperty("java.class.path"));
|
system.setAttribute("JavaClassPath", System.getProperty("java.class.path"));
|
||||||
system.setAttribute("JavaLibraryPath",System.getProperty("java.library.path"));
|
system.setAttribute("JavaLibraryPath", System.getProperty("java.library.path"));
|
||||||
root.appendChild(system);
|
root.appendChild(system);
|
||||||
|
|
||||||
Element norm = cd.doc.createElement("_NORMALIZATION_VALUES");
|
Element norm = cd.doc.createElement("_NORMALIZATION_VALUES");
|
||||||
Long ems = new Long(samplingTime);
|
Long ems = new Long(samplingTime);
|
||||||
norm.setAttribute("ElapsedTime",ems.toString());
|
norm.setAttribute("ElapsedTime", ems.toString());
|
||||||
root.appendChild(norm);
|
root.appendChild(norm);
|
||||||
|
|
||||||
/* Insert comments for Task tag */
|
/* Insert comments for Task tag */
|
||||||
|
@ -455,22 +467,18 @@ public class PerformanceLogger
|
||||||
} catch (TransformerException e2) {
|
} catch (TransformerException e2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// OutputFormat fmt = new OutputFormat(cd.doc);
|
// OutputFormat fmt = new OutputFormat(cd.doc);
|
||||||
// fmt.setLineSeparator(LineSeparator.Windows);
|
// fmt.setLineSeparator(LineSeparator.Windows);
|
||||||
// fmt.setIndenting(true);
|
// fmt.setIndenting(true);
|
||||||
// fmt.setPreserveSpace(false);
|
// fmt.setPreserveSpace(false);
|
||||||
// //writer.flush();
|
// //writer.flush();
|
||||||
// XMLSerializer serializer = new XMLSerializer(writer, fmt);
|
// XMLSerializer serializer = new XMLSerializer(writer, fmt);
|
||||||
// serializer.serialize(cd.doc);
|
// serializer.serialize(cd.doc);
|
||||||
// writer.close();
|
// writer.close();
|
||||||
|
|
||||||
}
|
} catch (java.io.IOException e) {
|
||||||
catch (java.io.IOException e)
|
|
||||||
{
|
|
||||||
System.out.println("PerformanceLogger::updateXML IO Error:" + e.toString());
|
System.out.println("PerformanceLogger::updateXML IO Error:" + e.toString());
|
||||||
}
|
} catch (DOMException e) {
|
||||||
catch (DOMException e)
|
|
||||||
{
|
|
||||||
System.out.println("PerformanceLogger::updateXML DOM Error:" + e.toString());
|
System.out.println("PerformanceLogger::updateXML DOM Error:" + e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -480,7 +488,7 @@ public class PerformanceLogger
|
||||||
* @return
|
* @return
|
||||||
* - A "Task" tag is created in the XML file with the current start and stop timer information.
|
* - A "Task" tag is created in the XML file with the current start and stop timer information.
|
||||||
*/
|
*/
|
||||||
private static void updateXMLFileAtStop(ComponentData cd, StartData td ){
|
private static void updateXMLFileAtStop(ComponentData cd, StartData td) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cd.XMLFile), "UTF8"));
|
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cd.XMLFile), "UTF8"));
|
||||||
|
@ -488,22 +496,22 @@ public class PerformanceLogger
|
||||||
Element task = td.node;
|
Element task = td.node;
|
||||||
|
|
||||||
/* Construct Long class insatnce for string manipulation */
|
/* Construct Long class insatnce for string manipulation */
|
||||||
Long ems = new Long(td.stopTime-td.startTime);
|
Long ems = new Long(td.stopTime - td.startTime);
|
||||||
Long sms = new Long(td.startTime);
|
Long sms = new Long(td.startTime);
|
||||||
Long tms = new Long(td.stopTime);
|
Long tms = new Long(td.stopTime);
|
||||||
/*Calculate the normalization factor*/
|
/*Calculate the normalization factor*/
|
||||||
String normalizedFactor = "invalid";
|
String normalizedFactor = "invalid";
|
||||||
if (samplingTime > 0) {
|
if (samplingTime > 0) {
|
||||||
Long sam = new Long(samplingTime);
|
Long sam = new Long(samplingTime);
|
||||||
Double val = new Double(ems.doubleValue()/sam.doubleValue());
|
Double val = new Double(ems.doubleValue() / sam.doubleValue());
|
||||||
normalizedFactor = val.toString();
|
normalizedFactor = val.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the document */
|
/* Update the document */
|
||||||
task.setAttribute("ElapsedTime",ems.toString());
|
task.setAttribute("ElapsedTime", ems.toString());
|
||||||
task.setAttribute("NormalizedFactor",normalizedFactor);
|
task.setAttribute("NormalizedFactor", normalizedFactor);
|
||||||
task.setAttribute("StartTime",sms.toString());
|
task.setAttribute("StartTime", sms.toString());
|
||||||
task.setAttribute("StopTime",tms.toString());
|
task.setAttribute("StopTime", tms.toString());
|
||||||
task.setAttribute("StartAt", td.startMethod);
|
task.setAttribute("StartAt", td.startMethod);
|
||||||
task.setAttribute("StartThread", td.startThread);
|
task.setAttribute("StartThread", td.startThread);
|
||||||
task.setAttribute("StopAt", td.stopMethod);
|
task.setAttribute("StopAt", td.stopMethod);
|
||||||
|
@ -521,21 +529,17 @@ public class PerformanceLogger
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Now save the DOM*/
|
/*Now save the DOM*/
|
||||||
// OutputFormat fmt = new OutputFormat(cd.doc);
|
// OutputFormat fmt = new OutputFormat(cd.doc);
|
||||||
// fmt.setLineSeparator(LineSeparator.Windows);
|
// fmt.setLineSeparator(LineSeparator.Windows);
|
||||||
// fmt.setIndenting(true);
|
// fmt.setIndenting(true);
|
||||||
// fmt.setPreserveSpace(false);
|
// fmt.setPreserveSpace(false);
|
||||||
// //writer.flush();
|
// //writer.flush();
|
||||||
// XMLSerializer serializer = new XMLSerializer(writer, fmt);
|
// XMLSerializer serializer = new XMLSerializer(writer, fmt);
|
||||||
// serializer.serialize(cd.doc);
|
// serializer.serialize(cd.doc);
|
||||||
// writer.close();
|
// writer.close();
|
||||||
}
|
} catch (java.io.IOException e) {
|
||||||
catch (java.io.IOException e)
|
|
||||||
{
|
|
||||||
System.out.println("PerformanceLogger::updateXMLFileAtStop IO Error:" + e.toString());
|
System.out.println("PerformanceLogger::updateXMLFileAtStop IO Error:" + e.toString());
|
||||||
}
|
} catch (DOMException e) {
|
||||||
catch (DOMException e)
|
|
||||||
{
|
|
||||||
System.out.println("PerformanceLogger::updateXMLFileAtStop DOM Error:" + e.toString());
|
System.out.println("PerformanceLogger::updateXMLFileAtStop DOM Error:" + e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,7 +556,7 @@ public class PerformanceLogger
|
||||||
* no match: null
|
* no match: null
|
||||||
*/
|
*/
|
||||||
public static String getCurrentProductInfo(int req, String comp_id) {
|
public static String getCurrentProductInfo(int req, String comp_id) {
|
||||||
ComponentData cd = (ComponentData)perfLogRegistry.get(comp_id);
|
ComponentData cd = (ComponentData) perfLogRegistry.get(comp_id);
|
||||||
if (cd == null) {
|
if (cd == null) {
|
||||||
System.out.println("PerformanceLogger::getCurrentProductInfo invalid comp_id");
|
System.out.println("PerformanceLogger::getCurrentProductInfo invalid comp_id");
|
||||||
return null;
|
return null;
|
||||||
|
@ -560,8 +564,7 @@ public class PerformanceLogger
|
||||||
|
|
||||||
if (req == OPTION_GET_FEATURE)
|
if (req == OPTION_GET_FEATURE)
|
||||||
return cd.feature;
|
return cd.feature;
|
||||||
else if (req == OPTION_GET_VERSION)
|
else if (req == OPTION_GET_VERSION) return cd.version;
|
||||||
return cd.version;
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,7 +574,7 @@ public class PerformanceLogger
|
||||||
* The XML file fullpath name.
|
* The XML file fullpath name.
|
||||||
*/
|
*/
|
||||||
public static String getXMLFileName(String comp_id) {
|
public static String getXMLFileName(String comp_id) {
|
||||||
ComponentData cd = (ComponentData)perfLogRegistry.get(comp_id);
|
ComponentData cd = (ComponentData) perfLogRegistry.get(comp_id);
|
||||||
return cd.XMLFile.getAbsolutePath();
|
return cd.XMLFile.getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,35 +602,27 @@ public class PerformanceLogger
|
||||||
* Depending if the caller is using default task ID or not, so the caller is the 3rd or the 4th in the stack.
|
* Depending if the caller is using default task ID or not, so the caller is the 3rd or the 4th in the stack.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (int i = 0; tokenizer.hasMoreTokens(); i++)
|
for (int i = 0; tokenizer.hasMoreTokens(); i++) {
|
||||||
{
|
|
||||||
methodPath = tokenizer.nextToken();
|
methodPath = tokenizer.nextToken();
|
||||||
if ( (methodPath.indexOf("java.lang.Throwable") == -1) &&
|
if ((methodPath.indexOf("java.lang.Throwable") == -1) && (methodPath.indexOf("logging.performance.PerformanceLogger") == -1)) break;
|
||||||
(methodPath.indexOf("logging.performance.PerformanceLogger") == -1) )
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
methodPath = methodPath.substring(4);
|
methodPath = methodPath.substring(4);
|
||||||
if (parsed) {
|
if (parsed) {
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
/* The method name obtained looks like this:
|
/* The method name obtained looks like this:
|
||||||
* " com.ibm.etools.iseries.core.resources.ISeriesEditableSrcPhysicalFileMember.doDownload(ISeriesEditableSrcPhysicalFileMember.java:558)"
|
* " com.ibm.etools.iseries.core.resources.ISeriesEditableSrcPhysicalFileMember.doDownload(ISeriesEditableSrcPhysicalFileMember.java:558)"
|
||||||
*/
|
*/
|
||||||
int i = methodPath.indexOf('(');
|
int i = methodPath.indexOf('(');
|
||||||
if ( i != -1)
|
if (i != -1) methodPath = methodPath.substring(0, i); //strip of the substring enclosed in ()
|
||||||
methodPath = methodPath.substring(0,i); //strip of the substring enclosed in ()
|
|
||||||
//Now we have "com.ibm.etools.systems.logging.performance.PerformanceLogger.start"
|
//Now we have "com.ibm.etools.systems.logging.performance.PerformanceLogger.start"
|
||||||
i = methodPath.lastIndexOf('.'); //Get the method name after the last period (.)
|
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 methodName = methodPath.substring(i + 1); //Now we have the method name "start"
|
||||||
String className = methodPath.substring(0,i); //remove method name from the string
|
String className = methodPath.substring(0, i); //remove method name from the string
|
||||||
//We are left with "com.ibm.etools.systems.logging.performance.PerformanceLogger"
|
//We are left with "com.ibm.etools.systems.logging.performance.PerformanceLogger"
|
||||||
i = className.lastIndexOf('.');
|
i = className.lastIndexOf('.');
|
||||||
if ( i != -1)
|
if (i != -1) className = className.substring(i + 1); //Now we have the class name "PerformanceLogger"
|
||||||
className = className.substring(i+1); //Now we have the class name "PerformanceLogger"
|
methodPath = className + "." + methodName;
|
||||||
methodPath = className+"."+methodName;
|
} catch (IndexOutOfBoundsException ex) {
|
||||||
}
|
|
||||||
catch ( IndexOutOfBoundsException ex )
|
|
||||||
{
|
|
||||||
System.out.println("PerformanceLogger:getMethodName exception" + ex.toString());
|
System.out.println("PerformanceLogger:getMethodName exception" + ex.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -665,41 +660,47 @@ public class PerformanceLogger
|
||||||
if (isPerformanceLoggingEnabled()) {
|
if (isPerformanceLoggingEnabled()) {
|
||||||
PerformanceLogger.start(); //Start timer using default component
|
PerformanceLogger.start(); //Start timer using default component
|
||||||
}
|
}
|
||||||
for ( i = 0; i < 1000000; i++);
|
for (i = 0; i < 1000000; i++)
|
||||||
|
;
|
||||||
if (isPerformanceLoggingEnabled()) {
|
if (isPerformanceLoggingEnabled()) {
|
||||||
PerformanceLogger.stop();
|
PerformanceLogger.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
PerformanceLogger.enablePerformanceLogging(true);
|
PerformanceLogger.enablePerformanceLogging(true);
|
||||||
String key = PerformanceLogger.register("","WDSC","5120");
|
String key = PerformanceLogger.register("", "WDSC", "5120");
|
||||||
key = PerformanceLogger.register("RSE","WDSC","5120");
|
key = PerformanceLogger.register("RSE", "WDSC", "5120");
|
||||||
PerformanceLogger.deRegister("XXX"); //not registered key previously
|
PerformanceLogger.deRegister("XXX"); //not registered key previously
|
||||||
System.out.println("Product info : " +
|
System.out.println("Product info : " + PerformanceLogger.getCurrentProductInfo(PerformanceLogger.OPTION_GET_FEATURE, key) + " "
|
||||||
PerformanceLogger.getCurrentProductInfo(PerformanceLogger.OPTION_GET_FEATURE, key) +
|
+ PerformanceLogger.getCurrentProductInfo(PerformanceLogger.OPTION_GET_VERSION, key));
|
||||||
" " +
|
|
||||||
PerformanceLogger.getCurrentProductInfo(PerformanceLogger.OPTION_GET_VERSION, key));
|
|
||||||
PerformanceLogger.start(key, "NOT_NESTED_1");
|
PerformanceLogger.start(key, "NOT_NESTED_1");
|
||||||
for ( i = 0; i < 1000000; i++);
|
for (i = 0; i < 1000000; i++)
|
||||||
|
;
|
||||||
PerformanceLogger.stop(key);
|
PerformanceLogger.stop(key);
|
||||||
|
|
||||||
PerformanceLogger.start(key,"NESTED_ONE");
|
PerformanceLogger.start(key, "NESTED_ONE");
|
||||||
for ( i = 0; i < 500; i++);
|
for (i = 0; i < 500; i++)
|
||||||
PerformanceLogger.start(key,"NESTED_ONE_CHILD");
|
;
|
||||||
for ( i = 0; i < 300; i++);
|
PerformanceLogger.start(key, "NESTED_ONE_CHILD");
|
||||||
|
for (i = 0; i < 300; i++)
|
||||||
|
;
|
||||||
PerformanceLogger.stop(key);
|
PerformanceLogger.stop(key);
|
||||||
PerformanceLogger.stop(key);
|
PerformanceLogger.stop(key);
|
||||||
|
|
||||||
PerformanceLogger.start(key, "NOT_NESTED_2");
|
PerformanceLogger.start(key, "NOT_NESTED_2");
|
||||||
for ( i = 0; i < 2000000; i++);
|
for (i = 0; i < 2000000; i++)
|
||||||
|
;
|
||||||
PerformanceLogger.stop(key);
|
PerformanceLogger.stop(key);
|
||||||
|
|
||||||
PerformanceLogger.start(key, "NESTED_THREE");
|
PerformanceLogger.start(key, "NESTED_THREE");
|
||||||
for ( i = 0; i < 300; i++);
|
for (i = 0; i < 300; i++)
|
||||||
|
;
|
||||||
PerformanceLogger.start(key, "NESTED_TWO_CHILD1");
|
PerformanceLogger.start(key, "NESTED_TWO_CHILD1");
|
||||||
PerformanceLogger.start(key, "NESTED_TWO_CHILD2");
|
PerformanceLogger.start(key, "NESTED_TWO_CHILD2");
|
||||||
for ( i = 0; i < 4000; i++);
|
for (i = 0; i < 4000; i++)
|
||||||
|
;
|
||||||
PerformanceLogger.start(key, "NESTED_TWO_CHILD3");
|
PerformanceLogger.start(key, "NESTED_TWO_CHILD3");
|
||||||
for ( i = 0; i < 6000; i++);
|
for (i = 0; i < 6000; i++)
|
||||||
|
;
|
||||||
PerformanceLogger.stop(key);
|
PerformanceLogger.stop(key);
|
||||||
PerformanceLogger.stop(key);
|
PerformanceLogger.stop(key);
|
||||||
PerformanceLogger.stop(key);
|
PerformanceLogger.stop(key);
|
||||||
|
@ -707,7 +708,8 @@ public class PerformanceLogger
|
||||||
|
|
||||||
PerformanceLogger.start("ABC"); //Expect error: not registered
|
PerformanceLogger.start("ABC"); //Expect error: not registered
|
||||||
PerformanceLogger.start(key); //record timer in the previous registered component
|
PerformanceLogger.start(key); //record timer in the previous registered component
|
||||||
for ( i = 0; i < 3000000; i++);
|
for (i = 0; i < 3000000; i++)
|
||||||
|
;
|
||||||
PerformanceLogger.stop(key);
|
PerformanceLogger.stop(key);
|
||||||
key = PerformanceLogger.register(key); // Expect error: already registered
|
key = PerformanceLogger.register(key); // Expect error: already registered
|
||||||
PerformanceLogger.deRegister(key);
|
PerformanceLogger.deRegister(key);
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* {Name} (company) - description of contribution.
|
* {Name} (company) - description of contribution.
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.logging;
|
package org.eclipse.rse.logging.ui;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
|
@ -0,0 +1,30 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* Copyright (c) 2006 IBM Corporation. All rights reserved.
|
||||||
|
* This program and the accompanying materials are made available under the terms
|
||||||
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* David Dykstal (IBM) - 148434 Better F1 help.
|
||||||
|
********************************************************************************/
|
||||||
|
package org.eclipse.rse.logging.ui;
|
||||||
|
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
|
public class LoggingPreferenceLabels extends NLS {
|
||||||
|
|
||||||
|
private static String BUNDLE_NAME = "org.eclipse.rse.logging.ui.LoggingPreferenceLabels";//$NON-NLS-1$
|
||||||
|
|
||||||
|
public static String LOGGING_PREFERENCE_PAGE_TOPLABEL1;
|
||||||
|
public static String LOGGING_PREFERENCE_PAGE_TOPLABEL2;
|
||||||
|
public static String LOGGING_PREFERENCE_PAGE_ERRORS_ONLY;
|
||||||
|
public static String LOGGING_PREFERENCE_PAGE_WARNINGS_ERRORS;
|
||||||
|
public static String LOGGING_PREFERENCE_PAGE_INFO_DEBUG;
|
||||||
|
public static String LOGGING_PREFERENCE_PAGE_FULL_DEBUG;
|
||||||
|
|
||||||
|
static {
|
||||||
|
// load message values from bundle file
|
||||||
|
NLS.initializeMessages(BUNDLE_NAME, LoggingPreferenceLabels.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -21,12 +21,9 @@
|
||||||
|
|
||||||
# Preference Page
|
# Preference Page
|
||||||
# ----------------
|
# ----------------
|
||||||
LoggingPreferencePage.topLabel1 = Specify the logging options for {0}
|
LOGGING_PREFERENCE_PAGE_TOPLABEL1 = Specify the logging options for {0}
|
||||||
LoggingPreferencePage.topLabel2 = Logging Level:
|
LOGGING_PREFERENCE_PAGE_TOPLABEL2 = Logging Level:
|
||||||
LoggingPreferencePage.errors_only = Errors only
|
LOGGING_PREFERENCE_PAGE_ERRORS_ONLY = Errors only
|
||||||
LoggingPreferencePage.warnings_errors = Warnings and errors
|
LOGGING_PREFERENCE_PAGE_WARNINGS_ERRORS = Warnings and errors
|
||||||
LoggingPreferencePage.info_debug = Warnings, errors and information messages
|
LOGGING_PREFERENCE_PAGE_INFO_DEBUG = Warnings, errors and information messages
|
||||||
LoggingPreferencePage.full_debug = Full debug
|
LOGGING_PREFERENCE_PAGE_FULL_DEBUG = Full debug
|
||||||
LoggingPreferencePage.logging_location = Logging Location:
|
|
||||||
LoggingPreferencePage.log_to_file = Log to file (default)
|
|
||||||
LoggingPreferencePage.log_to_stdout = Log to Standard Out
|
|
|
@ -11,23 +11,20 @@
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
|
* Michael Berger (IBM Canada) - 148434 Better F1 help.
|
||||||
* {Name} (company) - description of contribution.
|
* {Name} (company) - description of contribution.
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.logging;
|
package org.eclipse.rse.logging.ui;
|
||||||
|
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.Plugin;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
|
||||||
import org.eclipse.core.runtime.IExecutableExtension;
|
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.preference.PreferencePage;
|
import org.eclipse.jface.preference.PreferencePage;
|
||||||
import org.eclipse.jface.preference.PreferenceStore;
|
import org.eclipse.jface.preference.PreferenceStore;
|
||||||
import org.eclipse.rse.internal.logging.LabelUtil;
|
import org.eclipse.rse.logging.IRemoteSystemsLogging;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
@ -37,32 +34,21 @@ import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.ui.IWorkbench;
|
import org.eclipse.ui.IWorkbench;
|
||||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||||
import org.eclipse.ui.help.WorkbenchHelp;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||||
import org.osgi.framework.Bundle;
|
import org.osgi.framework.Bundle;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract preference page for all remote system logging.<br/>
|
* An abstract preference page for all remote system logging.<br/>
|
||||||
* Use a subclass of this page if you need a preference page to control
|
* Use a subclass of this page if you need a preference page to control
|
||||||
* logging.
|
* logging.
|
||||||
*/
|
*/
|
||||||
public abstract class LoggingPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IExecutableExtension {
|
public abstract class LoggingPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
|
||||||
|
|
||||||
|
|
||||||
private Button radioButton0;
|
private Button radioButton0;
|
||||||
private Button radioButton1;
|
private Button radioButton1;
|
||||||
private Button radioButton2;
|
private Button radioButton2;
|
||||||
private Button radioButton3;
|
private Button radioButton3;
|
||||||
private Button radioButtonLogFile;
|
|
||||||
private Button radioButtonLogView;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is the plugin instance who's preference store will be used
|
|
||||||
* to control the settings on this page. Also, when this page is closed
|
|
||||||
* the settings are restored in the preference store of the above plugin.
|
|
||||||
*/
|
|
||||||
private Bundle bundle = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates composite control and sets the default layout data.
|
* Creates composite control and sets the default layout data.
|
||||||
|
@ -90,37 +76,28 @@ public abstract class LoggingPreferencePage extends PreferencePage implements IW
|
||||||
* Method declared on PreferencePage
|
* Method declared on PreferencePage
|
||||||
*/
|
*/
|
||||||
protected Control createContents(Composite parent) {
|
protected Control createContents(Composite parent) {
|
||||||
|
Bundle bundle = getBundle();
|
||||||
Composite composite_tab = createComposite(parent, 2);
|
Composite composite_tab = createComposite(parent, 2);
|
||||||
String bundleName = (String)(bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_NAME));
|
String bundleName = (String) (bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_NAME));
|
||||||
String topLabel1 = RemoteSystemsLoggingPlugin.getResourceString("LoggingPreferencePage.topLabel1");
|
String topLabel1 = LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_TOPLABEL1;
|
||||||
topLabel1 = MessageFormat.format(topLabel1, new Object[] {bundleName});
|
topLabel1 = MessageFormat.format(topLabel1, new Object[] { bundleName });
|
||||||
createLabel(composite_tab, topLabel1);
|
createLabel(composite_tab, topLabel1);
|
||||||
forceSpace(composite_tab);
|
forceSpace(composite_tab);
|
||||||
String topLabel2 = RemoteSystemsLoggingPlugin.getResourceString("LoggingPreferencePage.topLabel2");
|
String topLabel2 = LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_TOPLABEL2;
|
||||||
createLabel(composite_tab, topLabel2);
|
createLabel(composite_tab, topLabel2);
|
||||||
tabForward(composite_tab);
|
tabForward(composite_tab);
|
||||||
Composite composite1_radioButton = createComposite(composite_tab, 1);
|
Composite composite1_radioButton = createComposite(composite_tab, 1);
|
||||||
String text = RemoteSystemsLoggingPlugin.getResourceString("LoggingPreferencePage.errors_only");
|
String text = LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_ERRORS_ONLY;
|
||||||
Set used = LabelUtil.usedFromString("ad"); // the mnemonics already used on preference page (in English)
|
Set used = LabelUtil.usedFromString("ad"); // the mnemonics already used on preference page (in English)
|
||||||
radioButton0 = createRadioButton(composite1_radioButton, LabelUtil.assignMnemonic(text, used));
|
radioButton0 = createRadioButton(composite1_radioButton, LabelUtil.assignMnemonic(text, used));
|
||||||
text = RemoteSystemsLoggingPlugin.getResourceString("LoggingPreferencePage.warnings_errors");
|
text = LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_WARNINGS_ERRORS;
|
||||||
radioButton1 = createRadioButton(composite1_radioButton, LabelUtil.assignMnemonic(text, used));
|
radioButton1 = createRadioButton(composite1_radioButton, LabelUtil.assignMnemonic(text, used));
|
||||||
text = RemoteSystemsLoggingPlugin.getResourceString("LoggingPreferencePage.info_debug");
|
text = LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_INFO_DEBUG;
|
||||||
radioButton2 = createRadioButton(composite1_radioButton, LabelUtil.assignMnemonic(text, used));
|
radioButton2 = createRadioButton(composite1_radioButton, LabelUtil.assignMnemonic(text, used));
|
||||||
// now add debug stuff, that only shows up in a debug build.
|
text = LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_FULL_DEBUG;
|
||||||
if (Logger.DEBUG) {
|
radioButton3 = createRadioButton(composite1_radioButton, LabelUtil.assignMnemonic(text, used));
|
||||||
radioButton3 = createRadioButton(composite1_radioButton, RemoteSystemsLoggingPlugin.getResourceString("LoggingPreferencePage.full_debug"));
|
|
||||||
Composite composite_tab2 = createComposite(parent, 2);
|
|
||||||
Label label3 = createLabel(composite_tab2, RemoteSystemsLoggingPlugin.getResourceString("LoggingPreferencePage.logging_location"));
|
|
||||||
tabForward(composite_tab2);
|
|
||||||
Composite composite_radioButton2 = createComposite(composite_tab2, 1);
|
|
||||||
radioButtonLogFile = createRadioButton(composite_radioButton2, RemoteSystemsLoggingPlugin.getResourceString("LoggingPreferencePage.log_to_file"));
|
|
||||||
radioButtonLogView = createRadioButton(composite_radioButton2, RemoteSystemsLoggingPlugin.getResourceString("LoggingPreferencePage.log_to_stdout"));
|
|
||||||
WorkbenchHelp.setHelp(composite_tab2, "com.ibm.etools.systems.logging.pref0000");
|
|
||||||
}
|
|
||||||
initializeValues();
|
initializeValues();
|
||||||
RemoteSystemsLoggingPlugin.out.logInfo("created LoggingPreferencePage");
|
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "com.ibm.etools.systems.logging.rsel0000");
|
||||||
WorkbenchHelp.setHelp(composite_tab, "com.ibm.etools.systems.logging.pref0000");
|
|
||||||
return new Composite(parent, SWT.NULL);
|
return new Composite(parent, SWT.NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,24 +139,27 @@ public abstract class LoggingPreferencePage extends PreferencePage implements IW
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected IPreferenceStore doGetPreferenceStore() {
|
protected IPreferenceStore doGetPreferenceStore() {
|
||||||
|
Bundle bundle = getBundle();
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
AbstractUIPlugin plugin = getPlugin();
|
AbstractUIPlugin plugin = getPlugin();
|
||||||
|
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
return plugin.getPreferenceStore();
|
return plugin.getPreferenceStore();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return new PreferenceStore();
|
return new PreferenceStore();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return new PreferenceStore();
|
return new PreferenceStore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract AbstractUIPlugin getPlugin();
|
protected abstract AbstractUIPlugin getPlugin();
|
||||||
|
|
||||||
|
private Bundle getBundle() {
|
||||||
|
Plugin plugin = getPlugin();
|
||||||
|
Bundle bundle = plugin.getBundle();
|
||||||
|
return bundle;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method declared on IWorkbenchPreferencePage
|
* Method declared on IWorkbenchPreferencePage
|
||||||
*/
|
*/
|
||||||
|
@ -195,37 +175,25 @@ public abstract class LoggingPreferencePage extends PreferencePage implements IW
|
||||||
radioButton0.setSelection(false);
|
radioButton0.setSelection(false);
|
||||||
radioButton1.setSelection(false);
|
radioButton1.setSelection(false);
|
||||||
radioButton2.setSelection(false);
|
radioButton2.setSelection(false);
|
||||||
if (null != radioButton3)
|
if (null != radioButton3) radioButton3.setSelection(false);
|
||||||
radioButton3.setSelection(false);
|
|
||||||
if (Logger.DEBUG) {
|
|
||||||
radioButtonLogFile.setSelection(false);
|
|
||||||
radioButtonLogView.setSelection(false);
|
|
||||||
}
|
|
||||||
int choice = store.getInt(IRemoteSystemsLogging.DEBUG_LEVEL);
|
int choice = store.getInt(IRemoteSystemsLogging.DEBUG_LEVEL);
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case 0 :
|
case 0:
|
||||||
radioButton0.setSelection(true);
|
radioButton0.setSelection(true);
|
||||||
break;
|
break;
|
||||||
case 1 :
|
case 1:
|
||||||
radioButton1.setSelection(true);
|
radioButton1.setSelection(true);
|
||||||
break;
|
break;
|
||||||
case 2 :
|
case 2:
|
||||||
radioButton2.setSelection(true);
|
radioButton2.setSelection(true);
|
||||||
break;
|
break;
|
||||||
case 3 :
|
case 3:
|
||||||
if (null != radioButton3)
|
if (null != radioButton3)
|
||||||
radioButton3.setSelection(true);
|
radioButton3.setSelection(true);
|
||||||
else
|
else
|
||||||
radioButton2.setSelection(true);
|
radioButton2.setSelection(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (Logger.DEBUG) {
|
|
||||||
String log_location = store.getString(IRemoteSystemsLogging.LOG_LOCATION);
|
|
||||||
if (log_location.equalsIgnoreCase(IRemoteSystemsLogging.LOG_TO_STDOUT))
|
|
||||||
radioButtonLogView.setSelection(true);
|
|
||||||
else
|
|
||||||
radioButtonLogFile.setSelection(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -237,37 +205,25 @@ public abstract class LoggingPreferencePage extends PreferencePage implements IW
|
||||||
radioButton0.setSelection(false);
|
radioButton0.setSelection(false);
|
||||||
radioButton1.setSelection(false);
|
radioButton1.setSelection(false);
|
||||||
radioButton2.setSelection(false);
|
radioButton2.setSelection(false);
|
||||||
if (null != radioButton3)
|
if (null != radioButton3) radioButton3.setSelection(false);
|
||||||
radioButton3.setSelection(false);
|
|
||||||
if (Logger.DEBUG) {
|
|
||||||
radioButtonLogFile.setSelection(false);
|
|
||||||
radioButtonLogView.setSelection(false);
|
|
||||||
}
|
|
||||||
int choice = store.getDefaultInt(IRemoteSystemsLogging.DEBUG_LEVEL);
|
int choice = store.getDefaultInt(IRemoteSystemsLogging.DEBUG_LEVEL);
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case 0 :
|
case 0:
|
||||||
radioButton0.setSelection(true);
|
radioButton0.setSelection(true);
|
||||||
break;
|
break;
|
||||||
case 1 :
|
case 1:
|
||||||
radioButton1.setSelection(true);
|
radioButton1.setSelection(true);
|
||||||
break;
|
break;
|
||||||
case 2 :
|
case 2:
|
||||||
radioButton2.setSelection(true);
|
radioButton2.setSelection(true);
|
||||||
break;
|
break;
|
||||||
case 3 :
|
case 3:
|
||||||
if (null != radioButton3)
|
if (null != radioButton3)
|
||||||
radioButton3.setSelection(true);
|
radioButton3.setSelection(true);
|
||||||
else
|
else
|
||||||
radioButton2.setSelection(true);
|
radioButton2.setSelection(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (Logger.DEBUG) {
|
|
||||||
String log_location = store.getDefaultString(IRemoteSystemsLogging.LOG_LOCATION);
|
|
||||||
if (log_location.equalsIgnoreCase(IRemoteSystemsLogging.LOG_TO_STDOUT))
|
|
||||||
radioButtonLogView.setSelection(true);
|
|
||||||
else
|
|
||||||
radioButtonLogFile.setSelection(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -296,17 +252,8 @@ public abstract class LoggingPreferencePage extends PreferencePage implements IW
|
||||||
choice = 1;
|
choice = 1;
|
||||||
else if (radioButton2.getSelection())
|
else if (radioButton2.getSelection())
|
||||||
choice = 2;
|
choice = 2;
|
||||||
else if (null != radioButton3 && radioButton3.getSelection())
|
else if (null != radioButton3 && radioButton3.getSelection()) choice = 3;
|
||||||
choice = 3;
|
|
||||||
store.setValue(IRemoteSystemsLogging.DEBUG_LEVEL, choice);
|
store.setValue(IRemoteSystemsLogging.DEBUG_LEVEL, choice);
|
||||||
if (Logger.DEBUG) {
|
|
||||||
String log_location = "";
|
|
||||||
if (radioButtonLogFile.getSelection())
|
|
||||||
log_location = IRemoteSystemsLogging.LOG_TO_FILE;
|
|
||||||
else
|
|
||||||
log_location = IRemoteSystemsLogging.LOG_TO_STDOUT;
|
|
||||||
store.setValue(IRemoteSystemsLogging.LOG_LOCATION, log_location);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -336,17 +283,4 @@ public abstract class LoggingPreferencePage extends PreferencePage implements IW
|
||||||
data.horizontalSpan = 2;
|
data.horizontalSpan = 2;
|
||||||
label.setLayoutData(data);
|
label.setLayoutData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This is needed to get to the plugin id, and then plugin instance.
|
|
||||||
*/
|
|
||||||
public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
|
|
||||||
try {
|
|
||||||
String pluginName = config.getDeclaringExtension().getContributor().getName();
|
|
||||||
this.bundle = Platform.getBundle(pluginName);
|
|
||||||
} catch (Exception e) {
|
|
||||||
RemoteSystemsLoggingPlugin.out.logError("Failed to create LoggingPreferencePage.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package org.eclipse.rse.ui.propertypages;
|
package org.eclipse.rse.ui.propertypages;
|
||||||
|
|
||||||
import org.eclipse.rse.logging.LoggingPreferencePage;
|
import org.eclipse.rse.logging.ui.LoggingPreferencePage;
|
||||||
import org.eclipse.rse.ui.RSEUIPlugin;
|
import org.eclipse.rse.ui.RSEUIPlugin;
|
||||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||||
|
|
||||||
|
|
|
@ -1810,7 +1810,7 @@ public class SystemFilterPoolManager implements ISystemFilterPoolManager
|
||||||
*/
|
*/
|
||||||
public void logDebugMessage(String prefix, String message)
|
public void logDebugMessage(String prefix, String message)
|
||||||
{
|
{
|
||||||
if ((Logger.DEBUG) && (logger!=null))
|
if ((logger!=null))
|
||||||
{
|
{
|
||||||
logger.logDebugMessage(prefix, message);
|
logger.logDebugMessage(prefix, message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -448,15 +448,13 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
|
||||||
if (passwordInformation == null && oldUserId != null && !forcePrompt) {
|
if (passwordInformation == null && oldUserId != null && !forcePrompt) {
|
||||||
SystemSignonInformation savedPasswordInformation = ppm.find(hostType, hostName, oldUserId);
|
SystemSignonInformation savedPasswordInformation = ppm.find(hostType, hostName, oldUserId);
|
||||||
if (savedPasswordInformation != null) {
|
if (savedPasswordInformation != null) {
|
||||||
if (validator != null) {
|
if (validator == null || validator.isValid(shell, savedPasswordInformation)) {
|
||||||
if (!validator.isValid(shell, savedPasswordInformation)) {
|
setPasswordInformation(savedPasswordInformation);
|
||||||
|
passwordInformation = getPasswordInformation();
|
||||||
|
} else {
|
||||||
passwordValid = false;
|
passwordValid = false;
|
||||||
clearPasswordCache();
|
clearPasswordCache();
|
||||||
passwordInformation = null;
|
passwordInformation = null;
|
||||||
} else {
|
|
||||||
setPasswordInformation(savedPasswordInformation);
|
|
||||||
passwordInformation = getPasswordInformation();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1087,7 +1085,7 @@ public abstract class AbstractConnectorService extends RSEModelObject implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logException(Throwable t) {
|
private void logException(Throwable t) {
|
||||||
Logger log = LoggerFactory.getInst(RSEUIPlugin.getDefault());
|
Logger log = LoggerFactory.getLogger(RSEUIPlugin.getDefault());
|
||||||
log.logError("Unexpected exception", t);
|
log.logError("Unexpected exception", t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -654,12 +654,9 @@ public abstract class SystemBasePlugin extends AbstractUIPlugin
|
||||||
* @param message - Message to be written to the log file
|
* @param message - Message to be written to the log file
|
||||||
*/
|
*/
|
||||||
public static void logDebugMessage(String prefix, String message)
|
public static void logDebugMessage(String prefix, String message)
|
||||||
{
|
|
||||||
if (Logger.DEBUG)
|
|
||||||
{
|
{
|
||||||
log.logDebugMessage(prefix, message);
|
log.logDebugMessage(prefix, message);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -716,7 +713,7 @@ public abstract class SystemBasePlugin extends AbstractUIPlugin
|
||||||
|
|
||||||
// logger
|
// logger
|
||||||
if (log == null) {
|
if (log == null) {
|
||||||
log = LoggerFactory.getInst(this);
|
log = LoggerFactory.getLogger(this);
|
||||||
log.logInfo("Loading " + this.getClass());
|
log.logInfo("Loading " + this.getClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -726,7 +723,7 @@ public abstract class SystemBasePlugin extends AbstractUIPlugin
|
||||||
*/
|
*/
|
||||||
public void stop(BundleContext context) throws Exception {
|
public void stop(BundleContext context) throws Exception {
|
||||||
logDebugMessage(this.getClass().getName(), "SHUTDOWN");
|
logDebugMessage(this.getClass().getName(), "SHUTDOWN");
|
||||||
LoggerFactory.freeInst(this);
|
LoggerFactory.freeLogger(this);
|
||||||
super.stop(context);
|
super.stop(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue