org.eclipse.core.runtime.ILog Java Examples

The following examples show how to use org.eclipse.core.runtime.ILog. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EclipseLogAppender.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@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);

			// Injector injector = N4JSActivator.getInstance().getInjector(N4JSActivator.ORG_ECLIPSE_N4JS_N4JS);
			// if (injector != null) {
			getLog().log(status);
			// }
		} else {
			// nothing to do (message should be logged to stdout by default appender)
		}
	}
}
 
Example #2
Source File: DocumentProvider.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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( ) );
}
 
Example #3
Source File: EclipseLogAppender.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@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)
		}
	}
}
 
Example #4
Source File: UpdateDetailsPresenter.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
@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.");
  }
}
 
Example #5
Source File: ProblemReporter.java    From EasyMPermission with MIT License 6 votes vote down vote up
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."));
	}
}
 
Example #6
Source File: TestEditor.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
protected void validateState(IEditorInput input) {

		IDocumentProvider provider = getDocumentProvider();
		if (!(provider instanceof IDocumentProviderExtension))
			return;

		IDocumentProviderExtension extension = (IDocumentProviderExtension) provider;

		try {

			extension.validateState(input, getSite().getShell());

		} catch (CoreException x) {
			IStatus status = x.getStatus();
			if (status == null || status.getSeverity() != IStatus.CANCEL) {
				Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
				ILog log = Platform.getLog(bundle);
				log.log(x.getStatus());

				Shell shell = getSite().getShell();
				String title = "EditorMessages.Editor_error_validateEdit_title";
				String msg = "EditorMessages.Editor_error_validateEdit_message";
				ErrorDialog.openError(shell, title, msg, x.getStatus());
			}
			return;
		}

		if (fSourceViewer != null)
			fSourceViewer.setEditable(isEditable());

	}
 
Example #7
Source File: EP_LogThrowErrorImpl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
public void newError(int severity, String message, Exception exception) {
  String pluginId = JgPlugin.getUniqueIdentifier();        
  ILog log = JgPlugin.getDefault().getLog();
  log.log(new Status(logLevels[severity], pluginId, IStatus.OK, message, exception));
  if (IError.WARN < severity)
    throw new ErrorExit();
}
 
Example #8
Source File: SARLEclipsePluginTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
	this.old = Debug.out;
	Debug.out = mock(PrintStream.class);
	this.logger = mock(ILog.class);
	// Cannot create a "spyied" version of getILog() since it
	// will be directly called by the underlying implementation.
	// For providing a mock for the ILog, only subclassing is working.
	this.plugin = new SARLEclipsePlugin() {
		public ILog getILog() {
			return logger;
		}
	};
	SARLEclipsePlugin.setDefault(this.plugin);
}
 
Example #9
Source File: SARLMavenEclipsePluginTest.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
	this.old = Debug.out;
	Debug.out = mock(PrintStream.class);
	this.logger = mock(ILog.class);
	// Cannot create a "spyied" version of getILog() since it
	// will be directly called by the underlying implementation.
	// For providing a mock for the ILog, only subclassing is working.
	this.plugin = new SARLMavenEclipsePlugin() {
		public ILog getILog() {
			return logger;
		}
	};
	SARLMavenEclipsePlugin.setDefault(this.plugin);
}
 
Example #10
Source File: Slf4jEclipseLoggerFactory.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Replies the Eclipse logger to be used.
 *
 * @return the logger.
 */
protected synchronized ILog getEclipseLogger() {
	if (this.eclipseLogger == null) {
		this.eclipseLogger = InternalPlatform.getDefault().getLog(getBundle());
	}
	return this.eclipseLogger;
}
 
Example #11
Source File: LastModifiedPreferencesFileTaskTest.java    From workspacemechanic with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
  ref = mock(IResourceTaskReference.class);
  ilog = mock(ILog.class);
  prefs = mock(IMechanicPreferences.class);
  log = new MechanicLog(ilog);
  super.setUp();
}
 
Example #12
Source File: PlatformHolder.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #13
Source File: TestEditor.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
protected void validateState(final IEditorInput input) {

        final IDocumentProvider provider = getDocumentProvider();
        if (!(provider instanceof IDocumentProviderExtension))
            return;

        final IDocumentProviderExtension extension = (IDocumentProviderExtension) provider;

        try {

            extension.validateState(input, getSite().getShell());

        } catch (final CoreException x) {
            final IStatus status = x.getStatus();
            if (status == null || status.getSeverity() != IStatus.CANCEL) {
                final Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
                final ILog log = Platform.getLog(bundle);
                log.log(x.getStatus());

                final Shell shell = getSite().getShell();
                final String title = "EditorMessages.Editor_error_validateEdit_title";
                final String msg = "EditorMessages.Editor_error_validateEdit_message";
                ErrorDialog.openError(shell, title, msg, x.getStatus());
            }
            return;
        }

        if (fSourceViewer != null)
            fSourceViewer.setEditable(isEditable());

    }
 
Example #14
Source File: EclipseLogAppender.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
private ILog getLog() {
	ensureInitialized();
	return log;
}
 
Example #15
Source File: LoggerImpl.java    From LogViewer with Eclipse Public License 2.0 4 votes vote down vote up
public LoggerImpl(ILog log, String pluginId) {
	this.log = log;
	this.pluginId = pluginId;
}
 
Example #16
Source File: GeneratorLocator.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
public GeneratorLocator ( final BundleContext context, final ILog log )
{
    this.context = context;
    this.log = log;
}
 
Example #17
Source File: Activator.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public ILog getLogger(){
    return Platform.getLog(Platform.getBundle(Activator.PLUGIN_ID));
}
 
Example #18
Source File: LangCorePlugin.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void logStatus(StatusException se) {
	int severity = EclipseUtils.toEclipseSeverity(se);
	ILog log = LangCorePlugin.getInstance().getLog();
	log.log(EclipseCore.createStatus(severity, se.getMessage(), se.getCause()));
}
 
Example #19
Source File: MechanicLog.java    From workspacemechanic with Eclipse Public License 1.0 4 votes vote down vote up
public MechanicLog(ILog log) {
  this.log = Preconditions.checkNotNull(log);
}
 
Example #20
Source File: DeveloperStudioLog.java    From developer-studio with Apache License 2.0 4 votes vote down vote up
public static ILog getLog() {
 return LOG;
}
 
Example #21
Source File: EclipseLogAppender.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
private ILog getLog() {
	ensureInitialized();
	return log;
}
 
Example #22
Source File: IUpdateDetailsPresenter.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
void presentUpdateDetails(Shell shell, String updateSiteUrl, ILog log,
String pluginId);
 
Example #23
Source File: LogUtils.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
private static String getBundleSymbolicName(ILog log) {
  return log.getBundle().getSymbolicName();
}
 
Example #24
Source File: DSL4SARLEclipsePlugin.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** Replies the logger.
 *
 * <p>Thus function is a non-final version of {@link #getLog()}.
 *
 * @return the logger.
 */
public ILog getILog() {
	return getLog();
}
 
Example #25
Source File: Slf4jEclipseLogger.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** Constructor.
 *
 * @param name the name of the logger.
 * @param log the M2E logger.
 */
public Slf4jEclipseLogger(String name, ILog log) {
	this.name = name;
	this.logger = log;
}
 
Example #26
Source File: SARLEclipsePlugin.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** Replies the logger.
 *
 * <p>Thus function is a non-final version of {@link #getLog()}.
 *
 * @return the logger.
 */
public ILog getILog() {
	return getLog();
}
 
Example #27
Source File: SARLMavenEclipsePlugin.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** Replies the logger.
 *
 * <p>Thus function is a non-final version of {@link #getLog()}.
 *
 * @return the logger.
 */
public ILog getILog() {
	return getLog();
}
 
Example #28
Source File: LogUtils.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Log the specified warning.
 * 
 * @param message a human-readable message, localized to the current locale.
 */
public static void logWarning(ILog log, String message) {
  log(log, IStatus.WARNING, IStatus.OK, message, null);
}
 
Example #29
Source File: LogUtils.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Log the specified information.
 * 
 * @param message a human-readable message, localized to the current locale.
 * @param args message arguments.
 */
public static void logInfo(ILog log, String message, Object... args) {
  message = MessageFormat.format(message, args);
  log(log, IStatus.INFO, IStatus.OK, message, null);
}
 
Example #30
Source File: LogUtils.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Log the specified information.
 * 
 * @param message a human-readable message, localized to the current locale.
 */
public static void logInfo(ILog log, String message) {
  logInfo(log, message, new Object[0]);
}