Search in sources :

Example 16 with FrameworkLogEntry

use of org.eclipse.osgi.framework.log.FrameworkLogEntry 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();
        }
    };
}
Also used : FrameworkLog(org.eclipse.osgi.framework.log.FrameworkLog) FrameworkLogEntry(org.eclipse.osgi.framework.log.FrameworkLogEntry) Logger(org.eclipse.equinox.log.Logger)

Aggregations

FrameworkLogEntry (org.eclipse.osgi.framework.log.FrameworkLogEntry)16 Logger (org.eclipse.equinox.log.Logger)2 FrameworkLog (org.eclipse.osgi.framework.log.FrameworkLog)2 WeavingHookConfigurator (org.eclipse.osgi.internal.weaving.WeavingHookConfigurator)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 Module (org.eclipse.osgi.container.Module)1 DevClassLoadingHook (org.eclipse.osgi.internal.hooks.DevClassLoadingHook)1 EclipseLazyStarter (org.eclipse.osgi.internal.hooks.EclipseLazyStarter)1 SignedBundleHook (org.eclipse.osgi.internal.signedcontent.SignedBundleHook)1 Equinox (org.eclipse.osgi.launch.Equinox)1 ResolutionReport (org.eclipse.osgi.report.resolution.ResolutionReport)1 Location (org.eclipse.osgi.service.datalocation.Location)1 EnvironmentInfo (org.eclipse.osgi.service.environment.EnvironmentInfo)1 Framework (org.osgi.framework.launch.Framework)1 BundleStartLevel (org.osgi.framework.startlevel.BundleStartLevel)1 FrameworkStartLevel (org.osgi.framework.startlevel.FrameworkStartLevel)1 Resource (org.osgi.resource.Resource)1