Search in sources :

Example 1 with LogService

use of org.osgi.service.log.LogService in project sling by apache.

the class MimeTypeServiceImpl method log.

private void log(int level, String message, Throwable t) {
    LogService log = this.logService;
    if (log != null) {
        log.log(level, message, t);
    } else {
        PrintStream out = (level == LogService.LOG_ERROR) ? System.err : System.out;
        out.println(message);
        if (t != null) {
            t.printStackTrace(out);
        }
    }
}
Also used : PrintStream(java.io.PrintStream) LogService(org.osgi.service.log.LogService)

Example 2 with LogService

use of org.osgi.service.log.LogService in project felix by apache.

the class TestBNDManifestLoggerInfo method init.

@Before
public void init() {
    log = (LogReaderService) osgiHelper.getServiceObject(LogReaderService.class.getName(), null);
    if (log == null) {
        throw new RuntimeException("No Log Service !");
    }
    LogService logs = (LogService) osgiHelper.getServiceObject(LogService.class.getName(), null);
    logs.log(LogService.LOG_WARNING, "Ready");
}
Also used : LogReaderService(org.osgi.service.log.LogReaderService) LogService(org.osgi.service.log.LogService) Before(org.junit.Before)

Example 3 with LogService

use of org.osgi.service.log.LogService in project felix by apache.

the class TestSystemLoggerInfo method init.

@Before
public void init() {
    log = (LogReaderService) osgiHelper.getServiceObject(LogReaderService.class.getName(), null);
    if (log == null) {
        throw new RuntimeException("No Log Service !");
    }
    LogService logs = (LogService) osgiHelper.getServiceObject(LogService.class.getName(), null);
    logs.log(LogService.LOG_WARNING, "Ready");
}
Also used : LogReaderService(org.osgi.service.log.LogReaderService) LogService(org.osgi.service.log.LogService) Before(org.junit.Before)

Example 4 with LogService

use of org.osgi.service.log.LogService in project felix by apache.

the class TestSystemLoggerWarning method init.

@Before
public void init() {
    log = (LogReaderService) osgiHelper.getServiceObject(LogReaderService.class.getName(), null);
    if (log == null) {
        throw new RuntimeException("No Log Service !");
    }
    LogService logs = (LogService) osgiHelper.getServiceObject(LogService.class.getName(), null);
    logs.log(LogService.LOG_WARNING, "Ready");
}
Also used : LogReaderService(org.osgi.service.log.LogReaderService) LogService(org.osgi.service.log.LogService) Before(org.junit.Before)

Example 5 with LogService

use of org.osgi.service.log.LogService in project felix by apache.

the class DropAllBundlesCommand method doExecute.

protected void doExecute(DeploymentSessionImpl session) throws Exception {
    AbstractDeploymentPackage target = session.getTargetAbstractDeploymentPackage();
    LogService log = session.getLog();
    BundleInfoImpl[] orderedTargetBundles = target.getOrderedBundleInfos();
    for (int i = orderedTargetBundles.length - 1; i >= 0; i--) {
        BundleInfoImpl bundleInfo = orderedTargetBundles[i];
        // stale bundle, save a copy for rolling back and uninstall it
        String symbolicName = bundleInfo.getSymbolicName();
        try {
            Bundle bundle = target.getBundle(symbolicName);
            if (bundle != null) {
                bundle.uninstall();
                addRollback(new InstallBundleRunnable(bundle, target, log));
            }
        } catch (Exception be) {
            log.log(LogService.LOG_WARNING, "Bundle '" + symbolicName + "' could not be uninstalled", be);
        }
    }
}
Also used : BundleInfoImpl(org.apache.felix.deploymentadmin.BundleInfoImpl) Bundle(org.osgi.framework.Bundle) AbstractDeploymentPackage(org.apache.felix.deploymentadmin.AbstractDeploymentPackage) LogService(org.osgi.service.log.LogService)

Aggregations

LogService (org.osgi.service.log.LogService)57 ServiceTracker (org.osgi.util.tracker.ServiceTracker)15 File (java.io.File)10 ServiceReference (org.osgi.framework.ServiceReference)10 AbstractDeploymentPackage (org.apache.felix.deploymentadmin.AbstractDeploymentPackage)7 Bundle (org.osgi.framework.Bundle)7 HashMap (java.util.HashMap)6 PrintStream (java.io.PrintStream)5 StringWriter (java.io.StringWriter)5 Builder (aQute.bnd.osgi.Builder)4 Jar (aQute.bnd.osgi.Jar)4 Resource (aQute.bnd.osgi.Resource)4 XmlTester (aQute.bnd.test.XmlTester)4 Attributes (java.util.jar.Attributes)4 BundleInfoImpl (org.apache.felix.deploymentadmin.BundleInfoImpl)4 Before (org.junit.Before)4 BundleContext (org.osgi.framework.BundleContext)4 IOException (java.io.IOException)3 Date (java.util.Date)3 Matchers.anyString (org.mockito.Matchers.anyString)3