@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); } }
@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); } }
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); } } } }); }
@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); } }
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); }
@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()); } }
/** * @param listener */ public static void removeLogListener(ILogListener listener) { ILog log = Activator.getDefault().getLog(); log.removeLogListener(listener); }
/** * @param listener */ public static void addLogListener(ILogListener listener) { ILog log = Activator.getDefault().getLog(); log.addLogListener(listener); }
@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 (); }
public void removeLogListener(ILogListener listener) { }
public void addLogListener(ILogListener listener) { }
public LogAdapter(Bundle bundle) { listeners = new HashSet<ILogListener>(); this.bundle = bundle; }
@Override public void addLogListener(ILogListener arg0) { listeners.add(arg0); }
@Override public void removeLogListener(ILogListener arg0) { listeners.remove(arg0); }