當前位置: 首頁>>代碼示例>>Java>>正文


Java ILog類代碼示例

本文整理匯總了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)
		}
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:19,代碼來源:EclipseLogAppender.java

示例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);
	}
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:23,代碼來源:ResourceManagerTest.java

示例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);
	}
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:23,代碼來源:ResourceManagerTest.java

示例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."));
	}
}
 
開發者ID:git03394538,項目名稱:lombok-ianchiu,代碼行數:19,代碼來源:ProblemReporter.java

示例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.");
  }
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:17,代碼來源:UpdateDetailsPresenter.java

示例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);
    }
}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:25,代碼來源:CommandRunner.java

示例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);
	}
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:18,代碼來源:TreeTimelineContentProvider.java

示例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);
}
 
開發者ID:forcedotcom,項目名稱:idecore,代碼行數:26,代碼來源:LogAppender.java

示例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));
	}
}
 
開發者ID:opcoach,項目名稱:genModelAddon,代碼行數:19,代碼來源:Util.java

示例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( ) );
}
 
開發者ID:eclipse,項目名稱:birt,代碼行數:25,代碼來源:DocumentProvider.java

示例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));
    }
}
 
開發者ID:d-case,項目名稱:d-case_editor,代碼行數:23,代碼來源:MessageWriter.java

示例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));
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:10,代碼來源:ResourceManager.java

示例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);
	}
	
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:28,代碼來源:ResourceManagerTest.java

示例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();
}
 
開發者ID:alfsch,項目名稱:workspacemechanic,代碼行數:9,代碼來源:LastModifiedPreferencesFileTaskTest.java

示例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();
}
 
開發者ID:SAP,項目名稱:hybris-commerce-eclipse-plugin,代碼行數:12,代碼來源:PlatformHolder.java


注:本文中的org.eclipse.core.runtime.ILog類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。