Search in sources :

Example 1 with ExtendedLogEntry

use of org.eclipse.equinox.log.ExtendedLogEntry in project rt.equinox.framework by eclipse.

the class ExtendedLogReaderServiceTest method testExtendedLogEntry.

public void testExtendedLogEntry() throws Exception {
    TestListener listener = new TestListener();
    reader.addLogListener(listener);
    long timeBeforeLog = System.currentTimeMillis();
    String threadName = Thread.currentThread().getName();
    long threadId = getCurrentThreadId();
    synchronized (listener) {
        log.getLogger("test").log(logReference, LogService.LOG_INFO, "info", new Throwable("test"));
        listener.waitForLogEntry();
    }
    ExtendedLogEntry entry = listener.getEntryX();
    long sequenceNumberBefore = entry.getSequenceNumber();
    synchronized (listener) {
        log.getLogger("test").log(logReference, LogService.LOG_INFO, "info", new Throwable("test"));
        listener.waitForLogEntry();
    }
    entry = listener.getEntryX();
    assertTrue(entry.getBundle() == OSGiTestsActivator.getContext().getBundle());
    assertTrue(entry.getMessage().equals("info"));
    assertTrue(entry.getException().getMessage().equals("test"));
    assertTrue(entry.getServiceReference() == logReference);
    assertTrue(entry.getTime() >= timeBeforeLog);
    assertTrue(entry.getLevel() == LogService.LOG_INFO);
    assertTrue(entry.getLoggerName().equals("test"));
    assertTrue(entry.getThreadName().equals(threadName));
    if (threadId >= 0)
        assertTrue(entry.getThreadId() == threadId);
    assertTrue(entry.getContext() == logReference);
    assertTrue(entry.getSequenceNumber() > sequenceNumberBefore);
}
Also used : ExtendedLogEntry(org.eclipse.equinox.log.ExtendedLogEntry)

Example 2 with ExtendedLogEntry

use of org.eclipse.equinox.log.ExtendedLogEntry in project rt.equinox.framework by eclipse.

the class TestListener method getEntryX.

public synchronized ExtendedLogEntry getEntryX() {
    ExtendedLogEntry current = (ExtendedLogEntry) entry;
    entry = null;
    return current;
}
Also used : ExtendedLogEntry(org.eclipse.equinox.log.ExtendedLogEntry)

Aggregations

ExtendedLogEntry (org.eclipse.equinox.log.ExtendedLogEntry)2