Examples of LogService


Examples of org.osgi.service.log.LogService

    }


    public static void log( int level, String message, Throwable exception )
    {
        LogService log = ( LogService ) INSTANCE.logService.getService();
        if ( log == null )
        {
            _log( null, level, message, exception );
        }
        else
        {
            log.log( level, message, exception );
        }
    }
View Full Code Here

Examples of org.osgi.service.log.LogService

    }


    public static void log( ServiceReference sr, int level, String message )
    {
        LogService log = ( LogService ) INSTANCE.logService.getService();
        if ( log == null )
        {
            _log( sr, level, message, null );
        }
        else
        {
            log.log( sr, level, message );
        }
    }
View Full Code Here

Examples of org.osgi.service.log.LogService

    }


    public static void log( ServiceReference sr, int level, String message, Throwable exception )
    {
        LogService log = ( LogService ) INSTANCE.logService.getService();
        if ( log == null )
        {
            _log( sr, level, message, exception );
        }
        else
        {
            log.log( sr, level, message, exception );
        }
    }
View Full Code Here

Examples of org.osgi.service.log.LogService

        this.tracker.close();
    }

    public void log(ServiceReference ref, int level, String message, Throwable cause)
    {
        LogService log = (LogService)this.tracker.getService();
        if (log != null) {
            log.log(ref, level, message, cause);
        } else {
            this.consoleLogger.log(ref, level, message, cause);
        }
    }
View Full Code Here

Examples of org.osgi.service.log.LogService

*/
public class DropAllBundlesCommand extends Command {

    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);
            }
        }
    }
View Full Code Here

Examples of org.osgi.service.log.LogService

    public static void log( int level, Bundle bundle, String message, Throwable ex )
    {
        if ( isLogEnabled( level ) )
        {
            ServiceTracker<LogService, LogService> t = m_logService;
            LogService logger = ( t != null ) ? t.getService() : null;
            if ( logger == null )
            {
                // output depending on level
                PrintStream out = ( level == LogService.LOG_ERROR ) ? System.err : System.out;

                // level as a string
                StringBuffer buf = new StringBuffer();
                switch ( level )
                {
                    case ( LogService.LOG_DEBUG     ):
                        buf.append( "DEBUG: " );
                        break;
                    case ( LogService.LOG_INFO     ):
                        buf.append( "INFO : " );
                        break;
                    case ( LogService.LOG_WARNING     ):
                        buf.append( "WARN : " );
                        break;
                    case ( LogService.LOG_ERROR     ):
                        buf.append( "ERROR: " );
                        break;
                    default:
                        buf.append( "UNK  : " );
                        break;
                }

                // bundle information
                if ( bundle != null )
                {
                    buf.append( bundle.getSymbolicName() );
                    buf.append( " (" );
                    buf.append( bundle.getBundleId() );
                    buf.append( "): " );
                }

                // the message
                buf.append( message );

                // keep the message and the stacktrace together
                synchronized ( out)
                {
                    out.println( buf );
                    if ( ex != null )
                    {
                        ex.printStackTrace( out );
                    }
                }
            }
            else
            {
                logger.log( level, message, ex );
            }
        }
    }
View Full Code Here

Examples of org.osgi.service.log.LogService

            }

            ServiceTracker<LogService, LogService> logService = m_logService;
            if ( logService != null )
            {
                LogService logger = logService.getService();
                if ( logger == null )
                {
                    Activator.log( level, m_bundle, message, ex );
                }
                else
                {
                    logger.log( level, message, ex );
                }
            }
            else
            {
                // BCA has been disposed off, bundle context is probably invalid. Try to log something.
View Full Code Here

Examples of org.osgi.service.log.LogService

    // this test always expects output since when using a LogService, the log
    // level property is ignored
    public void testLogWithLogService()
    {
        LogService logService = new MockLogService();
        ConfigurationManager configMgr = createConfigurationManager( logService );

        setLogLevel( configMgr, LogService.LOG_WARNING );
        assertLog( configMgr, LogService.LOG_DEBUG, "Debug Test Message", null );
        assertLog( configMgr, LogService.LOG_INFO, "Info Test Message", null );
View Full Code Here

Examples of org.osgi.service.log.LogService

            }
        }
    }

    protected void log(final int level, final String message, final Throwable t) {
        final LogService log = (LogService) this.logTracker.getService();
        if (log != null) {
            log.log(level, message, t);
            return;
        }
    }
View Full Code Here

Examples of org.osgi.service.log.LogService

        return log;
    }

    public static void log(int level, String message)
    {
        LogService service = getLogService();
        if (service != null)
        {
            service.log(level, message);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.