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

项目: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);
    }
}
项目:emfstore-rest    文件:EMFStoreController.java   
private void initLogging() {
    Platform.getLog(Platform.getBundle(EMFSTORE_COMMON_BUNDLE)).addLogListener(new
        ILogListener() {

            public void logging(IStatus status, String plugin) {
                if (status.getSeverity() == IStatus.INFO) {
                    System.out.println(status.getMessage());
                } else if (!status.isOK()) {
                    System.err.println(status.getMessage());
                    final Throwable exception = status.getException();
                    if (exception != null) {
                        exception.printStackTrace(System.err);
                    }
                }
            }

        });
}
项目: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);
    }

}
项目:eclipse.jdt.ls    文件:LogHandler.java   
public void install(JavaClientConnection rcpConnection) {
    this.dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
    this.logLevelMask = getLogLevelMask(System.getProperty("log.level", ""));//Empty by default
    this.calendar = Calendar.getInstance();
    this.connection = rcpConnection;

    this.logListener = new ILogListener() {
        @Override
        public void logging(IStatus status, String bundleId) {
            processLogMessage(status);
        }
    };
    Platform.addLogListener(this.logListener);
}
项目:spotless    文件:GroovyCoreActivator.java   
@Override
public void log(IStatus status) {
    for (ILogListener listener : listeners) {
        listener.logging(status, PLUGIN_ID);
    }
    if (QUIET_SEVERITIES.contains(status.getSeverity())) {
        System.out.println(status.getMessage());
    } else {
        System.err.println(status.getMessage());
    }
}
项目: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);
}
项目:gw4e.project    文件:GW4EProjectTestCase.java   
@Test
public void testOfflineStandAloneModeWithTimeout() throws Exception {
    boolean[] result = new boolean [] {false};
    ILogListener listener = new ILogListener() {
        @Override
        public void logging(IStatus status, String plugin) {
             if (status.getMessage().indexOf("Operation cancelled either manually or a timeout occured.")!=-1) {
                 result[0] = true;
             }
        }
    };

    GW4EProject project = new GW4EProject(bot, gwproject);
    project.createSimpleProjectWithoutGeneration ();

    IFile buildPolicyFile = (IFile) ResourceManager.getResource("gwproject/src/main/resources/com/company/build.policies");
    BuildPolicyManager.setPolicies(buildPolicyFile, "Simple.json", "random(never);I", new NullProgressMonitor ());
    buildPolicyFile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor ());
    FileParameters fp = project.generateForSimpleProject ();
    fp.setTargetFilename("SimpleOffLineImpl");
    OfflineTestUIPageTest page = walkToToOfflinePage(gwproject,fp); 
    page.selectTimeout("1");
    page.selectStandAloneMode("MyClazz");
    page.selectGenerators(new String [] {"random(never)"});


    try {
        ErrorDialog.AUTOMATED_MODE = true;
        ResourceManager.addLogListener(listener);
        page.finish();

        ICondition condition = new DefaultCondition () {
            @Override
            public boolean test() throws Exception {
                return result[0];
            }

            @Override
            public String getFailureMessage() {
                return "Operation not cancelled";
            }
        };

        bot.waitUntil(condition,3 * 6 * SWTBotPreferences.TIMEOUT); //3mn
    } finally {
        ErrorDialog.AUTOMATED_MODE = false;
        ResourceManager.removeLogListener(listener);
    }
    closeWizard ();
}
项目:workspacemechanic    文件:EmptyLog.java   
public void removeLogListener(ILogListener listener) {
}
项目:workspacemechanic    文件:EmptyLog.java   
public void addLogListener(ILogListener listener) {
}
项目:spotless    文件:GroovyCoreActivator.java   
public LogAdapter(Bundle bundle) {
    listeners = new HashSet<ILogListener>();
    this.bundle = bundle;
}
项目:spotless    文件:GroovyCoreActivator.java   
@Override
public void addLogListener(ILogListener arg0) {
    listeners.add(arg0);
}
项目:spotless    文件:GroovyCoreActivator.java   
@Override
public void removeLogListener(ILogListener arg0) {
    listeners.remove(arg0);
}