Java 类org.eclipse.core.runtime.ILog 实例源码

项目:n4js    文件:EclipseLogAppender.java   
@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)
        }
    }
}
项目:gw4e.project    文件:ResourceManagerTest.java   
@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);
    }
}
项目:gw4e.project    文件:ResourceManagerTest.java   
@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);
    }
}
项目:lombok-ianchiu    文件:ProblemReporter.java   
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."));
    }
}
项目:EasyMPermission    文件:ProblemReporter.java   
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."));
    }
}
项目:gwt-eclipse-plugin    文件:UpdateDetailsPresenter.java   
@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.");
  }
}
项目:mytourbook    文件:CommandRunner.java   
/**
* 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);
    }
}
项目:OpenSPIFe    文件:TreeTimelineContentProvider.java   
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);
    }
}
项目:idecore    文件:LogAppender.java   
@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);
}
项目:genModelAddon    文件:Util.java   
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));
    }
}
项目:birt    文件:DocumentProvider.java   
/**
 * 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( ) );
}
项目:d-case_editor    文件:MessageWriter.java   
/**
 * 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));
    }
}
项目:gw4e.project    文件:ResourceManager.java   
/**
 * @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));
}
项目:gw4e.project    文件:ResourceManagerTest.java   
@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);
    }

}
项目:workspacemechanic    文件:LastModifiedPreferencesFileTaskTest.java   
@Override
protected void setUp() throws Exception {
  ref = mock(IResourceTaskReference.class);
  ilog = mock(ILog.class);
  prefs = mock(IMechanicPreferences.class);
  log = new MechanicLog(ilog);
  super.setUp();
}
项目:hybris-commerce-eclipse-plugin    文件:PlatformHolder.java   
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();
}
项目:ermasterr    文件:TestEditor.java   
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());

    }
项目:ermaster-k    文件:TestEditor.java   
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());

    }
项目:spotless    文件:ErrorRecoveredCSTParserPluginFactory.java   
@Override
public void reportErrors(String fileName, @SuppressWarnings("rawtypes") List errors) {
    ILog log = GroovyCoreActivator.getDefault().getLog();
    for (Object error : errors) {
        log.log(new Status(Status.ERROR, GroovyCoreActivator.PLUGIN_ID, error.toString()));
    }
}
项目:synergyview    文件:ResourceLoader.java   
/**
    * Gets the string.
    * 
    * @param key
    *            the key
    * @return the string
    */
   public static String getString(String key) {
final ILog logger = Activator.getDefault().getLog();
try {
    String keyValue = new String(rb.getString(key).getBytes("ISO-8859-1"), "UTF-8");
    return keyValue;
} catch (Exception ex) {
    IStatus status = new Status(IStatus.WARNING, Activator.PLUGIN_ID, ex.getMessage(), ex);
    logger.log(status);
    return key;
}
   }
项目:synergyview    文件:ResourceLoader.java   
/**
    * Sets the bundle.
    * 
    * @param locale
    *            the new bundle
    */
   public static void setBundle(Locale locale) {
final ILog logger = Activator.getDefault().getLog();
try {
    rb = ResourceBundle.getBundle(BUNDLE_NAME, locale);
} catch (Exception ex) {
    IStatus status = new Status(IStatus.WARNING, Activator.PLUGIN_ID, ex.getMessage(), ex);
    logger.log(status);
    rb = ResourceBundle.getBundle(BUNDLE_NAME, Locale.ENGLISH);
}
   }
项目:synergyview    文件:OpenCollectionMediaEditorHandler.java   
public Object execute(ExecutionEvent event) throws ExecutionException {
final ILog logger = Activator.getDefault().getLog();

ISelection selection = HandlerUtil.getCurrentSelection(event);
if (!(selection instanceof IStructuredSelection)) {
    return null;
}
IStructuredSelection structSel = (IStructuredSelection) selection;

Object element = null;

try {
    element = structSel.iterator().next();
} catch (NoSuchElementException e) {
}

if (element != null) {

    if (element instanceof CollectionNode) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage page = window.getActivePage();
    IEditorInput editorInput = new NodeEditorInput((INode) element);
    try {
        page.openEditor(editorInput, CollectionEditor.ID);
    } catch (PartInitException ex) {
        IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, ex.getMessage(), ex);
        logger.log(status);
    }
    }
    ;
}

return null;
   }
项目:synergyview    文件:RenameAnnotationSetHandler.java   
public Object execute(ExecutionEvent event) throws ExecutionException {
final ILog logger = Activator.getDefault().getLog();
ISelection selection = HandlerUtil.getCurrentSelection(event);

if (!(selection instanceof IStructuredSelection)) {
    return null;
}
IStructuredSelection structSel = (IStructuredSelection) selection;
Object object = structSel.getFirstElement();
if (object instanceof AnnotationSetNode) {
    AnnotationSetNode node = (AnnotationSetNode) object;
    IInputValidator validator = new IInputValidator() {
    public String isValid(String newText) {
        if (!newText.equalsIgnoreCase("")) {
        return null;
        } else {
        return "Name empty!";
        }
    }
    };
    InputDialog dialog = new InputDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Rename Annoatation Set", "Enter Annotation Set Name:", node.getResource().getName(), validator);
    if (dialog.open() == Window.OK) {
    try {
        node.renameAnnotationSet(dialog.getValue());
    } catch (ModelPersistenceException e) {
        IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to rename the Annotation Set", e);
        logger.log(status);
        MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Save Error", "Unable to rename the Annotation Set!");
    }
    } else {
    return null;
    }
}
return null;
   }
项目:ermaster-nhit    文件:TestEditor.java   
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());

    }
项目:EclipseCommander    文件:EclipseAppender.java   
@Override
protected void append(ILoggingEvent event) {
    Bundle bundle = Platform.getBundle("cane.brothers.e4.commander.logging.logback"); //$NON-NLS-1$
    if (bundle == null) {
        System.out.println("No bundle found when trying to log to eclipse."); //$NON-NLS-1$
    }
    else {
        ILog log = Platform.getLog(bundle);
        log.log(new Status(getStatus(event), event.getLoggerName(), event.getMessage()));
    }
}
项目:idecore    文件:LogAppender.java   
private ILog getBundleILog() {
    // get the bundle for a plug-in
    Bundle b = Platform.getBundle(ForceIdeCorePlugin.getPluginId());
    if(b == null) {
        String m = MessageFormat.format("Plugin: {0} not found in {1}.",
                new Object[] { ForceIdeCorePlugin.getPluginId(), this.name });
        this.errorHandler.error(m);
        return null;
    }

    return Platform.getLog(b);
}
项目:genModelAddon    文件:GenerateCommon.java   
public static void setProperty(final IFile f, final QualifiedName qn, final String value) {
  try {
    f.setPersistentProperty(qn, value);
  } catch (final Throwable _t) {
    if (_t instanceof Exception) {
      final Exception e = (Exception)_t;
      final Bundle bndl = FrameworkUtil.getBundle(GenerateCommon.class);
      final ILog logger = Platform.getLog(bndl);
      Status _status = new Status(IStatus.WARNING, GMAConstants.PLUGIN_ID, ("Unable to store the property : " + qn), e);
      logger.log(_status);
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
}
项目:wt-studio    文件:JsonLog.java   
public static JsonLog getInstance(String pluginId, ILog log) {
    if (singleton != null) {
        return singleton;
    }
    singleton = new JsonLog(pluginId, log);
    return singleton;
}
项目:victims-plugin-eclipse-legacy    文件:Settings.java   
/**
 * Use the supplied log to display the current settings.
 * @param log Log to send output to.
 */
public void show(ILog log) {
  StringBuilder info = new StringBuilder();
  info.append(TextUI.box(TextUI.fmt(Resources.INFO_SETTINGS_HEADING)));
  for (Entry<String, String> kv : settings.entrySet()){
    info.append(String.format("%-12s = %s\n", kv.getKey(), kv.getValue()));
  }
  log.log(new Status(Status.INFO, Activator.PLUGIN_ID, info.toString()));
}
项目:lombok    文件:EclipseHandlerUtil.java   
private void msg(int msgType, String message, String bundleName, Throwable error) {
    Bundle bundle = Platform.getBundle(bundleName);
    if (bundle == null) {
        System.err.printf("Can't find bundle %s while trying to report error:\n%s\n", bundleName, message);
        return;
    }

    ILog log = Platform.getLog(bundle);

    log.log(new Status(msgType, bundleName, message, error));
}
项目:n4js    文件:EclipseLogAppender.java   
private ILog getLog() {
    ensureInitialized();
    return log;
}
项目:eclipse-jenkins-editor    文件:JenkinsEditorLogSupport.java   
protected ILog getLog() {
    ILog log = JenkinsEditorActivator.getDefault().getLog();
    return log;
}
项目:eclipse-jenkins-editor    文件:JenkinsEditorUtil.java   
private static ILog getLog() {
    ILog log = JenkinsEditorActivator.getDefault().getLog();
    return log;
}
项目:eclipse-batch-editor    文件:BatchEditorUtil.java   
private static ILog getLog() {
    ILog log = BatchEditorActivator.getDefault().getLog();
    return log;
}
项目:eclipse-batch-editor    文件:EclipseUtil.java   
private static ILog getLog() {
    ILog log = BatchEditorActivator.getDefault().getLog();
    return log;
}
项目:neoscada    文件:GeneratorLocator.java   
public GeneratorLocator ( final BundleContext context, final ILog log )
{
    this.context = context;
    this.log = log;
}
项目:eclipse-bash-editor    文件:BashEditorUtil.java   
private static ILog getLog() {
    ILog log = BashEditorActivator.getDefault().getLog();
    return log;
}
项目:eclipse-bash-editor    文件:EclipseUtil.java   
private static ILog getLog() {
    ILog log = BashEditorActivator.getDefault().getLog();
    return log;
}
项目:gw4e.project    文件:ResourceManager.java   
/**
 * @param listener
 */
public static void removeLogListener(ILogListener listener) {
    ILog log = Activator.getDefault().getLog();
    log.removeLogListener(listener);
}
项目:gw4e.project    文件:ResourceManager.java   
/**
 * @param listener
 */
public static void addLogListener(ILogListener listener) {
    ILog log = Activator.getDefault().getLog();
    log.addLogListener(listener);
}