本文整理汇总了Java中org.eclipse.core.runtime.ILog类的典型用法代码示例。如果您正苦于以下问题:Java ILog类的具体用法?Java ILog怎么用?Java ILog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ILog类属于org.eclipse.core.runtime包,在下文中一共展示了ILog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: append
import org.eclipse.core.runtime.ILog; //导入依赖的package包/类
@Override
protected void append(LoggingEvent event) {
if (isDoLog(event.getLevel())) {
String logString = layout.format(event);
ILog myLog = getLog();
if (myLog != null) {
String loggerName = event.getLoggerName();
int severity = mapLevel(event.getLevel());
final Throwable throwable = event.getThrowableInformation() != null ? event.getThrowableInformation()
.getThrowable() : null;
IStatus status = createStatus(severity, loggerName, logString, throwable);
getLog().log(status);
} else {
// nothing to do (message should be logged to stdout by default appender)
}
}
}
示例2: testLogExceptionThrowable
import org.eclipse.core.runtime.ILog; //导入依赖的package包/类
@Test
public void testLogExceptionThrowable() throws Exception {
ILog log = Activator.getDefault().getLog();
String [] msg = new String [] {"",""};
ILogListener listener = new ILogListener() {
@Override
public void logging(IStatus status, String plugin) {
msg [0] = status.getMessage();
if (status.getSeverity()==IStatus.ERROR) {
msg [1] = "error";
}
}
};
log.addLogListener(listener);
try {
ResourceManager.logException(new Exception("test"));
assertEquals("test",msg [0]);
assertEquals("error",msg [1]);
} finally {
log.removeLogListener(listener);
}
}
示例3: testLogExceptionThrowableString
import org.eclipse.core.runtime.ILog; //导入依赖的package包/类
@Test
public void testLogExceptionThrowableString() throws Exception {
ILog log = Activator.getDefault().getLog();
String [] msg = new String [] {"",""};
ILogListener listener = new ILogListener() {
@Override
public void logging(IStatus status, String plugin) {
msg [0] = status.getMessage();
if (status.getSeverity()==IStatus.ERROR) {
msg [1] = "error";
}
}
};
log.addLogListener(listener);
try {
ResourceManager.logException(new Exception("message"));
assertEquals("message",msg [0]);
assertEquals("error",msg [1]);
} finally {
log.removeLogListener(listener);
}
}
示例4: msg
import org.eclipse.core.runtime.ILog; //导入依赖的package包/类
private void msg(int msgType, String message, Throwable error) {
int ct = squelchTimeout != 0L ? 0 : counter.incrementAndGet();
boolean printSquelchWarning = false;
if (squelchTimeout != 0L) {
long now = System.currentTimeMillis();
if (squelchTimeout > now) return;
squelchTimeout = now + SQUELCH_TIMEOUT;
printSquelchWarning = true;
} else if (ct >= MAX_LOG) {
squelchTimeout = System.currentTimeMillis() + SQUELCH_TIMEOUT;
printSquelchWarning = true;
}
ILog log = Platform.getLog(bundle);
log.log(new Status(msgType, DEFAULT_BUNDLE_NAME, message, error));
if (printSquelchWarning) {
log.log(new Status(IStatus.WARNING, DEFAULT_BUNDLE_NAME, "Lombok has logged too many messages; to avoid memory issues, further lombok logs will be squelched for a while. Restart eclipse to start over."));
}
}
示例5: presentUpdateDetails
import org.eclipse.core.runtime.ILog; //导入依赖的package包/类
@Override
public void presentUpdateDetails(Shell shell, String updateSiteUrl, ILog log,
String pluginId) {
try {
InstallUpdateHandler.launch(updateSiteUrl);
} catch (Throwable t) {
// Log, and fallback on dialog
log.log(new Status(IStatus.WARNING, pluginId,
"Could not open install wizard", t));
MessageDialog.openInformation(
shell,
DEFAULT_DIALOG_TITLE,
"An update is available for the GWT Plugin for Eclipse. Go to \"Help > Install New Software\" to install it.");
}
}
示例6: run
import org.eclipse.core.runtime.ILog; //导入依赖的package包/类
/**
* Asynchronously executes a {@link Command} in the Eclipse UI thread.
*
* @see Runnable#run()
* @see Display#asyncExec(Runnable)
* @see #runCommand(String)
**/
public void run()
{
try
{
if (command.isHandled() && command.isEnabled())
{
command.executeWithChecks(executionEvent);
}
}
catch (CommandException exception)
{
ILog log = MultiTouchPlugin.getDefault().getLog();
String info = "Unexpected exception while executing " + command; //$NON-NLS-1$
IStatus status = new Status(IStatus.ERROR, MultiTouchPlugin.PLUGIN_ID, info, exception);
log.log(status);
}
}
示例7: runInRealm
import org.eclipse.core.runtime.ILog; //导入依赖的package包/类
private void runInRealm(String message, Runnable runnable) {
if (Realm.getDefault() == realm) {
try {
runnable.run();
} catch (Exception e) {
Activator plugin = Activator.getDefault();
ILog log = plugin.getLog();
if (log != null) {
log.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "failed to perform " + message, e));
} else {
LogUtil.error(new Exception("failed to perform " + message));
}
}
} else {
realm.asyncExec(runnable);
}
}
示例8: append
import org.eclipse.core.runtime.ILog; //导入依赖的package包/类
@Override
protected void append(LoggingEvent event) {
// don't go any further if event is not severe enough.
if (!isAsSevereAsThreshold(event.getLevel())) {
return;
}
ILog log = getBundleILog();
if (log == null) {
return;
}
// if throwable information is available, extract it.
Throwable t = null;
if (event.getThrowableInformation() != null && layout.ignoresThrowable()) {
t = event.getThrowableInformation().getThrowable();
}
// build an Eclipse Status record, map severity and code from Event.
Status s = new Status(getSeverity(event), ForceIdeCorePlugin.getPluginId(), getCode(event),
layout.format(event), t);
log.log(s);
}
示例9: saveGenModel
import org.eclipse.core.runtime.ILog; //导入依赖的package包/类
public static void saveGenModel(GenModel gm, Shell parentShell)
{
final Map<Object, Object> opt = new HashMap<Object, Object>();
opt.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
opt.put(Resource.OPTION_LINE_DELIMITER, Resource.OPTION_LINE_DELIMITER_UNSPECIFIED);
try
{
gm.eResource().save(opt);
} catch (IOException e)
{
MessageDialog.openInformation(parentShell, "genModel could not be saved",
"The genmodel could not be saved.\nReason is : " + e.getMessage());
Bundle bundle = FrameworkUtil.getBundle(Util.class);
ILog logger = Platform.getLog(bundle);
logger.log(new Status(IStatus.WARNING, bundle.getSymbolicName(),
"Unable to save the genModel in : " + gm.eResource(), e));
}
}
示例10: handleCoreException
import org.eclipse.core.runtime.ILog; //导入依赖的package包/类
/**
* Defines the standard procedure to handle <code>CoreExceptions</code>.
* Exceptions are written to the plug-in log.
*
* @param exception
* the exception to be logged
* @param message
* the message to be logged
*/
protected void handleCoreException( CoreException exception, String message )
{
Bundle bundle = Platform.getBundle( PlatformUI.PLUGIN_ID );
ILog log = Platform.getLog( bundle );
if ( message != null )
log.log( new Status( IStatus.ERROR,
PlatformUI.PLUGIN_ID,
0,
message,
exception ) );
else
log.log( exception.getStatus( ) );
}
示例11: writeMessageToErrorLog
import org.eclipse.core.runtime.ILog; //导入依赖的package包/类
/**
* Outputs the exception to the Error Log.
*
* @param exception the exception.
*/
public static void writeMessageToErrorLog(DcaseSystemException exception) {
if (enableWrite(exception.getMessageType().getMessageLevel())) {
// sets the status.
int status = getStatus(exception.getMessageType().getMessageLevel());
// outputs.
String message = exception.getMessage();
if (message == null) {
message = Messages.MessageWriter_0;
}
ILog log = DcaseDiagramEditorPlugin.getInstance().getLog();
log.log(new Status(status, DcaseDiagramEditorPlugin.ID, 0, message,
exception));
}
}
示例12: logInfo
import org.eclipse.core.runtime.ILog; //导入依赖的package包/类
/**
* @param message
*/
public static void logInfo(String project, String message) {
if (project !=null && !PreferenceManager.isLogInfoEnabled(project))
return;
ILog log = Activator.getDefault().getLog();
log.log(new Status(IStatus.INFO, Activator.PLUGIN_ID, message));
}
示例13: testLogInfo
import org.eclipse.core.runtime.ILog; //导入依赖的package包/类
@Test
public void testLogInfo() throws Exception {
ILog log = Activator.getDefault().getLog();
String [] msg = new String [] {"",""};
ILogListener listener = new ILogListener() {
@Override
public void logging(IStatus status, String plugin) {
msg [0] = status.getMessage();
if (status.getSeverity()==IStatus.INFO) {
msg [1] = "info";
}
}
};
log.addLogListener(listener);
IJavaProject jp = null;
try {
jp = ProjectHelper.getOrCreateSimpleGW4EProject(PROJECT_NAME, false, false);
PreferenceManager.setLogInfoEnabled (jp.getProject().getName(),true);
ResourceManager.logInfo(jp.getProject().getName(), "infomessage");
assertEquals("infomessage",msg [0]);
assertEquals("info",msg [1]);
} finally {
PreferenceManager.setLogInfoEnabled (jp.getProject().getName(),false);
log.removeLogListener(listener);
}
}
示例14: setUp
import org.eclipse.core.runtime.ILog; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
ref = mock(IResourceTaskReference.class);
ilog = mock(ILog.class);
prefs = mock(IMechanicPreferences.class);
log = new MechanicLog(ilog);
super.setUp();
}
示例15: PlatformHolder
import org.eclipse.core.runtime.ILog; //导入依赖的package包/类
PlatformHolder(ILog log) {
this.log = log;
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
for (final IProject project : workspace.getRoot().getProjects()) {
if (Platform.isPlatformProject(project)) {
platformProjectAdded(project);
}
}
addResourceChangeListenerToWorkspace();
}