mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-12 10:45:37 +02:00
[170920] moved packages and data from org.eclipse.rse.logging plugin to org.eclipse.rse.core and org.eclipse.rse.ui.
This commit is contained in:
parent
115435a893
commit
895374834f
12 changed files with 815 additions and 3 deletions
|
@ -7,7 +7,6 @@ Bundle-Activator: org.eclipse.rse.core.RSECorePlugin
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Require-Bundle: org.eclipse.core.runtime,
|
Require-Bundle: org.eclipse.core.runtime,
|
||||||
org.eclipse.core.resources,
|
org.eclipse.core.resources,
|
||||||
org.eclipse.rse.logging,
|
|
||||||
org.eclipse.rse.services
|
org.eclipse.rse.services
|
||||||
Eclipse-LazyStart: true
|
Eclipse-LazyStart: true
|
||||||
Export-Package: org.eclipse.rse.core,
|
Export-Package: org.eclipse.rse.core,
|
||||||
|
@ -18,9 +17,11 @@ Export-Package: org.eclipse.rse.core,
|
||||||
org.eclipse.rse.internal.core;x-internal:=true,
|
org.eclipse.rse.internal.core;x-internal:=true,
|
||||||
org.eclipse.rse.internal.core.filters;x-internal:=true,
|
org.eclipse.rse.internal.core.filters;x-internal:=true,
|
||||||
org.eclipse.rse.internal.core.subsystems;x-internal:=true,
|
org.eclipse.rse.internal.core.subsystems;x-internal:=true,
|
||||||
|
org.eclipse.rse.internal.logging,
|
||||||
org.eclipse.rse.internal.persistence;x-internal:=true,
|
org.eclipse.rse.internal.persistence;x-internal:=true,
|
||||||
org.eclipse.rse.internal.persistence.dom;x-internal:=true,
|
org.eclipse.rse.internal.persistence.dom;x-internal:=true,
|
||||||
org.eclipse.rse.internal.references;x-internal:=true,
|
org.eclipse.rse.internal.references;x-internal:=true,
|
||||||
|
org.eclipse.rse.logging,
|
||||||
org.eclipse.rse.persistence,
|
org.eclipse.rse.persistence,
|
||||||
org.eclipse.rse.persistence.dom
|
org.eclipse.rse.persistence.dom
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
<initializer
|
<initializer
|
||||||
class="org.eclipse.rse.internal.core.RSEPreferenceInitializer">
|
class="org.eclipse.rse.internal.core.RSEPreferenceInitializer">
|
||||||
</initializer>
|
</initializer>
|
||||||
|
<initializer class="org.eclipse.rse.internal.logging.LoggingPreferenceInitializer"/>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -0,0 +1,139 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.ILogListener;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Plugin;
|
||||||
|
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
|
||||||
|
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log Listener is a sink for messages coming from Logger.
|
||||||
|
*/
|
||||||
|
public class LogListener implements ILogListener, IPropertyChangeListener {
|
||||||
|
|
||||||
|
private PrintWriter log = null;
|
||||||
|
private File outputFile = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new log listener for a plugin.
|
||||||
|
* @param plugin The plugin for which to create a log listener.
|
||||||
|
*/
|
||||||
|
public LogListener(Plugin plugin) {
|
||||||
|
IPath path = plugin.getStateLocation().addTrailingSeparator().append(".log"); //$NON-NLS-1$
|
||||||
|
outputFile = path.toFile();
|
||||||
|
if ((outputFile != null) && (outputFile.exists())) {
|
||||||
|
outputFile.delete();
|
||||||
|
}
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the logger. Retrieves the logging location preference and sets up the logger
|
||||||
|
* to log to that location.
|
||||||
|
*/
|
||||||
|
private void initialize() {
|
||||||
|
try {
|
||||||
|
freeResources();
|
||||||
|
log = new PrintWriter(new BufferedWriter(new FileWriter(outputFile.toString(), true)), true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log = null;
|
||||||
|
System.err.println("Exception in RemoteSystemLogListener.initialize(): " + e.getMessage()); //$NON-NLS-1$
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logging(IStatus status) {
|
||||||
|
if (log == null)
|
||||||
|
return;
|
||||||
|
else {
|
||||||
|
// Need a to string here, because we need to be able to compare dates.
|
||||||
|
String date = new Date().toString();
|
||||||
|
log.println(date);
|
||||||
|
int severity = status.getSeverity();
|
||||||
|
if (severity == IStatus.ERROR) {
|
||||||
|
log.print("ERROR"); //$NON-NLS-1$
|
||||||
|
} else if (severity == IStatus.WARNING) {
|
||||||
|
log.print("WARNING"); //$NON-NLS-1$
|
||||||
|
} else if (severity == IStatus.INFO) {
|
||||||
|
log.print("INFO"); //$NON-NLS-1$
|
||||||
|
} else if (severity == IStatus.OK) {
|
||||||
|
log.print("DEBUG"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
log.print(" "); //$NON-NLS-1$
|
||||||
|
log.print(status.getPlugin());
|
||||||
|
log.print(" "); //$NON-NLS-1$
|
||||||
|
log.println(status.getMessage());
|
||||||
|
if (status.getException() != null) status.getException().printStackTrace(log);
|
||||||
|
if (status.isMultiStatus()) {
|
||||||
|
IStatus[] children = status.getChildren();
|
||||||
|
for (int i = 0; i < children.length; i++) {
|
||||||
|
loggingChild(children[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.println("--------------------------------------------"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logging(IStatus status, String plugin) {
|
||||||
|
logging(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param tmp org.eclipse.core.runtime.IStatus
|
||||||
|
*/
|
||||||
|
private void loggingChild(IStatus status) {
|
||||||
|
if (log == null)
|
||||||
|
return;
|
||||||
|
else {
|
||||||
|
log.print("\t\t"); //$NON-NLS-1$
|
||||||
|
log.println(status.getMessage());
|
||||||
|
if (status.getException() != null) status.getException().printStackTrace(log);
|
||||||
|
if (status.isMultiStatus()) {
|
||||||
|
IStatus[] children = status.getChildren();
|
||||||
|
for (int i = 0; i < children.length; i++)
|
||||||
|
logging(children[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle changes from Preferences page.
|
||||||
|
*/
|
||||||
|
public synchronized void propertyChange(PropertyChangeEvent event) {
|
||||||
|
// refresh the log location from plugin Preference store
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void freeResources() {
|
||||||
|
if (log == null) return;
|
||||||
|
log.flush();
|
||||||
|
log.close();
|
||||||
|
log = null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.internal.logging;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.Preferences;
|
||||||
|
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
||||||
|
import org.eclipse.rse.core.RSECorePlugin;
|
||||||
|
import org.eclipse.rse.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class initializes logging preferences.
|
||||||
|
*/
|
||||||
|
public class LoggingPreferenceInitializer extends AbstractPreferenceInitializer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public LoggingPreferenceInitializer() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
|
||||||
|
*/
|
||||||
|
public void initializeDefaultPreferences() {
|
||||||
|
Preferences prefs = RSECorePlugin.getDefault().getPluginPreferences();
|
||||||
|
prefs.setDefault(Logger.LOGGING_LEVEL, Logger.LOG_ERROR);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,250 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.logging;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.ILog;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.MultiStatus;
|
||||||
|
import org.eclipse.core.runtime.Plugin;
|
||||||
|
import org.eclipse.core.runtime.Preferences;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
|
||||||
|
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
|
||||||
|
import org.eclipse.rse.internal.logging.LogListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic Logger class for handling Remote Systems logging and tracing.<br>
|
||||||
|
* <br>
|
||||||
|
* The debug level is determined by a "debug_level" key in the preferences store
|
||||||
|
* of the plugin that owns this Logger instance.<br>
|
||||||
|
* <br>
|
||||||
|
* The debug location is determined by a "log_location" key in the preferences store
|
||||||
|
* of the plugin that owns this Logger instance.<br>
|
||||||
|
* <br>
|
||||||
|
* The valid values for these keys can be found in the javadocs for IRemoteSystemsLogging.<br>.
|
||||||
|
* This means that these keys could have been defined through hardcoding in your
|
||||||
|
* plugin startup code, through preferences.ini in the plugin install directory,
|
||||||
|
* OR from pref_store.ini in the plugin read/write metadata area. <br>
|
||||||
|
* The default behavior is to log to file, and to log only errors.
|
||||||
|
* <br>
|
||||||
|
* A typical usage of this class is as follows: <br>
|
||||||
|
* <br>
|
||||||
|
* public class myPlugin extends AbstractUIPlugin { <br>
|
||||||
|
* <br>
|
||||||
|
* // a cached Logger inst for convenience.<br>
|
||||||
|
* public static Logger out = null;<br>
|
||||||
|
* <br>
|
||||||
|
* public myPlugin(IPluginDescriptor descriptor) { <br>
|
||||||
|
* super(descriptor);<br>
|
||||||
|
* ......<br>
|
||||||
|
* ......<br>
|
||||||
|
* out = LoggerFactory.getInst(this);<br>
|
||||||
|
* out.logInfo("loading myPlugin class.");<br>
|
||||||
|
* //out.logWarning("This is a warning message.");<br>
|
||||||
|
* //out.logError("This is an error.", new Exception());<br>
|
||||||
|
* //out.logDebugMessage(<br>
|
||||||
|
* // "myPlugin",<br>
|
||||||
|
* // "this is a debug message from class myPlugin.");<br>
|
||||||
|
* ......<br>
|
||||||
|
* ......<br>
|
||||||
|
* }<br>
|
||||||
|
* <br>
|
||||||
|
* <br>
|
||||||
|
* public void shutdown() throws CoreException {<br>
|
||||||
|
* super.shutdown();<br>
|
||||||
|
* LoggerFactory.freeInst(this);<br>
|
||||||
|
* }<br>
|
||||||
|
* <br>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Logger implements IPropertyChangeListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constant can be used to surround debugging code. Optimizing
|
||||||
|
* compilers have the possibility of removing the code from
|
||||||
|
* a production copy.
|
||||||
|
*
|
||||||
|
* Should be set false normally. Only set to true when testing.
|
||||||
|
*/
|
||||||
|
public static final boolean DEBUG = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the key that controls the logging level.<br>
|
||||||
|
* (value is "debug_level").
|
||||||
|
*/
|
||||||
|
public static final String LOGGING_LEVEL = "logging_level"; //$NON-NLS-1$
|
||||||
|
/**
|
||||||
|
* Set debug_level to this value to get Error messages.<br>
|
||||||
|
* (value is 0).
|
||||||
|
*/
|
||||||
|
public static final int LOG_ERROR = 0;
|
||||||
|
/**
|
||||||
|
* Set debug_level to this value to get Warning messages.<br>
|
||||||
|
* (value is 1).
|
||||||
|
*/
|
||||||
|
public static final int LOG_WARNING = 1;
|
||||||
|
/**
|
||||||
|
* Set debug_level to this value to get Information messages.<br>
|
||||||
|
* (value is 2).
|
||||||
|
*/
|
||||||
|
public static final int LOG_INFO = 2;
|
||||||
|
/**
|
||||||
|
* Set debug_level to this value to get Debug messages.<br>
|
||||||
|
* (value is 3).
|
||||||
|
*/
|
||||||
|
public static final int LOG_DEBUG = 3;
|
||||||
|
|
||||||
|
private ILog systemsPluginLog = null;
|
||||||
|
|
||||||
|
private LogListener logListener = null;
|
||||||
|
|
||||||
|
private String pluginId = null;
|
||||||
|
|
||||||
|
private Plugin systemPlugin = null;
|
||||||
|
|
||||||
|
private int debug_level = Logger.LOG_ERROR;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Logger. Invoked by the LoggerFactory.
|
||||||
|
* @param systemPlugin The preferences for this plugin will determine the detail
|
||||||
|
* logged by this logger. This allows different levels of detail to be logged in the
|
||||||
|
* workbench.
|
||||||
|
* @see LoggerFactory#getLogger(Plugin)
|
||||||
|
*/
|
||||||
|
Logger(Plugin systemPlugin) {
|
||||||
|
this.systemPlugin = systemPlugin;
|
||||||
|
this.pluginId = systemPlugin.getBundle().getSymbolicName();
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void freeResources() {
|
||||||
|
logListener.freeResources();
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized int getDebugLevel() {
|
||||||
|
return debug_level;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a Debug message. This is intended to be used as follows:<br>
|
||||||
|
* Logger.logDebugMessage("someClassName", "someMessage");<br>
|
||||||
|
* <br>
|
||||||
|
* and the output will be:<br>
|
||||||
|
* <br>
|
||||||
|
* ---------------------------------------------------------------<br>
|
||||||
|
* DEBUG org.eclipse.rse.logging someClassName<br>
|
||||||
|
* someMessage<br>
|
||||||
|
* ---------------------------------------------------------------<br>
|
||||||
|
* <br>
|
||||||
|
* <br>
|
||||||
|
* Note that since this message is only for developer debugging, it does not
|
||||||
|
* need to be localized to proper local.<br>
|
||||||
|
*/
|
||||||
|
public synchronized void logDebugMessage(String className, String message) {
|
||||||
|
if (Logger.DEBUG && debug_level >= Logger.LOG_DEBUG) {
|
||||||
|
MultiStatus debugStatus = new MultiStatus(pluginId, IStatus.OK, className, null);
|
||||||
|
Status infoStatus = new Status(IStatus.OK, pluginId, IStatus.OK, message, null);
|
||||||
|
debugStatus.add(infoStatus);
|
||||||
|
systemsPluginLog.log(debugStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log an Error message with an exception. Note that the message should already
|
||||||
|
* be localized to proper locale.
|
||||||
|
* @param message the message to log.
|
||||||
|
* @param ex the exception that caused the condition, may be null.
|
||||||
|
*/
|
||||||
|
public synchronized void logError(String message, Throwable ex) {
|
||||||
|
if (debug_level >= Logger.LOG_ERROR) {
|
||||||
|
if (message == null) message = ""; //$NON-NLS-1$
|
||||||
|
Status errorStatus = new Status(IStatus.ERROR, pluginId, IStatus.OK, message, ex);
|
||||||
|
systemsPluginLog.log(errorStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log an Information message. Note that the message should already
|
||||||
|
* be localized to proper local.<br>
|
||||||
|
* ie: Resource.getString() should already have been called
|
||||||
|
*/
|
||||||
|
public synchronized void logInfo(String message) {
|
||||||
|
logInfo(message, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log an Information message. Note that the message should already
|
||||||
|
* be localized to proper local.<br>
|
||||||
|
* ie: Resource.getString() should already have been called
|
||||||
|
*/
|
||||||
|
public synchronized void logInfo(String message, Throwable ex) {
|
||||||
|
if (debug_level >= Logger.LOG_INFO) {
|
||||||
|
if (message == null) message = ""; //$NON-NLS-1$
|
||||||
|
Status infoStatus = new Status(IStatus.INFO, pluginId, IStatus.OK, message, ex);
|
||||||
|
systemsPluginLog.log(infoStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a Warning message. Note that the message should already
|
||||||
|
* be localized to proper local.<br>
|
||||||
|
* ie: Resource.getString() should already have been called
|
||||||
|
*/
|
||||||
|
public synchronized void logWarning(String message) {
|
||||||
|
logWarning(message, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a Warning message. Note that the message should already
|
||||||
|
* be localized to proper local.<br>
|
||||||
|
* ie: Resource.getString() should already have been called
|
||||||
|
*/
|
||||||
|
public synchronized void logWarning(String message, Throwable ex) {
|
||||||
|
if (debug_level >= Logger.LOG_WARNING) {
|
||||||
|
if (message == null) message = ""; //$NON-NLS-1$
|
||||||
|
Status warningStatus = new Status(IStatus.WARNING, pluginId, IStatus.OK, message, ex);
|
||||||
|
systemsPluginLog.log(warningStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle changes from a Preferences page.
|
||||||
|
*/
|
||||||
|
public synchronized void propertyChange(PropertyChangeEvent event) {
|
||||||
|
Preferences prefs = systemPlugin.getPluginPreferences();
|
||||||
|
debug_level = prefs.getInt(Logger.LOGGING_LEVEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setDebugLevel(int level) {
|
||||||
|
debug_level = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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() {
|
||||||
|
systemsPluginLog = systemPlugin.getLog();
|
||||||
|
logListener = new LogListener(systemPlugin);
|
||||||
|
systemsPluginLog.addLogListener(logListener);
|
||||||
|
Preferences store = systemPlugin.getPluginPreferences();
|
||||||
|
debug_level = store.getInt(Logger.LOGGING_LEVEL);
|
||||||
|
store.addPropertyChangeListener(this);
|
||||||
|
store.addPropertyChangeListener(logListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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 java.util.Hashtable;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.Plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory class for creating Logger instances.<br>
|
||||||
|
* Keep in mind that this factory class follows the singleton model.<br>
|
||||||
|
* ie: once an instance of a Logger class for a given plugin is created,
|
||||||
|
* it will always be reused.
|
||||||
|
*/
|
||||||
|
public class LoggerFactory {
|
||||||
|
|
||||||
|
private static Hashtable pluginTable = new Hashtable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Logger instance for a given plugin. There is only
|
||||||
|
* one instance of the Logger class per plugin.
|
||||||
|
* @param plugin the plugin for which to find or create the log
|
||||||
|
* @return the logger for that plugin
|
||||||
|
*/
|
||||||
|
public static Logger getLogger(Plugin plugin) {
|
||||||
|
Logger logger = (Logger) pluginTable.get(plugin);
|
||||||
|
if (logger == null) {
|
||||||
|
logger = new Logger(plugin);
|
||||||
|
pluginTable.put(plugin, logger);
|
||||||
|
}
|
||||||
|
return logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Frees resources used by the Logger instance for the given plugin.
|
||||||
|
* This method must be called as part of the the plugin shutdown life cycle.
|
||||||
|
* @param plugin the plugin for which to free logging resources
|
||||||
|
*/
|
||||||
|
public static void freeLogger(Plugin plugin) {
|
||||||
|
Logger logger = (Logger) pluginTable.get(plugin);
|
||||||
|
if (logger != null) {
|
||||||
|
logger.freeResources();
|
||||||
|
pluginTable.remove(plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -967,4 +967,14 @@ From here you can manage the certificates that the RSE client uses when connecti
|
||||||
</description>
|
</description>
|
||||||
</context>
|
</context>
|
||||||
|
|
||||||
|
<!-- RSE logging -->
|
||||||
|
<context id="rsel0000">
|
||||||
|
<description>This page allows you to specify the Remote System Explorer logging preferences.
|
||||||
|
|
||||||
|
You can specify what severity of messages you wish to log - from informational messages, to warnings, to errors. If it is available, 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>
|
|
@ -8,7 +8,6 @@ Bundle-Localization: plugin
|
||||||
Require-Bundle: org.eclipse.ui,
|
Require-Bundle: org.eclipse.ui,
|
||||||
org.eclipse.core.runtime,
|
org.eclipse.core.runtime,
|
||||||
org.eclipse.rse.services,
|
org.eclipse.rse.services,
|
||||||
org.eclipse.rse.logging,
|
|
||||||
org.eclipse.core.resources,
|
org.eclipse.core.resources,
|
||||||
org.eclipse.jface.text,
|
org.eclipse.jface.text,
|
||||||
org.eclipse.ui.views,
|
org.eclipse.ui.views,
|
||||||
|
@ -26,6 +25,11 @@ Export-Package: org.eclipse.rse.core,
|
||||||
org.eclipse.rse.internal.model;x-internal:=true,
|
org.eclipse.rse.internal.model;x-internal:=true,
|
||||||
org.eclipse.rse.internal.ui;x-internal:=true,
|
org.eclipse.rse.internal.ui;x-internal:=true,
|
||||||
org.eclipse.rse.internal.ui.actions;x-internal:=true,
|
org.eclipse.rse.internal.ui.actions;x-internal:=true,
|
||||||
|
org.eclipse.rse.internal.ui.dialogs;x-internal:=true,
|
||||||
|
org.eclipse.rse.internal.ui.filters;x-internal:=true,
|
||||||
|
org.eclipse.rse.internal.ui.filters.dialogs;x-internal:=true,
|
||||||
|
org.eclipse.rse.internal.ui.logging;x-internal:=true,
|
||||||
|
org.eclipse.rse.internal.ui.propertypages;x-internal:=true,
|
||||||
org.eclipse.rse.internal.ui.view;x-internal:=true,
|
org.eclipse.rse.internal.ui.view;x-internal:=true,
|
||||||
org.eclipse.rse.internal.ui.view.monitor;x-internal:=true,
|
org.eclipse.rse.internal.ui.view.monitor;x-internal:=true,
|
||||||
org.eclipse.rse.internal.ui.view.scratchpad;x-internal:=true,
|
org.eclipse.rse.internal.ui.view.scratchpad;x-internal:=true,
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.internal.ui.logging;
|
||||||
|
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
|
public class LoggingPreferenceLabels extends NLS {
|
||||||
|
|
||||||
|
private static String BUNDLE_NAME = "org.eclipse.rse.internal.ui.logging.LoggingPreferenceLabels";//$NON-NLS-1$
|
||||||
|
|
||||||
|
public static String LOGGING_PREFERENCE_PAGE_TOPLABEL;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
################################################################################
|
||||||
|
# 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.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# =====================================
|
||||||
|
# Remote System Logging properties file
|
||||||
|
# =====================================
|
||||||
|
# NLS_MESSAGEFORMAT_VAR
|
||||||
|
# NLS_ENCODING=UTF-8
|
||||||
|
|
||||||
|
# Preference Page
|
||||||
|
# ----------------
|
||||||
|
LOGGING_PREFERENCE_PAGE_TOPLABEL = Logging Level
|
||||||
|
LOGGING_PREFERENCE_PAGE_ERRORS_ONLY = &Errors only
|
||||||
|
LOGGING_PREFERENCE_PAGE_WARNINGS_ERRORS = &Warnings and errors
|
||||||
|
LOGGING_PREFERENCE_PAGE_INFO_DEBUG = Warnings, errors and &information messages
|
||||||
|
LOGGING_PREFERENCE_PAGE_FULL_DEBUG = Full &debug
|
|
@ -0,0 +1,245 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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:
|
||||||
|
* Michael Berger (IBM Canada) - 148434 Better F1 help.
|
||||||
|
* {Name} (company) - description of contribution.
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.rse.internal.ui.logging;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.Plugin;
|
||||||
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
|
import org.eclipse.jface.preference.PreferencePage;
|
||||||
|
import org.eclipse.jface.preference.PreferenceStore;
|
||||||
|
import org.eclipse.rse.logging.Logger;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Button;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Group;
|
||||||
|
import org.eclipse.ui.IWorkbench;
|
||||||
|
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||||
|
import org.osgi.framework.Bundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An abstract preference page for all remote system logging.<br/>
|
||||||
|
* Use a subclass of this page if you need a preference page to control
|
||||||
|
* logging.
|
||||||
|
*/
|
||||||
|
public abstract class LoggingPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
|
||||||
|
|
||||||
|
private Button radioButton0;
|
||||||
|
private Button radioButton1;
|
||||||
|
private Button radioButton2;
|
||||||
|
private Button radioButton3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates composite control and sets the default layout data.
|
||||||
|
*
|
||||||
|
* @param parent the parent of the new composite
|
||||||
|
* @param numColumns the number of columns for the new composite
|
||||||
|
* @return the newly-created coposite
|
||||||
|
*/
|
||||||
|
private Composite createComposite(Composite parent, int span, int numColumns) {
|
||||||
|
Composite composite = new Composite(parent, SWT.NONE);
|
||||||
|
GridLayout layout = new GridLayout();
|
||||||
|
layout.numColumns = numColumns;
|
||||||
|
composite.setLayout(layout);
|
||||||
|
GridData data = new GridData();
|
||||||
|
data.verticalAlignment = GridData.FILL;
|
||||||
|
data.horizontalAlignment = GridData.FILL;
|
||||||
|
data.horizontalSpan = span;
|
||||||
|
composite.setLayoutData(data);
|
||||||
|
return composite;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates group control and sets the default layout data.
|
||||||
|
* @param parent the parent of the new composite
|
||||||
|
* @param numColumns the number of columns for the new composite
|
||||||
|
* @return the newly-created coposite
|
||||||
|
*/
|
||||||
|
private Group createGroup(Composite parent, int span, int numColumns, String text) {
|
||||||
|
Group group = new Group(parent, SWT.NONE);
|
||||||
|
GridLayout layout = new GridLayout();
|
||||||
|
layout.numColumns = numColumns;
|
||||||
|
group.setLayout(layout);
|
||||||
|
GridData data = new GridData();
|
||||||
|
data.verticalAlignment = GridData.FILL;
|
||||||
|
data.horizontalAlignment = GridData.FILL;
|
||||||
|
data.horizontalSpan = span;
|
||||||
|
group.setLayoutData(data);
|
||||||
|
group.setText(text);
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility method that creates a radio button instance
|
||||||
|
* and sets the default layout data.
|
||||||
|
*
|
||||||
|
* @param parent the parent for the new button
|
||||||
|
* @param label the label for the new button
|
||||||
|
* @return the newly-created button
|
||||||
|
*/
|
||||||
|
private Button createRadioButton(Composite parent, String label) {
|
||||||
|
Button button = new Button(parent, SWT.RADIO | SWT.LEFT);
|
||||||
|
button.setText(label);
|
||||||
|
GridData data = new GridData();
|
||||||
|
button.setLayoutData(data);
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method declared on PreferencePage
|
||||||
|
*/
|
||||||
|
protected Control createContents(Composite parent) {
|
||||||
|
Composite composite_tab = createComposite(parent, 1, 1);
|
||||||
|
String topLabel = LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_TOPLABEL;
|
||||||
|
Group group = createGroup(composite_tab, 1, 1, topLabel);
|
||||||
|
radioButton0 = createRadioButton(group, LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_ERRORS_ONLY);
|
||||||
|
radioButton1 = createRadioButton(group, LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_WARNINGS_ERRORS);
|
||||||
|
radioButton2 = createRadioButton(group, LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_INFO_DEBUG);
|
||||||
|
if (Logger.DEBUG) {
|
||||||
|
radioButton3 = createRadioButton(group, LoggingPreferenceLabels.LOGGING_PREFERENCE_PAGE_FULL_DEBUG);
|
||||||
|
}
|
||||||
|
initializeValues();
|
||||||
|
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.eclipse.rse.ui.rsel0000"); //$NON-NLS-1$
|
||||||
|
return composite_tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected IPreferenceStore doGetPreferenceStore() {
|
||||||
|
Bundle bundle = getBundle();
|
||||||
|
if (bundle != null) {
|
||||||
|
AbstractUIPlugin plugin = getPlugin();
|
||||||
|
if (plugin != null) {
|
||||||
|
return plugin.getPreferenceStore();
|
||||||
|
} else {
|
||||||
|
return new PreferenceStore();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return new PreferenceStore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract AbstractUIPlugin getPlugin();
|
||||||
|
|
||||||
|
private Bundle getBundle() {
|
||||||
|
Plugin plugin = getPlugin();
|
||||||
|
Bundle bundle = plugin.getBundle();
|
||||||
|
return bundle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method declared on IWorkbenchPreferencePage
|
||||||
|
*/
|
||||||
|
public void init(IWorkbench workbench) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes states of the controls using current values
|
||||||
|
* in the preference store.
|
||||||
|
*/
|
||||||
|
private void initializeValues() {
|
||||||
|
IPreferenceStore store = getPreferenceStore();
|
||||||
|
radioButton0.setSelection(false);
|
||||||
|
radioButton1.setSelection(false);
|
||||||
|
radioButton2.setSelection(false);
|
||||||
|
if (null != radioButton3) radioButton3.setSelection(false);
|
||||||
|
int choice = store.getInt(Logger.LOGGING_LEVEL);
|
||||||
|
switch (choice) {
|
||||||
|
case 0:
|
||||||
|
radioButton0.setSelection(true);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
radioButton1.setSelection(true);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
radioButton2.setSelection(true);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (null != radioButton3)
|
||||||
|
radioButton3.setSelection(true);
|
||||||
|
else
|
||||||
|
radioButton2.setSelection(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes states of the controls using default values
|
||||||
|
* in the preference store.
|
||||||
|
*/
|
||||||
|
private void initializeDefaults() {
|
||||||
|
IPreferenceStore store = getPreferenceStore();
|
||||||
|
radioButton0.setSelection(false);
|
||||||
|
radioButton1.setSelection(false);
|
||||||
|
radioButton2.setSelection(false);
|
||||||
|
if (null != radioButton3) radioButton3.setSelection(false);
|
||||||
|
int choice = store.getDefaultInt(Logger.LOGGING_LEVEL);
|
||||||
|
switch (choice) {
|
||||||
|
case 0:
|
||||||
|
radioButton0.setSelection(true);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
radioButton1.setSelection(true);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
radioButton2.setSelection(true);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (null != radioButton3)
|
||||||
|
radioButton3.setSelection(true);
|
||||||
|
else
|
||||||
|
radioButton2.setSelection(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method declared on PreferencePage
|
||||||
|
*/
|
||||||
|
protected void performDefaults() {
|
||||||
|
super.performDefaults();
|
||||||
|
initializeDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method declared on PreferencePage
|
||||||
|
*/
|
||||||
|
public boolean performOk() {
|
||||||
|
storeValues();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the values of the controls back to the preference store.
|
||||||
|
*/
|
||||||
|
private void storeValues() {
|
||||||
|
IPreferenceStore store = getPreferenceStore();
|
||||||
|
int choice = 0;
|
||||||
|
if (radioButton1.getSelection())
|
||||||
|
choice = 1;
|
||||||
|
else if (radioButton2.getSelection())
|
||||||
|
choice = 2;
|
||||||
|
else if (null != radioButton3 && radioButton3.getSelection()) choice = 3;
|
||||||
|
store.setValue(Logger.LOGGING_LEVEL, choice);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package org.eclipse.rse.internal.ui.propertypages;
|
package org.eclipse.rse.internal.ui.propertypages;
|
||||||
|
|
||||||
import org.eclipse.rse.internal.logging.ui.LoggingPreferencePage;
|
import org.eclipse.rse.internal.ui.logging.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;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue