1 11 package org.eclipse.ui.internal.intro.impl.util; 12 13 import org.eclipse.core.runtime.ILog; 14 import org.eclipse.core.runtime.IStatus; 15 import org.eclipse.core.runtime.MultiStatus; 16 import org.eclipse.core.runtime.Platform; 17 import org.eclipse.core.runtime.Status; 18 import org.eclipse.ui.internal.intro.impl.IIntroConstants; 19 import org.eclipse.ui.internal.intro.impl.IntroPlugin; 20 21 30 public class Log implements IIntroConstants { 31 32 37 public static final boolean DEBUG = false; 38 39 40 public static boolean logWarning = false; 43 public static boolean logInfo = false; 45 public static boolean logPerformance = false; 47 48 private final static ILog pluginLog = IntroPlugin.getDefault().getLog(); 49 50 static { 51 if (IntroPlugin.getDefault().isDebugging()) { 54 logWarning = true; 55 logInfo = getDebugOption("/trace/logInfo"); logPerformance = getDebugOption("/trace/logPerformance"); } 58 59 } 60 61 private static boolean getDebugOption(String option) { 62 return "true".equalsIgnoreCase( Platform.getDebugOption(PLUGIN_ID + option)); 64 } 65 66 70 public static synchronized void error(String message, Throwable ex) { 71 if (message == null) 72 message = ""; Status errorStatus = new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, 74 message, ex); 75 pluginLog.log(errorStatus); 76 } 77 78 83 public static synchronized void info(String message) { 84 if (!logInfo) 85 return; 87 88 if (message == null) 89 message = ""; Status infoStatus = new Status(IStatus.INFO, PLUGIN_ID, IStatus.OK, 91 message, null); 92 pluginLog.log(infoStatus); 93 } 94 95 101 public static synchronized void forcedInfo(String message) { 102 if (message == null) 103 message = ""; Status infoStatus = new Status(IStatus.INFO, PLUGIN_ID, IStatus.OK, 105 message, null); 106 pluginLog.log(infoStatus); 107 } 108 109 110 115 public static synchronized void warning(String message) { 116 if (!logWarning) 117 return; 120 121 if (message == null) 122 message = ""; Status warningStatus = new Status(IStatus.WARNING, PLUGIN_ID, 124 IStatus.OK, message, null); 125 pluginLog.log(warningStatus); 126 } 127 128 131 public static synchronized void debugMessage(String className, 132 String message) { 133 if (DEBUG) { 134 MultiStatus debugStatus = new MultiStatus(PLUGIN_ID, IStatus.OK, 135 className, null); 136 Status infoStatus = new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, 137 message, null); 138 debugStatus.add(infoStatus); 139 pluginLog.log(debugStatus); 140 } 141 } 142 } 143 | Popular Tags |