diff options
Diffstat (limited to 'plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender')
5 files changed, 0 insertions, 801 deletions
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/AbstractWorkBenchRenderer.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/AbstractWorkBenchRenderer.java deleted file mode 100644 index 428556607..000000000 --- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/AbstractWorkBenchRenderer.java +++ /dev/null @@ -1,472 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * $RCSfile: AbstractWorkBenchRenderer.java,v $ - * $Revision: 1.5 $ $Date: 2005/12/14 21:24:26 $ - */ -package org.eclipse.jem.util.logger.proxyrender; - -import java.lang.reflect.Field; -import java.util.logging.Level; - -import org.eclipse.core.runtime.*; -import org.osgi.framework.Bundle; - -import org.eclipse.jem.util.logger.proxy.*; - - -/** - * Base log renderer that logs to the workbench. - * - * @since 1.1.0 - */ -public abstract class AbstractWorkBenchRenderer implements ILogRenderer2 { - - private boolean fTraceMode = false; // will we actually punch trace messaged or not - - private boolean fSettingTrace = false; - - protected Bundle fMyBundle = null; - - protected Logger fMyLogger = null; - - protected ILog fWorkBenchLogger = null; - - /** - * Constructer taking a logger. - * - * @param logger - * - * @since 1.1.0 - */ - public AbstractWorkBenchRenderer(Logger logger) { - super(); - fMyLogger = logger; - fTraceMode = fMyLogger.getTraceMode(); - - String pluginID = fMyLogger.getPluginID(); - fMyBundle = Platform.getBundle(pluginID); - if (fMyBundle == null) - throw new RuntimeException("Invalid Plugin ID"); //$NON-NLS-1$ - - fWorkBenchLogger = Platform.getLog(fMyBundle); - setTraceMode(fMyLogger.getTraceMode() || isDebugging(fMyBundle)); - fMyLogger.setRenderer(this); - } - - /* - * This used to come from the Plugin instance. But in new OSGi, there is not necessarily a Plugin instance. So use the same logic they use. - */ - private boolean isDebugging(Bundle bundle) { - String symbolicName = bundle.getSymbolicName(); - if (symbolicName != null) { - String key = symbolicName + "/debug"; //$NON-NLS-1$ - String value = Platform.getDebugOption(key); - return value == null ? false : value.equalsIgnoreCase("true"); //$NON-NLS-1$ - } - return false; - } - - /** - * Is the console log for eclipse turned on to sysout. If true, then we shouldn't log to console anything already logged because Eclipse would of - * logged it for us. This comes from the -Declipse.consoleLog="true" which is the default when starting eclipse from PDE. - */ - protected static final boolean consoleLogOn; - static { - String consologPropertyName = null; - try { - // Accessing an internal field, so using reflection. This way if changes in future we won't crash. - Class eclipseStarter = Class.forName("org.eclipse.core.runtime.adaptor.EclipseStarter"); //$NON-NLS-1$ - Field consolelog = eclipseStarter.getDeclaredField("PROP_CONSOLE_LOG"); //$NON-NLS-1$ - consologPropertyName = (String) consolelog.get(null); - } catch (SecurityException e) { - } catch (IllegalArgumentException e) { - } catch (ClassNotFoundException e) { - } catch (NoSuchFieldException e) { - } catch (IllegalAccessException e) { - } - consoleLogOn = consologPropertyName != null && "true".equals(System.getProperty(consologPropertyName)) ; //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.logger.proxy.ILogRenderer#setTraceMode(boolean) - */ - public void setTraceMode(boolean flag) { - if (fSettingTrace) - return; // Do not allow cycles - - fSettingTrace = true; - fTraceMode = flag; - fMyLogger.setTraceMode(flag); - fSettingTrace = false; - } - - // The following methods are for historical renderers in case this has been subclassed outside - // of util. - - /** - * Log a string to the trace. - * - * @param param - * @return - * - * @since 1.0.0 - */ - public abstract String log(String param); - - /** - * Default one that log a string to the trace given a level. Default simply passes it to log(String) so that we don't break old subclasses. - * <p> - * If loggedToWorkbench is true, then it shouldn't be logged to console if consoleLogOn is true because workbench already logged to console. - * - * @param msg - * @param l - * - * @since 1.0.0 - */ - protected void log(String msg, Level l, boolean loggedToWorkbench) { - log(msg); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.logger.proxy.ILogRenderer#log(java.lang.String, int) - */ - public String log(String msg, int type) { - - String target = logWorkBench(msg, type); - if (fTraceMode || target.equals(NOLOG_DESCRIPTION)) - return log(msg); - else - return target; - } - - /** - * Log to workbench, a string of the given level <code>ILogRenderer.LOG_</code>. levels. - * - * @param msg - * @param type - * @return description of the log's destination e.g., <code>CONSOLE_DESCRIPTION</code> - * - * @see ILogRenderer#LOG_ERROR and all of the other log types. - * @see ILogRenderer#CONSOLE_DESCRIPTION - * @since 1.0.0 - */ - public String logWorkBench(String msg, int type) { - - try { - int ErrCode; - if (fWorkBenchLogger != null) { - switch (type) { - case (ILogRenderer.LOG_ERROR): - ErrCode = IStatus.ERROR; - break; - case (ILogRenderer.LOG_WARNING): - ErrCode = IStatus.WARNING; - break; - case (ILogRenderer.LOG_INFO): - ErrCode = IStatus.INFO; - break; - case (ILogRenderer.LOG_TRACE): - ErrCode = IStatus.OK; - break; - default: - throw new RuntimeException("Invalid Log Type"); //$NON-NLS-1$ - } - Status status = new Status(ErrCode, fMyBundle.getSymbolicName(), IStatus.OK, msg, null); - fWorkBenchLogger.log(status); - return WORKBENCH_DESCRIPTION; - } else - return NOLOG_DESCRIPTION; - } catch (Throwable t) { - return NOLOG_DESCRIPTION; - } - } - - // Default implentation of the ILogRenderer2 interface. - protected boolean isLogging(Level level) { - return fTraceMode || fMyLogger.isLoggingLevel(level); - } - - private static final int[] STATUS_LEVEL; - - private static final Level[] STATUS_LEVEL_LOOKUP; - - private static final Level[] LEVEL_STATUS; - - static { - // Status levels that correspond to the log levels, from finest to none, same indexes as from STATUS_LEVEL_LOOKUP. - STATUS_LEVEL_LOOKUP = new Level[] { Level.INFO, Level.WARNING, Level.SEVERE}; - STATUS_LEVEL = new int[] { IStatus.INFO, IStatus.WARNING, IStatus.ERROR}; - - // Levels that correspond to the IStatus levels. - int maxID = Math.max(IStatus.OK, Math.max(IStatus.INFO, Math.max(IStatus.WARNING, IStatus.ERROR))); - LEVEL_STATUS = new Level[maxID + 1]; - LEVEL_STATUS[IStatus.OK] = Level.FINE; - LEVEL_STATUS[IStatus.INFO] = Level.INFO; - LEVEL_STATUS[IStatus.WARNING] = Level.WARNING; - LEVEL_STATUS[IStatus.ERROR] = Level.SEVERE; - } - - /** - * Return the Java Level for the status code from the given IStatus. - * - * @param status - * @return the Java Level - * - * @since 1.0.0 - */ - protected Level getLogLevel(IStatus status) { - return LEVEL_STATUS[status.getSeverity()]; - } - - /** - * Return the IStatus status code for the given Java Level. - * - * @param logLevel - * @return the IStatus status code. - * - * @since 1.0.0 - */ - protected int getStatusSeverity(Level logLevel) { - for (int i = 0; i < STATUS_LEVEL_LOOKUP.length; i++) { - if (STATUS_LEVEL_LOOKUP[i] == logLevel) - return STATUS_LEVEL[i]; - } - return IStatus.OK; // Default to ok. - } - - /** - * Log the string to the workbench for the given level - * - * @param msg - * @param level - * @return description of the log's destination e.g., <code>CONSOLE_DESCRIPTION</code> - * - * @since 1.1.0 - */ - protected String logWorkbench(String msg, Level level) { - String result = NOLOG_DESCRIPTION; - // Test again because we could be here simply due to trace mode, in which case we - // don't want to workbench log it. - if (fMyLogger.isLoggingLevel(level)) { - Platform.getLog(fMyBundle).log(new Status(getStatusSeverity(level), fMyBundle.getSymbolicName(), 0, msg, null)); - result = WORKBENCH_DESCRIPTION; - if (fTraceMode) - log(msg, level, true); - } else if (fTraceMode) - log(msg, level, false); - return result; - } - - private String getStatusMsg(IStatus s, Level l) { - if (s.getException() != null) - return fMyLogger.getGenericMsg(s.toString() + fMyLogger.fLineSeperator + fMyLogger.exceptionToString(s.getException()), l); - else - return fMyLogger.getGenericMsg(s.toString(), l); - } - - /** - * Log the IStatus to the workbench at the given level. - * - * @param s - * @param level - * @return description of the log's destination e.g., <code>CONSOLE_DESCRIPTION</code> - * - * @since 1.0.0 - */ - protected String logWorkbench(IStatus s, Level level) { - if (level == DEFAULT) - level = getLogLevel(s); - String result = NOLOG_DESCRIPTION; - // Test again because we could be here simply due to trace mode, in which case we - // don't want to workbench log it. - if (fMyLogger.isLoggingLevel(level)) { - Platform.getLog(fMyBundle).log(s); - result = WORKBENCH_DESCRIPTION; - if (fTraceMode) - log(getStatusMsg(s, level), level, true); - } else if (fTraceMode) - log(getStatusMsg(s, level), level, false); - return result; - } - - /** - * Log to the workbench the Throwable at the given level. - * - * @param t - * @param level - * @return description of the log's destination e.g., <code>CONSOLE_DESCRIPTION</code> - * - * @since 1.0.0 - */ - protected String logWorkbench(Throwable t, Level level) { - String result = NOLOG_DESCRIPTION; - // Test again because we could be here simply due to trace mode, in which case we - // don't want to workbench log it. - if (fMyLogger.isLoggingLevel(level)) { - Platform.getLog(fMyBundle).log(new Status(getStatusSeverity(level), fMyBundle.getSymbolicName(), 0, "Exception thrown.", t)); //$NON-NLS-1$ - result = WORKBENCH_DESCRIPTION; - if (fTraceMode) - log(fMyLogger.getGenericMsg(fMyLogger.exceptionToString(t), level), level, true); - } else if (fTraceMode) - log(fMyLogger.getGenericMsg(fMyLogger.exceptionToString(t), level), level, false); - return result; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(byte, java.util.logging.Level) - */ - public String log(boolean b, Level level) { - if (level == DEFAULT) - level = Level.FINEST; - if (isLogging(level)) - return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(b), level), level); - else - return NOLOG_DESCRIPTION; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(byte, java.util.logging.Level) - */ - public String log(byte b, Level level) { - if (level == DEFAULT) - level = Level.FINEST; - if (isLogging(level)) - return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(b), level), level); - else - return NOLOG_DESCRIPTION; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(char, java.util.logging.Level) - */ - public String log(char c, Level level) { - if (level == DEFAULT) - level = Level.FINEST; - if (isLogging(level)) - return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(c), level), level); - else - return NOLOG_DESCRIPTION; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(double, java.util.logging.Level) - */ - public String log(double d, Level level) { - if (level == DEFAULT) - level = Level.FINEST; - if (isLogging(level)) - return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(d), level), level); - else - return NOLOG_DESCRIPTION; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(float, java.util.logging.Level) - */ - public String log(float f, Level level) { - if (level == DEFAULT) - level = Level.FINEST; - if (isLogging(level)) - return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(f), level), level); - else - return NOLOG_DESCRIPTION; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(int, java.util.logging.Level) - */ - public String log(int i, Level level) { - if (level == DEFAULT) - level = Level.FINEST; - if (isLogging(level)) - return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(i), level), level); - else - return NOLOG_DESCRIPTION; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(long, java.util.logging.Level) - */ - public String log(long l, Level level) { - if (level == DEFAULT) - level = Level.FINEST; - if (isLogging(level)) - return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(l), level), level); - else - return NOLOG_DESCRIPTION; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(java.lang.Object, java.util.logging.Level) - */ - public String log(Object o, Level level) { - if (o instanceof IStatus) - return logWorkbench((IStatus) o, level); - if (level == DEFAULT) - level = Level.FINEST; - if (isLogging(level)) - return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(o), level), level); - else - return NOLOG_DESCRIPTION; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(short, java.util.logging.Level) - */ - public String log(short s, Level level) { - if (level == DEFAULT) - level = Level.FINEST; - if (isLogging(level)) - return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(s), level), level); - else - return NOLOG_DESCRIPTION; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(java.lang.Throwable, java.util.logging.Level) - */ - public String log(Throwable t, Level level) { - if (t instanceof CoreException) - return logWorkbench(((CoreException) t).getStatus(), level); - if (level == DEFAULT) - level = Level.SEVERE; - if (isLogging(level)) { - return logWorkbench(t, level); - } else - return NOLOG_DESCRIPTION; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/ConsoleLogRenderer.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/ConsoleLogRenderer.java deleted file mode 100644 index 90b2963e7..000000000 --- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/ConsoleLogRenderer.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * $RCSfile: ConsoleLogRenderer.java,v $ - * $Revision: 1.2 $ $Date: 2005/02/15 23:04:14 $ - */ -package org.eclipse.jem.util.logger.proxyrender; - -import java.util.logging.Level; - -import org.eclipse.jem.util.logger.proxy.ILogRenderer; -import org.eclipse.jem.util.logger.proxy.Logger; - - -/** - * Log renderer to the console. - * - * @since 1.0.0 - */ -public class ConsoleLogRenderer extends AbstractWorkBenchRenderer { - - /** - * Constructor taking a logger. - * - * @param logger - * - * @since 1.0.0 - */ - public ConsoleLogRenderer(Logger logger) { - super(logger); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.logger.proxyrender.AbstractWorkBenchRenderer#log(java.lang.String) - */ - public String log(String msg) { - - System.out.println(msg); - return ILogRenderer.CONSOLE_DESCRIPTION; - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.logger.proxyrender.AbstractWorkBenchRenderer#log(java.lang.String, java.util.logging.Level, boolean) - */ - protected void log(String msg, Level l, boolean loggedToWorkbench) { - if (!loggedToWorkbench || !consoleLogOn) { - if (l == Level.SEVERE) - System.err.println(msg); - else - System.out.println(msg); - } - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/DefaultPluginTraceRenderer.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/DefaultPluginTraceRenderer.java deleted file mode 100644 index bedf203c7..000000000 --- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/DefaultPluginTraceRenderer.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * $RCSfile: DefaultPluginTraceRenderer.java,v $ - * $Revision: 1.2 $ $Date: 2005/02/15 23:04:14 $ - */ -package org.eclipse.jem.util.logger.proxyrender; - -import java.io.*; -import java.util.logging.Level; - -import org.eclipse.core.runtime.Platform; - -import org.eclipse.jem.util.logger.proxy.Logger; - - -/** - * Logger that also logs to a trace file in the plugin's metadata area. - * - * @since 1.0.0 - */ -public class DefaultPluginTraceRenderer extends AbstractWorkBenchRenderer { - - /** - * Name of the trace file in the metadata area. - * - * @since 1.0.0 - */ - public static final String PluginTraceFileName = "/.log"; //$NON-NLS-1$ - - private String fTraceFile = null; - - private PrintWriter traceFile = null; - - /** - * DefaultUILogRenderer constructor. - * - * @param logger - */ - public DefaultPluginTraceRenderer(Logger logger) { - super(logger); - - fTraceFile = Platform.getStateLocation(fMyBundle).toString() + PluginTraceFileName; - (new File(fTraceFile)).delete(); // Start from fresh ... do not want to leak on disk space - - } - - private void closeTraceFile() { - if (traceFile == null) - return; - try { - traceFile.flush(); - traceFile.close(); - } finally { - traceFile = null; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.logger.proxyrender.AbstractWorkBenchRenderer#log(java.lang.String) - */ - public String log(String msg) { - - System.out.println(msg); - - openTraceFile(); - if (traceFile != null) { - traceFile.println(msg); - closeTraceFile(); - } - return fTraceFile; - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jem.util.logger.proxyrender.AbstractWorkBenchRenderer#log(java.lang.String, java.util.logging.Level, boolean) - */ - protected void log(String msg, Level l, boolean loggedToWorkbench) { - if (!loggedToWorkbench || !consoleLogOn) { - if (l == Level.SEVERE) - System.err.println(msg); - else - System.out.println(msg); - } - - openTraceFile(); - if (traceFile != null) { - traceFile.println(msg); - closeTraceFile(); - } - } - - private void openTraceFile() { - try { - traceFile = new PrintWriter(new FileOutputStream(fTraceFile, true)); - } catch (IOException e) { - // there was a problem opening the log file so log to the console - traceFile = null; - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/EclipseLogger.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/EclipseLogger.java deleted file mode 100644 index 9e40f90f6..000000000 --- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/EclipseLogger.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * $RCSfile: EclipseLogger.java,v $ - * $Revision: 1.4 $ $Date: 2005/08/24 21:10:34 $ - */ -package org.eclipse.jem.util.logger.proxyrender; - -import java.util.logging.Level; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.Bundle; - -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jem.util.plugin.JEMUtilPlugin; - - -/** - * Get an Eclipse logger. This gets a logger that knows it is for a plugin. - * - * For each plugin, the following can be specified in the .option file: - * {plugin-id}/debug/logTrace - * The values valid for this are "true", "false", or "default". If true then loggers will be set into - * trace mode. This means everything logged (even those that are filtered out due to not meeting log level) - * will be traced out. If the value is "true" they will be traced to the system console. - * If it is "default" or not set at all, then it will be the value in the "org.eclipse.jem.util/debug/logTrace" .options setting. - * If not set there, then default value will be false. - * - * {plugin-id}/debug/logTraceFile - * The values valid for this are "true", "false", or "default". If true then loggers will trace to - * the system console AND to the ".log" file in the plugins work area in the metadata section of the workspace. - * If "false" then not traced to a trace file. - * If it is "default" or not set at all, then it will be the value in the "org.eclipse.jem.util/debug/logTraceFile" .options setting. - * If not set there, then default value will be false. - * - * {plugin-id}.debug/logLevel - * The values valid for this are the names from <code>java.util.logging.Level</code>, and "default". These - * are the trace cutoff levels to use. For instance, if the level was SEVERE, then only level SEVERE msgs - * are logged. The rest are skipped. Or if the level was WARNING, then only level SEVERE and WARNING are - * logged. - * If it is "default" or not set at all, then it will be the value in the "org.eclipse.jem.util/debug/logLevel" .options setting. - * If not set there, then default value will be WARNING. - * - * - * @since 1.0.0 - */ -public class EclipseLogger extends Logger { - - public static final String DEBUG_TRACE_OPTION = "/debug/logtrace"; //$NON-NLS-1$ - public static final String DEBUG_TRACE_FILE_OPTION = "/debug/logtracefile"; //$NON-NLS-1$ - public static final String DEBUG_LOG_LEVEL_OPTION = "/debug/loglevel"; // The logging level to use when no Hyaedes. (which we don't support at this time). //$NON-NLS-1$ - public static final String DEFAULT_OPTION = "default"; // If option value is this, then the value from WTP Common plugin options will be used for both logTrace and logLevel. //$NON-NLS-1$ - - /** - * Return a logger based upon the Plugin. - * @param plugin - * @return - * - * @since 1.0.0 - */ - public static Logger getEclipseLogger(Plugin plugin) { - return getEclipseLogger(plugin.getBundle()); - } - - /** - * Return a logger based upon the bundle. - * - * @param bundle - * @return - * - * @since 1.0.0 - */ - public static Logger getEclipseLogger(Bundle bundle) { - String id = bundle.getSymbolicName(); - Logger logger = getLoggerIfExists(id); - if (logger != null) - return logger; - - logger = getLogger(id); // Create one, we will now customize it. - - String pluginOption = Platform.getDebugOption(id + DEBUG_TRACE_OPTION); - if (pluginOption == null || "default".equalsIgnoreCase(pluginOption)) //$NON-NLS-1$ - pluginOption = Platform.getDebugOption(JEMUtilPlugin.getDefault().getBundle().getSymbolicName() + DEBUG_TRACE_OPTION); - boolean logTrace = "true".equalsIgnoreCase(pluginOption); //$NON-NLS-1$ - - pluginOption = Platform.getDebugOption(id + DEBUG_TRACE_FILE_OPTION); - if (pluginOption == null || "default".equalsIgnoreCase(pluginOption)) //$NON-NLS-1$ - pluginOption = Platform.getDebugOption(JEMUtilPlugin.getDefault().getBundle().getSymbolicName() + DEBUG_TRACE_FILE_OPTION); - boolean logTraceFile = "true".equalsIgnoreCase(pluginOption); //$NON-NLS-1$ - - pluginOption = Platform.getDebugOption(id + DEBUG_LOG_LEVEL_OPTION); - if (pluginOption == null || "default".equalsIgnoreCase(pluginOption)) //$NON-NLS-1$ - pluginOption = Platform.getDebugOption(JEMUtilPlugin.getDefault().getBundle().getSymbolicName() + DEBUG_LOG_LEVEL_OPTION); - - Level logLevel = Level.WARNING; - if (pluginOption != null) { - try { - logLevel = Level.parse(pluginOption); - } catch (IllegalArgumentException e) { - } - } - - if (logTrace) - logger.setTraceMode(true); - logger.setLevel(logLevel); - if (!logTraceFile) - logger.setRenderer(new ConsoleLogRenderer(logger)); - else - logger.setRenderer(new DefaultPluginTraceRenderer(logger)); - - return logger; - } - -} diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/IMsgLogger.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/IMsgLogger.java deleted file mode 100644 index 972ecdd17..000000000 --- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/IMsgLogger.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * $RCSfile: IMsgLogger.java,v $ - * $Revision: 1.2 $ $Date: 2005/02/15 23:04:14 $ - */ -package org.eclipse.jem.util.logger.proxyrender; - -import org.eclipse.jem.util.logger.proxy.Logger; - -/** - * Interface for a message logger. - * - * @since 1.0.0 - */ -public interface IMsgLogger { - public Logger getMsgLogger(); -} |