Search in sources :

Example 6 with LogEntry

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

the class TestBNDManifestLoggerInfo method getMessages.

private List<String> getMessages(Enumeration<LogEntry> log2) {
    List<String> list = new ArrayList<String>();
    while (log2.hasMoreElements()) {
        LogEntry entry = (LogEntry) log2.nextElement();
        list.add(entry.getMessage());
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) LogEntry(org.osgi.service.log.LogEntry)

Example 7 with LogEntry

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

the class TestSystemLoggerInfo method getMessages.

private List<String> getMessages(Enumeration<LogEntry> log2) {
    List<String> list = new ArrayList<String>();
    while (log2.hasMoreElements()) {
        LogEntry entry = (LogEntry) log2.nextElement();
        list.add(entry.getMessage());
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) LogEntry(org.osgi.service.log.LogEntry)

Example 8 with LogEntry

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

the class TestSystemLoggerWarning method getMessages.

private List<String> getMessages(Enumeration<LogEntry> log2) {
    List<String> list = new ArrayList<String>();
    while (log2.hasMoreElements()) {
        LogEntry entry = (LogEntry) log2.nextElement();
        list.add(entry.getMessage());
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) LogEntry(org.osgi.service.log.LogEntry)

Example 9 with LogEntry

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

the class Log method bundleChanged.

/**
 * Called when a bundle event occurs.
 * @param event the event that occured
 */
public void bundleChanged(final BundleEvent event) {
    int eventType = event.getType();
    String message = null;
    for (int i = 0; message == null && i < BUNDLE_EVENT_MESSAGES.length; ++i) {
        if (eventType >> i == 1) {
            message = BUNDLE_EVENT_MESSAGES[i];
        }
    }
    if (message != null) {
        LogEntry entry = new LogEntryImpl(event.getBundle(), null, LogService.LOG_INFO, message, null);
        addEntry(entry);
    }
}
Also used : LogEntry(org.osgi.service.log.LogEntry)

Example 10 with LogEntry

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

the class Log method frameworkEvent.

/**
 * Called when a framework event occurs.
 * @param event the event that occured
 */
public void frameworkEvent(final FrameworkEvent event) {
    int eventType = event.getType();
    String message = null;
    for (int i = 0; message == null && i < FRAMEWORK_EVENT_MESSAGES.length; ++i) {
        if (eventType >> i == 1) {
            message = FRAMEWORK_EVENT_MESSAGES[i];
        }
    }
    LogEntry entry = new LogEntryImpl(event.getBundle(), null, (eventType == FrameworkEvent.ERROR) ? LogService.LOG_ERROR : LogService.LOG_INFO, message, event.getThrowable());
    addEntry(entry);
}
Also used : LogEntry(org.osgi.service.log.LogEntry)

Aggregations

LogEntry (org.osgi.service.log.LogEntry)40 Test (org.junit.Test)18 ArrayList (java.util.ArrayList)6 LogReaderService (org.osgi.service.log.LogReaderService)5 BundleException (org.osgi.framework.BundleException)4 Enumeration (java.util.Enumeration)3 ServiceReference (org.osgi.framework.ServiceReference)3 LogListener (org.osgi.service.log.LogListener)3 SynchronousLogListener (org.eclipse.equinox.log.SynchronousLogListener)2 BundleContext (org.osgi.framework.BundleContext)2 TestDriver (com.yahoo.jdisc.test.TestDriver)1 File (java.io.File)1 Formatter (java.util.Formatter)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Vector (java.util.Vector)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1