Search in sources :

Example 16 with LogEntry

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

the class ConsoleLogFormatterTestCase method requireThatSimplifiedExceptionIsEscaped.

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

Example 17 with LogEntry

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

the class ConsoleLogFormatterTestCase method requireThatMessageIsEscaped.

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

Example 18 with LogEntry

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

the class ConsoleLogFormatterTestCase method requireThatProcessIdIncludesThreadIdWhenAvailable.

@Test
public void requireThatProcessIdIncludesThreadIdWhenAvailable() {
    LogEntry entry = new MyEntry(0, 0, null).putProperty("THREAD_ID", "threadId");
    assertEquals("0.000\t-\tprocessId/threadId\t-\t-\tunknown\t", new ConsoleLogFormatter(null, "processId", null).formatEntry(entry));
}
Also used : LogEntry(org.osgi.service.log.LogEntry) Test(org.junit.Test)

Example 19 with LogEntry

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

the class ConsoleLogFormatterTestCase method requireThatLoggerNameIsIncluded.

@Test
public void requireThatLoggerNameIsIncluded() {
    LogEntry entry = new MyEntry(0, 0, null).putProperty("LOGGER_NAME", "loggerName");
    assertEquals("0.000\t-\t-\t-\t/loggerName\tunknown\t", SIMPLE_FORMATTER.formatEntry(entry));
}
Also used : LogEntry(org.osgi.service.log.LogEntry) Test(org.junit.Test)

Example 20 with LogEntry

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

the class ConsoleLogFormatterTestCase method requireThatExceptionIsEscaped.

@Test
public void requireThatExceptionIsEscaped() {
    Throwable t = new Throwable("\\\n\r\t");
    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)

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