Search in sources :

Example 36 with LogEntry

use of org.osgi.service.log.LogEntry in project vespa by vespa-engine.

the class ConsoleLogFormatterTestCase method requireThatMessageIsIncluded.

@Test
public void requireThatMessageIsIncluded() {
    LogEntry entry = new MyEntry(0, 0, "message");
    assertEquals("0.000\t-\t-\t-\t-\tunknown\tmessage", SIMPLE_FORMATTER.formatEntry(entry));
}
Also used : LogEntry(org.osgi.service.log.LogEntry) Test(org.junit.Test)

Example 37 with LogEntry

use of org.osgi.service.log.LogEntry in project vespa by vespa-engine.

the class ConsoleLogFormatterTestCase method requireThatExceptionIsSimplifiedForInfoEntries.

@Test
public void requireThatExceptionIsSimplifiedForInfoEntries() {
    Throwable t = new Throwable("exception");
    LogEntry entry = new MyEntry(0, LogService.LOG_INFO, "entry").setException(t);
    assertEquals("0.000\t-\t-\t-\t-\tinfo\tentry: exception", SIMPLE_FORMATTER.formatEntry(entry));
}
Also used : LogEntry(org.osgi.service.log.LogEntry) Test(org.junit.Test)

Example 38 with LogEntry

use of org.osgi.service.log.LogEntry in project vespa by vespa-engine.

the class ConsoleLogFormatterTestCase method requireThatExceptionIsIncluded.

@Test
public void requireThatExceptionIsIncluded() {
    Throwable t = new Throwable();
    LogEntry entry = new MyEntry(0, 0, null).setException(t);
    assertEquals("0.000\t-\t-\t-\t-\tunknown\t\\n" + formatThrowable(t), SIMPLE_FORMATTER.formatEntry(entry));
}
Also used : LogEntry(org.osgi.service.log.LogEntry) Test(org.junit.Test)

Example 39 with LogEntry

use of org.osgi.service.log.LogEntry in project vespa by vespa-engine.

the class ConsoleLogFormatterTestCase method requireThatSimplifiedExceptionMessageIsOptional.

@Test
public void requireThatSimplifiedExceptionMessageIsOptional() {
    Throwable t = new Throwable();
    LogEntry entry = new MyEntry(0, LogService.LOG_INFO, "entry").setException(t);
    assertEquals("0.000\t-\t-\t-\t-\tinfo\tentry: java.lang.Throwable", SIMPLE_FORMATTER.formatEntry(entry));
}
Also used : LogEntry(org.osgi.service.log.LogEntry) Test(org.junit.Test)

Example 40 with LogEntry

use of org.osgi.service.log.LogEntry in project vespa by vespa-engine.

the class ConsoleLogFormatterTestCase method requireThatMillisecondsArePadded.

// TODO: Should (at least) use ConsoleLogFormatter.ABSENCE_REPLACEMENT instead of literal '-'. See ticket 7128315.
@Test
public void requireThatMillisecondsArePadded() {
    for (int i = 0; i < 10000; ++i) {
        LogEntry entry = new MyEntry(i, 0, null);
        assertEquals(String.format("%d.%03d\t-\t-\t-\t-\tunknown\t", i / 1000, i % 1000), SIMPLE_FORMATTER.formatEntry(entry));
    }
}
Also used : LogEntry(org.osgi.service.log.LogEntry) Test(org.junit.Test)

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