use of org.eclipse.osgi.framework.log.FrameworkLog in project rt.equinox.framework by eclipse.
the class EclipseStarter method startup.
/**
* Starts the platform and sets it up to run a single application. The application is either identified
* in the given arguments (e.g., -application <app id>) or in the <code>eclipse.application</code>
* System property. The platform must not be running already.
* <p>
* The given runnable (if not <code>null</code>) is used to tear down the splash screen if required.
* </p>
* @param args the arguments passed to the application
* @return BundleContext the context of the system bundle
* @throws Exception if anything goes wrong
*/
public static BundleContext startup(String[] args, Runnable endSplashHandler) throws Exception {
if (running)
throw new IllegalStateException(Msg.ECLIPSE_STARTUP_ALREADY_RUNNING);
processCommandLine(args);
framework = new Equinox(getConfiguration());
framework.init();
context = framework.getBundleContext();
ServiceReference<FrameworkLog> logRef = context.getServiceReference(FrameworkLog.class);
log = context.getService(logRef);
ServiceReference<EnvironmentInfo> configRef = context.getServiceReference(EnvironmentInfo.class);
equinoxConfig = (EquinoxConfiguration) context.getService(configRef);
equinoxConfig.setAllArgs(allArgs);
equinoxConfig.setFrameworkArgs(frameworkArgs);
equinoxConfig.setAppArgs(appArgs);
registerFrameworkShutdownHandlers();
publishSplashScreen(endSplashHandler);
consoleMgr = ConsoleManager.startConsole(context, equinoxConfig);
Bundle[] startBundles = loadBasicBundles();
if (startBundles == null || ("true".equals(getProperty(PROP_REFRESH_BUNDLES)) && refreshPackages(getCurrentBundles(false)))) {
// $NON-NLS-1$
waitForShutdown();
// cannot continue; loadBasicBundles caused refreshPackages to shutdown the framework
return context;
}
framework.start();
if (isForcedRestart()) {
return context;
}
// set the framework start level to the ultimate value. This will actually start things
// running if they are persistently active.
setStartLevel(getStartLevel());
// they should all be active by this time
ensureBundlesActive(startBundles);
// in the case where the built-in console is disabled we should try to start the console bundle
try {
consoleMgr.checkForConsoleBundle();
} catch (BundleException e) {
FrameworkLogEntry entry = new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, e.getMessage(), 0, e, null);
log.log(entry);
}
// TODO should log unresolved bundles if in debug or dev mode
running = true;
return context;
}
use of org.eclipse.osgi.framework.log.FrameworkLog in project rt.equinox.framework by eclipse.
the class LoggingTests method getLogService.
private LogServiceReference getLogService(BundleContext bc) {
ServiceReference logRef = bc.getServiceReference(ExtendedLogService.class.getName());
assertNotNull("log service ref is null", logRef);
ServiceReference readerRef = bc.getServiceReference(ExtendedLogReaderService.class.getName());
assertNotNull("log reader ref is null", readerRef);
ServiceReference fwkLogRef = bc.getServiceReference(FrameworkLog.class.getName());
assertNotNull("framework log ref is null", fwkLogRef);
ExtendedLogService logService = (ExtendedLogService) bc.getService(logRef);
assertNotNull("log service is null", logService);
ExtendedLogReaderService readerService = (ExtendedLogReaderService) bc.getService(readerRef);
assertNotNull("reader service is null", readerService);
FrameworkLog fwkLog = (FrameworkLog) bc.getService(fwkLogRef);
assertNotNull("framework log is null", fwkLog);
return new LogServiceReference(logRef, logService, readerRef, readerService, fwkLogRef, fwkLog);
}
use of org.eclipse.osgi.framework.log.FrameworkLog in project rt.equinox.framework by eclipse.
the class EquinoxLogFactory method createFrameworkLog.
FrameworkLog createFrameworkLog(Bundle bundle, EquinoxLogWriter eclipseWriter) {
final EquinoxLogWriter logWriter = eclipseWriter == null ? defaultWriter : eclipseWriter;
final Logger logger = bundle == null ? logManager.getSystemBundleLog().getLogger(eclipseWriter.getLoggerName()) : logManager.getSystemBundleLog().getLogger(bundle, logWriter.getLoggerName());
return new FrameworkLog() {
public void setWriter(Writer newWriter, boolean append) {
logWriter.setWriter(newWriter, append);
}
public void setFile(File newFile, boolean append) throws IOException {
logWriter.setFile(newFile, append);
}
public void setConsoleLog(boolean consoleLog) {
logWriter.setConsoleLog(consoleLog);
}
public void log(FrameworkLogEntry logEntry) {
logger.log(logEntry, convertLevel(logEntry), logEntry.getMessage(), logEntry.getThrowable());
}
public void log(FrameworkEvent frameworkEvent) {
Bundle b = frameworkEvent.getBundle();
Throwable t = frameworkEvent.getThrowable();
String entry = b.getSymbolicName() == null ? b.getLocation() : b.getSymbolicName();
int severity;
switch(frameworkEvent.getType()) {
case FrameworkEvent.INFO:
severity = FrameworkLogEntry.INFO;
break;
case FrameworkEvent.ERROR:
severity = FrameworkLogEntry.ERROR;
break;
case FrameworkEvent.WARNING:
severity = FrameworkLogEntry.WARNING;
break;
default:
severity = FrameworkLogEntry.OK;
}
// $NON-NLS-1$
FrameworkLogEntry logEntry = new FrameworkLogEntry(entry, severity, 0, "", 0, t, null);
log(logEntry);
}
public File getFile() {
return logWriter.getFile();
}
public void close() {
logWriter.close();
}
};
}
Aggregations